duhe
2023-11-15 015997e4efd5e5189498c9af00b7805919a676b2
WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
@@ -48,12 +48,12 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Xs_ExceptiveCheckRequestBillList_Query order by 单据号 ", "h_v_Xs_ExceptiveCheckRequestBillList_Query");
                    ds = oCN.RunProcReturn("select * from h_v_Xs_ExceptiveCheckRequestBillList_Query order by 单据号 desc", "h_v_Xs_ExceptiveCheckRequestBillList_Query");
                }
                else
                {
                    string sql1 = "select * from h_v_Xs_ExceptiveCheckRequestBillList_Query where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by 单据号 ";
                    string sql = sql1 + sWhere + " order by 单据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Xs_ExceptiveCheckRequestBillList_Query");
                }
@@ -468,9 +468,72 @@
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    //检验源单是否存在
                    string sql = "";
                    if(oBill.omodel.HMainSourceBillType == "1401")
                    {
                        sql = "select * from Xs_SeOrderBillMain as a " +
                        "inner join Xs_SeOrderBillSub as b on a.HInterID = b.HInterID " +
                        "where a.HInterID = " + oBill.omodel.HMainSourceInterID;
                        ds = oCN.RunProcReturn(sql, "Xs_SeOrderBill");
                        if (ds == null || ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "审核失败!原因:源单-销售订单不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "1")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "审核失败!原因:源单-销售订单未处于创建状态!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else if(oBill.omodel.HMainSourceBillType == "1205")
                    {
                        sql = "select * from Kf_ICStockBillMain as a " +
                        "inner join Kf_ICStockBillSub as b on a.HInterID = b.HInterID " +
                        "where a.HInterID = " + oBill.omodel.HMainSourceInterID;
                        ds = oCN.RunProcReturn(sql, "Kf_ICStockBill");
                        if (ds == null || ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "审核失败!原因:源单-销售出库单不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "1")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "审核失败!原因:源单-销售出库单未处于创建状态!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:源单不明确!!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oCN.BeginTran();
                    //反写源单单据状态
                    sql = "exec h_p_Xs_ExceptiveCheckRequestBill_ReWriteSourceStatus " + oBill.omodel.HMainSourceInterID + ",'" + oBill.omodel.HMainSourceBillType + "','" + CurUserName + "'";
                    oCN.RunProc(sql);
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        oCN.Commit();
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核成功";
@@ -479,6 +542,8 @@
                    }
                    else
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -510,6 +575,8 @@
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();