1
duhe
4 天以前 d703d7cc2f3a86692b1db16793ff2ffc60a1a355
WebAPI/Controllers/SCGL/Sc_ICMOChangeBillController.cs
@@ -48,12 +48,12 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_ICMOChangeBillList_Query order by 单据号 ", "h_v_Sc_ICMOChangeBillList_Query");
                    ds = oCN.RunProcReturn("select * from h_v_Sc_ICMOChangeBillList_Query order by 单据号 desc", "h_v_Sc_ICMOChangeBillList_Query");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_ICMOChangeBillList_Query where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by 单据号 ";
                    string sql = sql1 + sWhere + " order by 单据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_ICMOChangeBillList_Query");
                }
@@ -350,10 +350,57 @@
                    return objJsonResult;
                }
                //删除前控制=========================================
                string sql1 = "exec h_p_Sc_ICMOChangeBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_Sc_ICMOChangeBill_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;
                }
                //==================================================================================
                oCN.BeginTran();
                oCN.RunProc("delete from Sc_ICMOChangeBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Sc_ICMOChangeBillSub where HInterID= " + HInterID);
                //删除后控制==================================================================================
                string sql2 = "exec h_p_Sc_ICMOChangeBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql2, "h_p_h_p_Sc_ICMOChangeBill_AfterDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    s = "删除后判断失败,请与网络管理人员联系";
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    s = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==============================================================================================
                oCN.Commit();
@@ -488,8 +535,10 @@
                    }
                    //检查源单是否存在
                    string sql = "select * from Sc_ICMOBillSub where HInterID = " + oBill.omodel.HMainSourceInterID + " and HEntryID =" + oBill.omodel.HMainSourceEntryID;
                    ds = oCN.RunProcReturn(sql, "Sc_ICMOBillSub");
                    string sql = "select * from Sc_ICMOBillMain as a " +
                        " inner join Sc_ICMOBillSub as b on a.HInterID = b.HInterID " +
                        " where b.HInterID = " + oBill.omodel.HMainSourceInterID + " and b.HEntryID =" + oBill.omodel.HMainSourceEntryID;
                    ds = oCN.RunProcReturn(sql, "Sc_ICMOBill");
                    if(ds==null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
@@ -498,14 +547,45 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "2")
                    {
                        //反写源单数据
                        oCN.BeginTran();
                        sql = "exec h_p_Sc_ICMOBill_ReWriteByICMOChangeBill " + oBill.omodel.HInterID;
                        oCN.RunProc(sql);
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:源单未处于审核状态!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核前控制=========================================
                    string sql1 = "exec h_p_Sc_ICMOChangeBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_ICMOChangeBill_BeforeCheckCtrl");
                    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;
                    }
                    //==================================================================================
                    oCN.BeginTran();
                    //反写源单数据
                    sql = "exec h_p_Sc_ICMOBill_ReWriteByICMOChangeBill " + oBill.omodel.HInterID;
                    oCN.RunProc(sql);
                    //审核提交
                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Sc_ICMOChangeBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        oCN.Commit();
                        objJsonResult.code = "1";
@@ -516,6 +596,8 @@
                    }
                    else
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -525,8 +607,31 @@
                }
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制=========================================
                    string sql1 = "exec h_p_Sc_ICMOChangeBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_ICMOChangeBill_BeforeUnCheckCtrl");
                    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;
                    }
                    //===========================================================
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Sc_ICMOChangeBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -547,6 +652,8 @@
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();