| | |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using SyntacticSugar.constant; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID, "h_v_IF_POInStockBillList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_IF_POInStockBillEdit where hmainid=" + HInterID, "h_v_IF_POInStockBillList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 收料通知单分页列表 |
| | | [Route("Cg_POInStockBill/page")] |
| | | [HttpGet] |
| | | public object Cg_POInStockBillPage(string sWhere, string user, int page, int size) |
| | | { |
| | | DataSet ds; |
| | | json res = new json(); |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "您没有该模块权限,请与管理员联系!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_IF_POInStockBillList " + page + "," + size + ",''", "h_p_IF_POInStockBillList"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_IF_POInStockBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_IF_POInStockBillList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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列对象的列名 |
| | | } |
| | | |
| | | res.code = CodeConstant.SUCCEED; |
| | | res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); |
| | | res.Message = "Sucess!"; |
| | | res.list = columnNameList; |
| | | res.data = ds.Tables[0]; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 返回收料通知单列表 |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_POOrderBillList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID, "h_v_IF_POOrderBillList"); |
| | | if ((OperationType == 1 || OperationType == 2 || OperationType == 4) && ds.Tables[0].Rows.Count == 0)//新增 |
| | | { |
| | | |
| | |
| | | else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) |
| | | { //修改 |
| | | DataSet dss; |
| | | dss = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_POOrderBillList"); |
| | | dss = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID , "h_v_IF_POOrderBillList"); |
| | | //判断是否可编辑 |
| | | if (dss.Tables[0].Rows[0]["审核人"].ToString() != "" && dss.Tables[0].Rows[0]["审核人"] != null) |
| | | { |
| | |
| | | } |
| | | |
| | | string sql= $@"update Cg_POInStockBillMain set " + |
| | | "HRemark='" + HRemark + "', HUpDater ='" + HMaker + "', HUpDateDate=getdate()" + |
| | | ",HSupID=" + HSupID + ",HCurID=" + HCurID |
| | | + ",HExRate=" + HExRate + ",HEmpID=" + HEmpID + ",HManagerID=" + HManagerID + ",HDeptID=" + HDeptID |
| | | + ",HAddress='" + HAddress + "',HInnerBillNo='" + HInnerBillNo + "',HProjectID="+ HProjectID + ",HInvoiceBillNo='"+ HInvoiceBillNo + "' where HInterID=" + HInterID; |
| | | "HRemark='" + HRemark + "'" + |
| | | ", HUpDater ='" + HMaker + "'" + |
| | | ", HUpDateDate=getdate()"+ "" + |
| | | ",HBillNo='" + HBillNo + "'" + |
| | | ",HWHID=" + HWHID + "" + |
| | | ",HSupID=" + HSupID + "" + |
| | | ",HCurID=" + HCurID + "" + |
| | | ",HExRate=" + HExRate + "" + |
| | | ",HEmpID=" + HEmpID + "" + |
| | | ",HManagerID=" + HManagerID + "" + |
| | | ",HDeptID=" + HDeptID + "" + |
| | | ",HAddress='" + HAddress + "'" + |
| | | ",HInnerBillNo='" + HInnerBillNo + "'" + |
| | | ",HProjectID="+ HProjectID + "" + |
| | | ",HInvoiceBillNo='"+ HInvoiceBillNo + "' " + |
| | | " where HInterID=" + HInterID; |
| | | |
| | | oCN.RunProc(sql); |
| | | |
| | |
| | | |
| | | //收料通知单新增回填采购订单关联数量 |
| | | oCN.RunProc("exec h_p_Cg_UpDatePOOrderRelation_Add " + HInterID); |
| | | //自动审核设置 |
| | | if ((OperationType == 1 || OperationType == 2 || OperationType == 4)) |
| | | { |
| | | objJsonResult.HInterID = HInterID.ToString(); //返回主ID |
| | | //系统参数 自动审核 |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.Cg_POInStockBill_AutoCheck == "Y") //系统参数 自动审核 |
| | | { |
| | | objJsonResult.Verify = "Y"; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | } |
| | | } |
| | | else if (OperationType == 3 ) |
| | | { |
| | | objJsonResult.HInterID = HInterID.ToString(); //返回主ID |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | |
| | | if (objJsonResult.code == "0") |
| | | { |
| | |
| | | foreach (ClsCg_POInStockBillSub 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) |
| | | { |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 收料通知单下推查询列表 |
| | | [Route("Cg_POInStockBill/PushList")] |
| | | [HttpGet] |
| | | public object PushList(string HBillNo, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无权限查看!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | string sql = "select * from h_v_IF_POInStockBillList where 单据号 = '" + HBillNo + "' and 状态 = '已审核' and 数量 - 关联数量 > 0"; |
| | | |
| | | |
| | | ds = oCN.RunProcReturn(sql, "h_v_IF_POInStockBillList"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "找不到符合条件单据!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 收料通知单查询列表 |
| | | [Route("Cg_POInStockBill/QueryList")] |
| | | [HttpGet] |
| | | public object QueryList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无权限查看!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | string sql = "select * from h_v_Cg_POInStockBillQuery where 1 = 1 "; |
| | | |
| | | if (sWhere == "" || sWhere == null) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Cg_POInStockBillQuery order by hmainid desc", "h_v_Cg_POInStockBillQuery"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn(sql + sWhere + " order by hmainid desc", "h_v_Cg_POInStockBillQuery"); |
| | | } |
| | | |
| | | |
| | | |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 收料通知单查询子列表 |
| | | [Route("Cg_POInStockBill/QuerySubList")] |
| | | [HttpGet] |
| | | public object QuerySubList(string hmainid, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无权限查看!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | string sql = "select * from h_v_Cg_POInStockBillQuerySub where hmainid = " + hmainid; |
| | | |
| | | ds = oCN.RunProcReturn(sql + " order by hsubid ASC", "h_v_Cg_POInStockBillQuerySub"); |
| | | |
| | | |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |