yusijie
2024-03-12 17400e7f9e0ab6ce4027ba8941baf48f01fdadbf
WebAPI/Controllers/XSGL/YS_ReceiveOtherBillController.cs
@@ -308,7 +308,7 @@
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //判断是否可编辑
                //判断是否可删除
                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
                {
                    objJsonResult.code = "0";
@@ -317,68 +317,81 @@
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //删除前控制=========================================
                string sql1 = "exec h_p_YS_ReceiveOtherBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_YS_ReceiveOtherBill_BeforeDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                //判断是否是创建状态进行删除
                if (BillOld.omodel.HBillStatus.ToString() == "1")
                {
                    objJsonResult.code = "0";
                    //删除前控制=========================================
                    string sql1 = "exec h_p_YS_ReceiveOtherBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_YS_ReceiveOtherBill_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 YS_ReceiveOtherBillMain where HInterID = " + HInterID);
                    oCN.RunProc("delete from YS_ReceiveOtherBillSub where HInterID= " + HInterID);
                    //删除后控制==================================================================================
                    string sql2 = "exec h_p_YS_ReceiveOtherBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_YS_ReceiveOtherBill_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();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                    objJsonResult.Message = "删除成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                    objJsonResult.data = null;
                    objJsonResult.count = 0;
                    objJsonResult.Message = "此单据不是创建状态,不允许删除!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //==================================================================================
                oCN.BeginTran();
                oCN.RunProc("delete from YS_ReceiveOtherBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from YS_ReceiveOtherBillSub where HInterID= " + HInterID);
                //删除后控制==================================================================================
                string sql2 = "exec h_p_YS_ReceiveOtherBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql2, "h_p_YS_ReceiveOtherBill_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();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {