| | |
| | | } |
| | | } |
| | | |
| | | |
| | | #region 采购入库单分页列表 |
| | | [Route("Kf_POStockInBill/page")] |
| | | [HttpGet] |
| | | public object Kf_POStockInBillPage(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("Kf_POStockInBillList", 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_Kf_POStockInBillList_New " + page + "," + size + ",''", "h_p_Kf_POStockInBillList_New"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Kf_POStockInBillList_New " + page + "," + size + ",'" + sWhere + "'", "h_p_Kf_POStockInBillList_New"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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 |
| | | |
| | | |
| | | #region 采购入库单 保存/编辑功能 |
| | | [Route("Kf_POStockInBill/POStockInBillEdit")] |
| | | [HttpPost] |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Kf_POStockInBillList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillList where hmainid=" + HInterID, "h_v_Kf_POStockInBillList"); |
| | | |
| | | if ((OperationType == 1 || OperationType == 2 || OperationType == 4) && ds.Tables[0].Rows.Count == 0)//新增 |
| | | { |
| | |
| | | ,HAddress,HSupID,HCurID,HWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID,HExplanation,HRemark |
| | | ,HInnerBillNo,HSTOCKORGID,HOWNERID,HMaker,HMakeDate,HProjectID,HInvoiceBillNo) |
| | | values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 1201 + "','" + |
| | | 1201 + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + HAddress + |
| | | HBillSubType + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + HAddress + |
| | | "'," + HSupID + "," + HCurID + "," + HWHID + "," + HEmpID + "," + HManagerID + "," + |
| | | HSecManagerID + ","+ HKeeperID +"," + HDeptID + ",'" + HExplanation + "','" + HRemark |
| | | + "','" + HInnerBillNo + "'," + HSTOCKORGID + "," + HOWNERID + ",'" + HMaker + "',getdate(),"+ HProjectID + ",'"+ HInvoiceBillNo + "')"; |
| | |
| | | { //修改 |
| | | |
| | | DataSet dss; |
| | | dss = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Kf_POStockInBillList"); |
| | | dss = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillList where hmainid=" + HInterID , "h_v_Kf_POStockInBillList"); |
| | | //判断是否可编辑 |
| | | if (dss.Tables[0].Rows[0]["审核人"].ToString() != "" && dss.Tables[0].Rows[0]["审核人"] != null) |
| | | { |
| | |
| | | } |
| | | |
| | | String sql = $@"update Kf_ICStockBillMain set " + |
| | | "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" + |
| | | "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" + ",HBillNo='" + HBillNo + "'" + |
| | | ",HSupID=" + HSupID + ",HCurID=" + HCurID + ",HSecManagerID=" + HSecManagerID + ", HSTOCKORGID=" + HSTOCKORGID + ",HKeeperID=" + HKeeperID + ",HWHID = " + HWHID |
| | | + ",HEmpID=" + HEmpID + ",HManagerID=" + HManagerID + ",HDeptID=" + HDeptID + ",HOWNERID=" + HOWNERID |
| | | + ",HAddress='" + HAddress + "',HInnerBillNo='" + HInnerBillNo + "',HProjectID="+ HProjectID + ",HInvoiceBillNo='"+ HInvoiceBillNo + "' where HInterID=" + HInterID; |
| | |
| | | { |
| | | ClsKf_ICStockBillSub oSub = (ClsKf_ICStockBillSub)list[i1]; |
| | | 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) |
| | | { |
| | |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillList where hmainid =" + HInterID, "h_v_Kf_POStockInBillList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillEdit where hmainid =" + HInterID, "h_v_Kf_POStockInBillList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已关闭!不能再次审核!"; |
| | | objJsonResult.Message = "单据已关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已作废!不能再次审核!"; |
| | | objJsonResult.Message = "单据已作废!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillList where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_Kf_POStockInBillList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "未查询到源单信息!"; |
| | | 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 采购入库单 根据主内码与子内码获取采购入库单数据 |
| | | [Route("Kf_POStockInBill/loadKf_POStockInBillEdit_Push")] |
| | | [HttpGet] |
| | | public object loadKf_POStockInBillEdit_Push(long HInterID, long HSubID) |
| | | { |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillEdit where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_Kf_POStockInBillEdit"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | } |
| | | string sql = "select * from h_v_Kf_POStockInBillQuerySub where hmainid = " + hmainid; |
| | | |
| | | ds = oCN.RunProcReturn(sql + " order by hsubid desc", "h_v_Kf_POStockInBillQuerySub"); |
| | | ds = oCN.RunProcReturn(sql + " order by hsubid ASC", "h_v_Kf_POStockInBillQuerySub"); |
| | | |
| | | |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 采购入库单 审核同步 调用API |
| | | [Route("Kf_POStockInBill/Kf_POStockInBillSaveApi")] |
| | | [HttpPost] |
| | | public object Kf_POStockInBillSaveApi([FromBody] JObject sMainSub) |
| | | { |
| | | try |
| | | { |
| | | oCN.BeginTran(); |
| | | LogService.Write("采购入库单同步,保存方法执行:" + sMainSub.ToString()); |
| | | |
| | | var model = sMainSub["model"].ToString(); |
| | | var entry = sMainSub["model"]["HENTRY"].ToString(); |
| | | |
| | | model = "[" + model.ToString() + "]"; |
| | | List<ClsKf_ICStockBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ICStockBillMain>>(model); |
| | | List<ClsKf_ICStockBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ICStockBillSub>>(entry); |
| | | |
| | | // 判断 数据库中是否存在id和单据号相等的单据,存在,则重建,只有id号相等,则申请新的id号 |
| | | var ds1 = oCN.RunProcReturn($@" |
| | | select hmainid HInterID, 单据号 HBillNO from h_v_Kf_POStockInBillList where hmainid = {mainList[0].HInterID} |
| | | ", "h_v_Kf_POStockInBillList"); |
| | | |
| | | if (ds1.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows[0]["HInterID"] != null) |
| | | { |
| | | if (string.Equals(ds1.Tables[0].Rows[0]["HBillNo"].ToString(), mainList[0].HBillNo, StringComparison.OrdinalIgnoreCase)) |
| | | { |
| | | string sql = string.Empty; |
| | | sql = $"delete Kf_ICStockBillMain where HinterID = {mainList[0].HInterID}"; |
| | | oCN.RunProc(sql); |
| | | sql = $"delete Kf_ICStockBillSub where HinterID = {mainList[0].HInterID}"; |
| | | oCN.RunProc(sql); |
| | | } |
| | | else |
| | | { |
| | | // 重新申请HInterID |
| | | var HInterID_Exch = DBUtility.ClsPub.CreateBillID("1201", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | mainList[0].HInterID = HInterID_Exch; |
| | | |
| | | foreach (var oSub in subList) |
| | | { |
| | | oSub.HInterID = HInterID_Exch; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | // 主表 |
| | | // 主表插入 |
| | | oCN.RunProc($@"Insert Into Kf_ICStockBillMain |
| | | (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus |
| | | ,HAddress,HSupID,HCurID,HWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID,HExplanation,HRemark |
| | | ,HInnerBillNo,HSTOCKORGID,HOWNERID,HMaker,HMakeDate,HProjectID,HInvoiceBillNo |
| | | ,HChecker, HCheckDate) |
| | | values( |
| | | '{mainList[0].HInterID}', |
| | | '{mainList[0].HYear}', |
| | | '{mainList[0].HPeriod}', |
| | | '{mainList[0].HBillType}', |
| | | '{mainList[0].HBillSubType}', |
| | | '{mainList[0].HDate}', |
| | | '{mainList[0].HBillNo}', |
| | | {mainList[0].HBillStatus}, |
| | | '{mainList[0].HAddress}', |
| | | '{mainList[0].HSupID}', |
| | | '{mainList[0].HCurID}', |
| | | '{mainList[0].HWHID}', |
| | | '{mainList[0].HEmpID}', |
| | | '{mainList[0].HManagerID}', |
| | | '{mainList[0].HSecManagerID}', |
| | | '{mainList[0].HKeeperID}', |
| | | '{mainList[0].HDeptID}', |
| | | '{mainList[0].HExplanation}', |
| | | '{mainList[0].HRemark}', |
| | | '{mainList[0].HInnerBillNo}', |
| | | {mainList[0].HSTOCKORGID}, |
| | | '{mainList[0].HOWNERID}', |
| | | '{mainList[0].HMaker}', |
| | | '{mainList[0].HMakeDate}', |
| | | '{mainList[0].HProjectID}', |
| | | '{mainList[0].HInvoiceBillNo}', |
| | | '{mainList[0].HChecker}', |
| | | '{mainList[0].HCheckDate}' |
| | | ) |
| | | "); |
| | | |
| | | // 子表插入 |
| | | foreach (var osub in subList) |
| | | { |
| | | |
| | | oCN.RunProc($@"Insert into Kf_ICStockBillSub |
| | | (HInterID,HEntryID,HMaterID,HUnitID,HQtyMust,HQty,HPrice |
| | | ,HMoney,HOrderPrice,HWHID,HSPID,HRelationQty,HBatchNo |
| | | ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType |
| | | ,HPOOrderInterID,HPOOrderEntryID ,HPOOrderBillNo |
| | | ,HPropertyID,HSecUnitID,HSecUnitRate,HPlanMode,HRemark,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo |
| | | ,HTaxRate,HTaxPrice,HlineTotal) |
| | | values ( |
| | | '{osub.HInterID}', |
| | | '{osub.HEntryID}', |
| | | '{osub.HMaterID}', |
| | | '{osub.HUnitID}', |
| | | '{osub.HQtyMust}', |
| | | '{osub.HQty}', |
| | | '{osub.HPrice}', |
| | | '{osub.HMoney}', |
| | | '{osub.HOrderPrice}', |
| | | '{osub.HWHID}', |
| | | '{osub.HSPID}', |
| | | '{osub.HRelationQty}', |
| | | '{osub.HBatchNo}', |
| | | '{osub.HSourceInterID}', |
| | | '{osub.HSourceEntryID}', |
| | | '{osub.HSourceBillNo}', |
| | | '{osub.HSourceBillType}', |
| | | '{osub.HPOOrderInterID}', |
| | | '{osub.HPOOrderEntryID}', |
| | | '{osub.HPOOrderBillNo}', |
| | | '{osub.HPropertyID}', |
| | | '{osub.HSecUnitID}', |
| | | '{osub.HSecUnitRate}', |
| | | '{osub.HPlanMode}', |
| | | '{osub.HRemark}', |
| | | '{osub.HSeOrderInterID}', |
| | | '{osub.HSeOrderEntryID}', |
| | | '{osub.HSeOrderBillNo}', |
| | | '{osub.HTaxRate}', |
| | | '{osub.HTaxPrice}', |
| | | '{osub.HlineTotal}' |
| | | ) |
| | | "); |
| | | } |
| | | |
| | | //采购入库单新增回填采购入库关联数量 |
| | | oCN.RunProc("exec h_p_Cg_UpDateRelation_POOrderToPOStockIn_Add " + mainList[0].HInterID); |
| | | |
| | | //采购入库单新增回填收料通知单关联数量 |
| | | oCN.RunProc("exec h_p_Cg_UpDateRelation_POInStockToPOStockIn_Add " + mainList[0].HInterID); |
| | | |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据保存成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write("采购入库单同步异常,保存方法执行完成异常:" + e.Message.ToString()); |
| | | |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |