1
duhe
5 天以前 d703d7cc2f3a86692b1db16793ff2ffc60a1a355
WebAPI/Controllers/XSGL/Xs_SeOutStockBillController.cs
@@ -37,7 +37,7 @@
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid=" + HInterID, "h_v_IF_SeOutStockBillList");
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillEdit where hmainid=" + HInterID, "h_v_IF_SeOutStockBillList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
@@ -132,6 +132,63 @@
                return objJsonResult;
            }
        }
        #region 发货通知单 查询-分页
        [Route("Xs_SeOutStockBill/list_byPage")]
        [HttpGet]
        public object list_byPag(string sWhere, string user, string Organization, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();  //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBillQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_IF_SeOutStockBillList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_IF_SeOutStockBillList");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_IF_SeOutStockBillList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_IF_SeOutStockBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                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
        /// <summary>
        ///删除功能
        /// </summary>
@@ -332,7 +389,7 @@
                string HLinkPhone = mainList[0].HLinkPhone;
                string HSeOrderBillNo_M = mainList[0].HSeOrderBillNo_M;
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_SeOutStockBillList");
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid=" + HInterID, "h_v_IF_SeOutStockBillList");
                //进行 会计期间 结账 的判断和控制
                string s = "";
@@ -393,7 +450,7 @@
                { //修改
                    DataSet dss;
                    dss = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_SeOutStockBillList");
                    dss = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid=" + HInterID, "h_v_IF_SeOutStockBillList");
                    //判断是否可编辑
                    if (dss.Tables[0].Rows[0]["审核人"].ToString() != "" && dss.Tables[0].Rows[0]["审核人"] != null)
                    {
@@ -413,7 +470,7 @@
                    }
                    string sql = $@"update Xs_SeOutStockBillMain  set " +
                                "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" +
                                "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" + ",HBillNo='" + HBillNo + "'" +
                                 ",HCusID='" + HCusID + "', HCurID='" + HCurID + "', HWHID = '" + HWHID
                                 + "',HExRate='" + HExRate + "',HEmpID='" + HEmpID + "',HSeOrderBillNo_M='" + HSeOrderBillNo_M + "',HManagerID='" + HManagerID + "',HDeptID='" + HDeptID + "',HOWNERID='" + HOWNERID
                                 + "',HAddress='" + HAddress + "',HProjectID='"+ HProjectID + "' where HInterID=" + HInterID;
@@ -511,14 +568,14 @@
            foreach (ClsXs_SeOutStockBillSub oSub in DetailColl)
            {
                i++;
                if (oSub.HQty <= 0 || oSub.HQty == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "第" + i + "行,数量不能为0或者小于0";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //if (oSub.HQty <= 0 || oSub.HQty == null)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "第" + i + "行,数量不能为0或者小于0";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (oSub.HMaterID == 0)
                {
@@ -1208,6 +1265,182 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 发货通知单 行关闭/行反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Xs_SeOutStockBill/CloseRowXs_SeOutStockBill")]
        [HttpGet]
        public object CloseRowXs_SeOutStockBill(int HInterID, int HEntryID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Xs_SeOutStockBill_Close";
            string SubBillName = "Xs_SeOutStockBillSub";                   //子表表名
            DBUtility.ClsPub.CurUserName = CurUserName;
            DataSet ds = null;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "行关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //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_SeOutStockBill oBill = new DAL.ClsXs_SeOutStockBill();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HCloseMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已关闭!不能进行行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    string sql = "select * from " + SubBillName + " where HInterID = " + HInterID + " and HEntryID = " + HEntryID;
                    ds = oCN.RunProcReturn(sql, "Xs_SeOutStockBillSub");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "该行数据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //行关闭判断
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "行已关闭!不能再次行关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //行反关闭判断
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "行未关闭!不需要再行反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //判断行是否为自动关闭
                        string temp = ds.Tables[0].Rows[0]["HCloseType"].ToString();
                        if (ds.Tables[0].Rows[0]["HCloseType"].ToString() == "False")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "行反关闭失败!行为自动关闭,不能进行手动反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的行关闭/行反关闭操作
                if (IsAudit == 0) //行关闭提交
                {
                    //行关闭提交
                    if (oBill.CloseRow(lngBillKey, HEntryID, oBill.omodel.HBillNo, CurUserName, "h_p_Xs_SeOutStockBill_AfterEntryCloseCtrl", ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        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;
                    }
                }
                if (IsAudit == 1) //行反关闭提交
                {
                    //行反关闭提交
                    if (oBill.CancelRow(lngBillKey, HEntryID, oBill.omodel.HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        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;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -1999,7 +2232,7 @@
                }
                string sql = "select * from h_v_Xs_SeOutStockBillQuerySub where hmainid =  " + hmainid;
                ds = oCN.RunProcReturn(sql + " order by hsubid desc", "h_v_Xs_SeOutStockBillQuerySub");
                ds = oCN.RunProcReturn(sql + " order by hsubid ASC", "h_v_Xs_SeOutStockBillQuerySub");
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -2026,5 +2259,44 @@
            }
        }
        #endregion
        #region 发货通知单查询即时库存
        [Route("Xs_SeOutStockBill/GetICInventory")]
        [HttpGet]
        public object GetICInventory(int HMaterID, int HWHID, int HORGID)
        {
            try
            {
                //判断是否有查询权限
                //if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBillQuery", 1, false, user))
                //{
                //    objJsonResult.code = CodeConstant.FAIL;
                //    objJsonResult.count = CountConstant.FAIL;
                //    objJsonResult.Message = "无权限查看!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                string sql = "exec h_p_Xs_SeOutStockBillGetICInventory " + HMaterID + "," + HWHID + "," + HORGID;
                ds = oCN.RunProcReturn(sql, "h_p_Xs_SeOutStockBillGetICInventory");
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0].Rows[0]["HBack"];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}