zrg
2025-04-15 38bd77018665edaae981bf1c9d80b66711802f93
WebAPI/Controllers/CJGL/Gy_MaterPreventErrMouldBillController.cs
@@ -20,6 +20,7 @@
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public DataSet ds1 = new DataSet();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsGy_MaterPreventErrMouldBillMain OBill = new DAL.ClsGy_MaterPreventErrMouldBillMain();
        public DAL.ClsGy_MaterPreventErrMouldBillMain BillOld = new DAL.ClsGy_MaterPreventErrMouldBillMain();
@@ -373,9 +374,53 @@
                oCN.BeginTran();
                oCN.RunProc("delete from Gy_MaterPreventErrMouldBillMain where HInterID = " + HInterID);
                //判断存在性
                if (BillOld.ShowBill(Int64.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    //删除前控制=========================================
                    string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeDelCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //==================================================================================
                    //删除单据(包含删除后控制、写入日志)
                    if (!BillOld.DeleteBill(BillOld.omodel.HInterID, BillOld.omodel.HBillNo, "h_p_Gy_MaterPreventErrMouldBill_AfterDelCtrl", user, ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除成功!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -428,7 +473,6 @@
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
@@ -465,8 +509,32 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //审核前控制=========================================
                        string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeCheckCtrl");
                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                            objJsonResult.data = null;
                            oCN.RollBack();
                            return objJsonResult;
                        }
                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "审核失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                            objJsonResult.data = null;
                            oCN.RollBack();
                            return objJsonResult;
                        }
                        //==================================================================================
                        //审核单据
                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
@@ -479,7 +547,6 @@
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -508,8 +575,29 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //反审核前控制=========================================
                        string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeUnCheckCtrl");
                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "反审核失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //===========================================================
                        //反审核单据
                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
@@ -721,7 +809,6 @@
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
@@ -750,8 +837,31 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //作废前控制=========================================
                        string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeDropCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeDropCtrl");
                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                            objJsonResult.data = null;
                            oCN.RollBack();
                            return objJsonResult;
                        }
                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "审核失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                            objJsonResult.data = null;
                            oCN.RollBack();
                            return objJsonResult;
                        }
                        //==================================================================================
                        //作废单据
                        if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        if (!BillOld.Cancelltion(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
@@ -764,7 +874,6 @@
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -785,8 +894,31 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //反作废前控制=========================================
                        string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeUnDropCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeUnDropCtrl");
                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "作废失败!原因:反作废前判断失败,请与网络管理人员联系";
                            objJsonResult.data = null;
                            oCN.RollBack();
                            return objJsonResult;
                        }
                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "作废失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                            objJsonResult.data = null;
                            oCN.RollBack();
                            return objJsonResult;
                        }
                        //==================================================================================
                        //反作废单据
                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;