WebAPI/Controllers/MJGL/Sc_MouldProdInBillController.cs
@@ -100,6 +100,68 @@
        #endregion
        #region 模具采购入库单列表 查询-分页
        /// <summary>
        /// 返回应收单列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sc_MouldProdInBill/list_byPage")]
        [HttpGet]
        public object getSc_MouldProdInBill_byPage(string sWhere, string user, string Organization, int page, int size)
        {
            try
            {
                Log.LogInfo("成功!"); //记录提交数据
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdInBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Log.LogInfo("有权限");
                LogService.Write(sWhere + ";" + Organization);
                string sql = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " and 库存组织='" + Organization + "'";
                    sWhere = sWhere.Replace("'", "''");
                    sql = "exec h_p_Sc_MouldProdInHouseBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'";
                    Log.LogInfo(sql);
                    ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_p_Sc_MouldProdInHouseBillList_Query");
                }
                else
                {
                    sWhere += " and 库存组织='" + Organization + "'";
                    sWhere = sWhere.Replace("'", "''");
                    sql = "exec h_p_Sc_MouldProdInHouseBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'";
                    Log.LogInfo(sql);
                    ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_p_Sc_MouldProdInHouseBillList_Query");
                }
                objJsonResult.code = "1";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [模具采购入库单删除功能]
        /// <summary>
        /// 模具采购入库单删除功能
@@ -900,6 +962,22 @@
            DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill();
            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                if (oBill.omodel.HCloseMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已关闭!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oBill.omodel.HDeleteMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已作废!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (flag == 1)
                {
                    if (oBill.omodel.HBillStatus == 2)
@@ -923,7 +1001,7 @@
                }
                else
                {
                    if (oBill.omodel.HBillStatus == 1)
                    if (oBill.omodel.HBillStatus != 2)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
@@ -955,6 +1033,150 @@
        }
        #endregion
        #region 器具采购入库单 关闭/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Sc_MouldProdInBill/CloseSc_MouldProdInBill")]
        [HttpGet]
        public object CloseSc_MouldProdInBill(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Sc_MouldProdInBill_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsSc_MouldProdInBill oBill = new DAL.ClsSc_MouldProdInBill();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不能再次关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未关闭!不需要反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }