duhe
2023-11-16 1f04dee5f7849d8c0506c9ace925bec768539ea3
WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs
@@ -1157,6 +1157,7 @@
                    UserName = oItem.HMaker;  //制单人
                    oItem.HBillType = "1401";
                    oItem.HBillSubType = "1401";
                    oItem.HSALEORGID = oItem.HOrgID;
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
@@ -1447,6 +1448,16 @@
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                    ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
                    if(ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -1797,9 +1808,14 @@
                            ,cur.HName HCurName
                            ,cur.HExchangeRate HExRate
                            ,c.HTaxRate
                     ,c.HLinkMan
                     ,c.HLinkPhone
                     ,c.HMobilePhone
                     ,ISNULL(cre.HCreditRating_Now,0) HCreditRating_Now
                            from Gy_Customer as c 
                            left join Gy_SettleStyle as s on c.HSSID = s.HItemID
                            left join Gy_Currency as cur on c.HCurID = cur.HItemID
                     left join Gy_Customer_Credit as cre on c.HItemID = cre.HCusID
                            where c.HItemID = " + HCusID;
                ds = oCN.RunProcReturn(sql,"Gy_Customer");
@@ -1880,5 +1896,155 @@
            }
        }
        #endregion
        #region 销售订单 根据用户获取用户关联客户过滤条件
        [Route("Xs_SeOrderBill/getCusIDListByUser")]
        [HttpGet]
        public object getCusIDListByUser(string CurUserID, string CurUserName)
        {
            string sWhere = "";
            string ModRightNameCheck = "Gy_UserLookAllCus";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //权限判断:是否可以查看所有客户
                if (DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    sWhere = "";
                }
                else
                {
                    string sql = "select * from Gy_UserCustomerRelation where HUserID = '" + CurUserID + "'";
                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        sWhere = " and 1 = 0";
                    }
                    else
                    {
                        sWhere = " and HCusID in (";
                        for(var i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (i < ds.Tables[0].Rows.Count - 1)
                            {
                                sWhere += ds.Tables[0].Rows[i]["HCusID"].ToString() + ",";
                            }
                            else
                            {
                                sWhere += ds.Tables[0].Rows[i]["HCusID"].ToString() + ")";
                            }
                        }
                    }
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = sWhere;
                return objJsonResult;
            }
            catch (Exception e)
            {
                sWhere = " and 1=0 ";
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = sWhere;
                return objJsonResult;
            }
        }
        #endregion
        #region 销售订单 下推生产订单(无列表)-获取数据
        [Route("Xs_SeOrderBill/loadXs_SeOrderBill_InitICMO")]
        [HttpGet]
        public object loadXs_SeOrderBill_InitICMO(long HInterID,long HEntryID)
        {
            try
            {
                string sql = "select * from h_v_IF_SeOrderBillList where hmainid = " + HInterID + " and HSubID = " + HEntryID;
                ds = oCN.RunProcReturn(sql, "h_v_IF_SeOrderBillList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "false!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    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>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <returns></returns>
        [Route("Xs_SeOrderBill/CheckSeOrderBill_IsExist")]
        [HttpGet]
        public object CheckSeOrderBill_IsExist(int HInterID)
        {
            try
            {
                //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.ClsXs_SeOrderBill oBill = new DAL.ClsXs_SeOrderBill();                              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "程序错误!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}