private IMMaterial ToIMMaterial(T_GM_IMWarehouse src) { foreach (var item in src.GetType().GetProperties()) { item.SetValue(this, item.GetValue(src, null)); } return(this); }
//[VisitAuthorize(Read=false,Delete=false,Create=true,Update=true)] /// <summary> /// 注意看注释 /// </summary> /// <param name="list"></param> /// <param name="record"></param> /// <param name="pri"></param> /// <param name="wid"></param> /// <param name="rm"></param> /// <returns></returns> public ActionResult MReceiptSubmit(string list, string record, string pri, T_GM_ReceiptMaterial rm, string AuditProcess) { List <string> a = cw.JsontoList(list); List <string> c = cw.JsontoList(record); List <string> b = cw.JsontoList(pri); //这里是多张收货单确定一张采购单,与1张申请单配置多张采购单相反, //所以数据库中收货表要取采购单的GID才能找到对应记录,而不是订单号 var te = DB.T_GM_TempDetailMaterial.Where(w => w.Remark == rm.PMNo); var de = DB.T_GM_PurchaseMaterial.Find(rm.PMNo); string IMNo = "IMW" + DateTime.Now.ToString("yyyyMMdd") + SerialNum.NewSerialNum(); string IMOpId = Guid.NewGuid().ToString(); int i = 0; decimal t, f, totalprice = 0; if (a.Count > 0 && a[0] != "") { //rm.ReceiptPlace = wid; rm.ConfirmMan = user.EmployeeId; rm.ConfirmTime = DateTime.Now; rm.OperationLstId = IMOpId; foreach (var item in a) { if (c[i] != "" && b[i] != "" && c[i] != "null" && b[i] != "null") { T_GM_DM dm = new T_GM_DM(); T_GM_DM IMWMat = new T_GM_DM(); decimal.TryParse(c[i], out t); decimal.TryParse(b[i], out f); var test = te.FirstOrDefault(m => m.MFlID == item); if (test != null) { test.Num -= t; if (test.Num < 0) { //X.Msg.Alert("警告","" ).Show(); return(this.Direct(false, "收货实际数量超过采购数量!!!")); } DB.T_GM_TempDetailMaterial.Attach(test); DB.Entry(test).State = EntityState.Modified; //入库物料 IMWMat.NO = IMNo; IMWMat.Type = "PURIM"; IMWMat.Price = f; IMWMat.MFlID = a[i]; IMWMat.Num = t; IMWMat.Remark = IMOpId; DB.T_GM_DM.Add(IMWMat); } //收货的物料 dm.NO = rm.ReceivePMNo; dm.Type = "SHM"; dm.Num = t; dm.Price = f; dm.MFlID = a[i]; dm.Remark = rm.ReceivePMNo; DB.T_GM_DM.Add(dm); i++; totalprice += t * f; } else { X.Msg.Alert("警告", "您输入数量或价格为空!!!").Show(); return(this.Direct()); } } rm.RMTotalPrice = totalprice; DB.T_GM_ReceiptMaterial.Add(rm); var project = DB.V_GM_DetailProject.FirstOrDefault(l => l.ProjectNo == rm.ProjectNo); if (project == null) { return(this.Direct()); } T_GM_IMWarehouse imw = new T_GM_IMWarehouse(); imw.IMDate = DateTime.Now; imw.IMTypeID = 3; imw.IMID = IMNo; imw.IMWarehouseID = project.WarehouseID; imw.ProjectID = rm.ProjectNo; imw.RefrenceNo = rm.ReceivePMNo; imw.Operator = user.EmployeeId; imw.OperationTime = DateTime.Now; imw.OperationListID = IMOpId; DB.T_GM_IMWarehouse.Add(imw); T_CH_Operation_list auditprocess = new T_CH_Operation_list(); var cf = DB.V_CH_Checkfuncflow.Where(w => w.CheckfuncName == checkname).Where(w => w.ID == AuditProcess).ToList().FirstOrDefault(); auditprocess.ID = imw.OperationListID; auditprocess.Check_funcID = cf.CheckfuncID; auditprocess.Check_flowID = cf.ID; auditprocess.CreateTime = DateTime.Now; auditprocess.State = 1; auditprocess.Url = Url.Action("CheckIMAction", "IMWarehouse", new { id = IMNo }); auditprocess.Creator = user.EmployeeId; DB.T_CH_Operation_list.Add(auditprocess); DB.SaveChanges(); if (cw.check(rm.PMNo)) { de.OrderStatu = "delivered"; DB.T_GM_PurchaseMaterial.Attach(de); DB.Entry(de).State = EntityState.Modified; DB.SaveChanges(); X.Msg.Alert("提示", "此采购单货物已完全送达", "parent.App.win.close();").Show(); return(this.Direct()); } } else { X.Msg.Alert("警告", "物料数量不能为空").Show(); } X.Msg.AddScript("parent.App.win.close();"); return(this.Direct()); }