| | |
| | | using WebAPI.Models; |
| | | using System.Windows.Forms; |
| | | using SyntacticSugar.constant; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 器具出库申请单 - 托数变更功能 |
| | | [Route("Sc_MouldOutRequestBillController/UpdatePallet")] |
| | | [HttpPost] |
| | | public object UpdatePallet([FromBody] JObject data) |
| | | { |
| | | try |
| | | { |
| | | long hmainid = data["hmainid"]?.ToObject<long>() ?? 0; |
| | | int newPallet = data["newPallet"]?.ToObject<int>() ?? 0; |
| | | string operatorName = data["operator"]?.ToString() ?? ""; |
| | | |
| | | if (hmainid <= 0) |
| | | return new { code = "0", count = 0, Message = "单据ID不能为空!" }; |
| | | |
| | | if (newPallet <= 0) |
| | | return new { code = "0", count = 0, Message = "托数必须大于0!" }; |
| | | |
| | | // 检查是否已审核 |
| | | string checkAuditSql = $@" |
| | | SELECT COUNT(*) as HasAudit |
| | | FROM Sc_MouldOutRequestBillMain |
| | | WHERE HInterID = {hmainid} |
| | | AND HChecker IS NOT NULL |
| | | AND HCheckDate IS NOT NULL"; |
| | | |
| | | DataSet dsAudit = oCn.RunProcReturn(checkAuditSql, "CheckAudit"); |
| | | |
| | | if (dsAudit != null && dsAudit.Tables[0].Rows.Count > 0) |
| | | { |
| | | int hasAudit = Convert.ToInt32(dsAudit.Tables[0].Rows[0]["HasAudit"]); |
| | | if (hasAudit > 0) |
| | | { |
| | | return new { code = "0", count = 0, Message = "单据已审核,不能修改托数!" }; |
| | | } |
| | | } |
| | | // 直接更新托数 |
| | | string updateSql = $@" |
| | | UPDATE Sc_MouldOutRequestBillMain |
| | | SET HPackQtys = {newPallet} |
| | | WHERE HInterID = {hmainid}"; |
| | | |
| | | oCn.RunProc(updateSql); |
| | | |
| | | return new |
| | | { |
| | | code = "1", |
| | | count = 1, |
| | | Message = "托数修改成功!" |
| | | }; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return new |
| | | { |
| | | code = "0", |
| | | count = 0, |
| | | Message = "修改失败:" + e.Message |
| | | }; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 器具出库申请单 作废/反作废 |
| | | /// <summary> |
| | | /// 作废/反作废 器具出库申请单 |
| | |
| | | |
| | | |
| | | |
| | | #region 器具出库申请单 保存1 |
| | | /// <summary> |
| | | /// 器具出库申请单保存 |
| | | /// </summary> |
| | | [Route("Sc_MouldOutRequestBillController/GetSc_MouldOutRequestBill_Save_Json1")] |
| | | [HttpPost] |
| | | public object GetSc_MouldOutRequestBill_Save_Json1([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string sMainStr = sArray[0].ToString(); //主表数据 |
| | | string sSubStr = sArray[1].ToString(); //子表数据 |
| | | string sErrMsg = ""; |
| | | string HBillNo = ""; |
| | | HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("3849", ref sErrMsg, true); |
| | | |
| | | try |
| | | { |
| | | //表头赋值 |
| | | sMainStr = sMainStr.Replace("\\", ""); |
| | | sMainStr = sMainStr.Replace("\n", ""); |
| | | sMainStr = "[" + sMainStr.ToString() + "]"; |
| | | List<Model.ClsSc_MouldOutRequestBillMain> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldOutRequestBillMain>>(sMainStr); |
| | | foreach (Model.ClsSc_MouldOutRequestBillMain oItem in lsmain) |
| | | { |
| | | //单据号是否重复 |
| | | if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, HBillNo, BillStatus, oItem.HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据号重复!不允许保存!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //判断会计期是否合理 |
| | | string s = ""; |
| | | int sYear = 0; |
| | | int sPeriod = 0; |
| | | oItem.HDate = DateTime.Now; |
| | | if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oItem.HDate, ref sYear, ref sPeriod, ref s) == false) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = s; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oItem.HYear = sYear; |
| | | oItem.HPeriod = sPeriod; |
| | | oItem.HMaker = "钉钉"; |
| | | oItem.HRemark = "钉钉数据同步创建"; |
| | | oItem.HBillNo = HBillNo; |
| | | oItem.HSTOCKORGID = 100038; |
| | | oItem.HSupTypeID = 1; |
| | | oBill.omodel = oItem; |
| | | DBUtility.ClsPub.CurUserName = oItem.HMaker; |
| | | |
| | | } |
| | | //表体赋值 |
| | | //按 },{来拆分数组 //去掉【和】 |
| | | sSubStr = sSubStr.Substring(1, sSubStr.Length-2); |
| | | sSubStr = sSubStr.Replace("\\", ""); |
| | | sSubStr = sSubStr.Replace("\n", ""); |
| | | sSubStr = "[" + sSubStr.ToString() + "]"; |
| | | List<Model.ClsSc_MouldOutRequestBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldOutRequestBillSub>>(sSubStr); |
| | | int i = 0; |
| | | foreach (Model.ClsSc_MouldOutRequestBillSub oItemSub in ls) |
| | | { |
| | | i++; |
| | | oItemSub.HEntryID = i; |
| | | DataTable dtMould = GetMaterialByMouldNo(oItemSub.HMaterID); |
| | | DataRow row = dtMould.Rows[0]; |
| | | // 使用三元运算符处理DBNull |
| | | oItemSub.HUnitID = row["HUnitID"] != DBNull.Value ? Convert.ToInt32(row["HUnitID"]) : 0; |
| | | oItemSub.HWHID = row["HWhID"] != DBNull.Value ? Convert.ToInt32(row["HWhID"]) : 0; |
| | | oItemSub.HSPID = row["HSPID"] != DBNull.Value ? Convert.ToInt32(row["HSPID"]) : 0; |
| | | oItemSub.HMaterID = row["hmainid"] != DBNull.Value ? Convert.ToInt32(row["hmainid"]) : 0; |
| | | oItemSub.HStockOrgID = 100038; |
| | | oItemSub.HQty = 1; |
| | | oBill.DetailColl.Add(oItemSub); |
| | | } |
| | | |
| | | //保存 |
| | | bool bResult; |
| | | |
| | | bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | if (bResult) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //成功! |
| | | objJsonResult.data = null; |
| | | objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID |
| | | 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.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | #region 根据内码获取获取器具信息 |
| | | |
| | | public DataTable GetMaterialByMouldNo(long HMaterID) |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | string sql = @"SELECT |
| | | HMaterID, |
| | | HUnitID, |
| | | HWhID, |
| | | HSPID, |
| | | hmainid |
| | | FROM h_v_Gy_MouldFileList as a |
| | | WHERE a.HMaterID= '" + HMaterID + "' AND a.HBillType = '3899'"; |
| | | |
| | | var dataSet = oCN.RunProcReturn(sql, "h_v_Gy_MouldFileList"); |
| | | |
| | | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) |
| | | return null; |
| | | |
| | | return dataSet.Tables[0]; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | } |
| | | } |