public static Msg QueryInBunch(int iInBunch) { Msg msg = null; Tbl_CenterStorageBatch oBunch = new Tbl_CenterStorageBatch(); try { using (var en = new LingYunEntities()) { oBunch = en.Tbl_CenterStorageBatch.Where(a => a.BuildBatchID == iInBunch).FirstOrDefault(); if (oBunch != null) { msg = new Msg(true) { UserData = oBunch }; } else { msg = new Msg(false) { Message = "您当前没有待确认的入库批次" }; } } } catch (Exception ex) { msg = new Msg(false) { Message = ex.Message }; } return(msg); }
/// <summary> /// 更新出库批次表批次表 /// </summary> /// <param name="matriesId"></param> /// <param name="count"></param> /// <param name="oStorage">仓储表</param> /// <returns></returns> public static Msg UpdateOutBunch(Tbl_OutProductBatch oStorage, Tbl_CenterStorageBatch oCenterBunch) { Msg msg = null; if (oStorage != null) { try { using (var en = new LingYunEntities()) { var obj = en.Tbl_OutProductBatch.Where(a => a.BuildBatchID == oStorage.BuildBatchID).FirstOrDefault(); obj.Count = oStorage.Count; obj.PreAdmStatus = 128; obj.PreAdmTime = DateTime.Now; var oProductStorage = en.Tbl_ProductStorage.Where(b => b.BuildBatchID == oStorage.BuildBatchID).FirstOrDefault(); oProductStorage.NowAdmStatus = 128; oProductStorage.NowAdmTime = DateTime.Now; en.Tbl_CenterStorageBatch.AddObject(oCenterBunch);//插入入库记录 en.SaveChanges(); msg = Msg.Default; } } catch (Exception ex) { msg = new Msg() { Status = false, Message = ex.Message }; } } return(msg); }
public static Msg EnsureInBunch(Tbl_CenterStorageBatch oBunch, Tbl_CenterStorage oStorage) { Msg msg = null; if (oBunch != null) { try { using (var en = new LingYunEntities()) { var obj = en.Tbl_OutProductBatch.Where(a => a.BuildBatchID == oBunch.BuildBatchID).FirstOrDefault(); obj.NowAdmStatus = 128; en.Tbl_CenterStorageBatch.AddObject(oBunch); en.SaveChanges(); } } catch (Exception ex) { msg = new Msg() { Status = false, Message = ex.Message }; } } return(msg); }
protected void ensure_Click(object sender, EventArgs e) { Tbl_OutProductBatch oBunch = new Tbl_OutProductBatch(); oBunch.PlanID = int.Parse(txbPlanId.Value); oBunch.Time = DateTime.Now; oBunch.MateriesID = int.Parse(txbMateriesID.Value); oBunch.BuildID = txbBuildID.Value; oBunch.BuildName = txbBuildName.Value.ToString(); oBunch.MateriesType = txbMetriesType.Value.ToString(); oBunch.PreAdmTime = DateTime.Now; oBunch.PreAdmStatus = 128; oBunch.Count = int.Parse(txbCount.Value); oBunch.BuildBatchID = int.Parse(txbBuildBunchID.Value); //出库批次表 Tbl_CenterStorageBatch oCenterBunch = new Tbl_CenterStorageBatch(); oCenterBunch.PlanID = int.Parse(txbPlanId.Value); oBunch.MateriesTasbleID = 0; oCenterBunch.BuildID = txbBuildID.Value; oCenterBunch.BuildBatchID = int.Parse(txbBuildBunchID.Value); oCenterBunch.Time = DateTime.Now; oBunch.ProjectName = txbProjectName.Value; oCenterBunch.BuildName = txbBuildName.Value; oCenterBunch.ProjectName = txbProjectName.Value; oCenterBunch.MateriesID = int.Parse(txbMateriesID.Value); oCenterBunch.MateriesType = txbMetriesType.Value.ToString(); oCenterBunch.WorkMapID = txbProductNum.Value; oCenterBunch.Count = int.Parse(txbCount.Value); oCenterBunch.NowAdmStatus = 1; oCenterBunch.PreAdmStatus = 128; oCenterBunch.PreAdmTime = DateTime.Now; oCenterBunch.NowAdmTime = DateTime.Now; //string conStr = ConfigurationManager.AppSettings["ConStr"]; //SqlConnection con = new SqlConnection(conStr); //con.Open(); //SqlCommand com1 = new SqlCommand("insert into Tbl_CenterStorageBatch(PlanID,MateriesTasbleID,BuildID,BuildBatchID,Time,ProjectName,BuildName,MateriesID,MateriesType,WorkMapID,Count,PreAdmStatus,PreAdmTime,NowAdmStatus,NowAdmTime) values('" + oCenterBunch.PlanID + "','" + oCenterBunch.MateriesTasbleID + "','" + oCenterBunch.BuildID + "','" + oCenterBunch.BuildBatchID + "','" + oCenterBunch.Time + "','" + oCenterBunch.ProjectName + "','" + oCenterBunch.BuildName + "','" + oCenterBunch.MateriesID + "','" + oCenterBunch.MateriesType + "','" + oCenterBunch.WorkMapID + "','" + oCenterBunch.Count + "','" + oCenterBunch.PreAdmStatus + "','"+DateTime.Now+"','1','" + DateTime.Now + "')", con); //com1.ExecuteScalar(); //con.Close(); ////using (var en = new LingYunEntities()) ////{ //// en.Tbl_CenterStorageBatch.AddObject(oCenterBunch); //// en.SaveChanges(); ////} Msg msg = ProductModel.UpdateOutBunch(oBunch, oCenterBunch); if (msg.Status) { PageHelper.ShowAlertMsg(this, "编辑并确认成功"); } else { PageHelper.ShowAlertMsg(this, msg.Message); } }
public static Msg AndroidOutEnsure(int iBatchId) { Msg msg = null; try{ using (var en = new LingYunEntities()) { var obj = en.Tbl_ProductStorage.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); obj.NowAdmStatus = 128; obj.NowAdmTime = DateTime.Now; var oOut = en.Tbl_OutProductBatch.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); oOut.PreAdmStatus = 128; oOut.PreAdmTime = DateTime.Now; //出库批次表 Tbl_CenterStorageBatch oCenterBunch = new Tbl_CenterStorageBatch(); oCenterBunch.PlanID = oOut.PlanID; oCenterBunch.MateriesTasbleID = oOut.MateriesTasbleID; oCenterBunch.BuildID = oOut.BuildID; oCenterBunch.BuildBatchID = oOut.BuildBatchID; oCenterBunch.Time = DateTime.Now; oCenterBunch.ProjectName = oOut.ProjectName; oCenterBunch.BuildName = oOut.BuildName; oCenterBunch.ProjectName = oOut.ProjectName; oCenterBunch.MateriesID = oOut.MateriesID; oCenterBunch.MateriesType = oOut.MateriesType; oCenterBunch.WorkMapID = oOut.WorkMapID; oCenterBunch.Count = oOut.Count ; oCenterBunch.NowAdmStatus = 1; oCenterBunch.PreAdmStatus = 128; oCenterBunch.PreAdmTime = DateTime.Now; oCenterBunch.NowAdmTime = DateTime.Now; en.AddToTbl_CenterStorageBatch(oCenterBunch); en.SaveChanges(); msg = Msg.Default; } }catch (Exception ex) { msg = new Msg(false); } return(msg); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string MetriesId = this.Request["BuildBunchId"]; Msg MetriesMsg = Center.QueryInBunch(int.Parse(MetriesId)); Tbl_CenterStorageBatch oMatries = MetriesMsg.UserData as Tbl_CenterStorageBatch; if (oMatries != null) { txbPlanId.Value = oMatries.PlanID.ToString(); txbMateriesID.Value = oMatries.MateriesID.ToString(); txbBuildID.Value = oMatries.BuildID.ToString(); txbBuildName.Value = oMatries.BuildName; txbCount.Value = oMatries.Count.ToString(); txbMetriesType.Value = oMatries.MateriesType; txbProductNum.Value = oMatries.WorkMapID; txbProjectName.Value = oMatries.ProjectName; txbBuildBunchId.Value = oMatries.BuildBatchID.ToString(); } } }
public static TrackMsg TrackByBatchId(int iBatchId) { TrackMsg track = null; string list = string.Empty; // List<string> list = new List<string>(); try { track = new TrackMsg(); int res = 0; using (var en = new LingYunEntities()) { Tbl_ProductBatch oProIn = en.Tbl_ProductBatch.Where(a => a.BuildBatchID == iBatchId && a.NowAdmStatus == 128).FirstOrDefault(); if (oProIn != null) { list += oProIn.NowAdmTime.Value.ToString(); Tbl_OutProductBatch oProOut = en.Tbl_OutProductBatch.Where(a => a.BuildBatchID == iBatchId && a.PreAdmStatus == 128).FirstOrDefault(); if (oProOut != null) { list += ";" + oProOut.PreAdmTime.Value.ToString(); Tbl_CenterStorageBatch oCenIn = en.Tbl_CenterStorageBatch.Where(a => a.BuildBatchID == iBatchId && a.NowAdmStatus == 128).FirstOrDefault(); if (oCenIn != null) { list += ";" + oCenIn.NowAdmTime.Value.ToString(); Tbl_OutCenterStorage oCenOut = en.Tbl_OutCenterStorage.Where(a => a.BuildBatchID == iBatchId && a.PreAdmStatus == 128).FirstOrDefault(); if (oCenOut != null) { list += ";" + oCenOut.PreAdmTime.Value.ToString(); Tbl_SiteStorageBatch oSiteIn = en.Tbl_SiteStorageBatch.Where(a => a.BuildBatchID == iBatchId && a.NowAdmStatus == 128).FirstOrDefault(); if (oSiteIn != null) { list += ";" + oSiteIn.NowAdmTime.Value.ToString(); Tbl_OutSiteStorage oSiteOut = en.Tbl_OutSiteStorage.Where(a => a.BuildBatchID == iBatchId && a.PreAdmStatus == 128).FirstOrDefault(); if (oSiteOut != null) { list += ";" + oSiteOut.PreAdmTime.Value.ToString(); res = (int)BatchStatus.待领料; } else { res = (int)BatchStatus.现场仓库待出库审批; } } else { res = (int)BatchStatus.现场仓库入库待审批; } } else { res = (int)BatchStatus.中心仓库待出库审批; } } else { res = (int)BatchStatus.中心仓库入库待审批; } } else { res = (int)BatchStatus.加工仓库待出库审批; } } else { res = (int)BatchStatus.加工仓库入库待审批; } //Tbl_SiteStorage oSite = en.Tbl_SiteStorage.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); //Tbl_CenterStorage oCenter = en.Tbl_CenterStorage.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); //Tbl_ProductStorage oPro = en.Tbl_ProductStorage.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); //if (oSite != null) //{ // Tbl_OutSiteStorage oOut = en.Tbl_OutSiteStorage.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); // if (oOut ==null) // res = (int)BatchStatus.现场仓库待出库审批; // else // res = (int)BatchStatus.待领料; //} //else if (oCenter != null) //{ // Tbl_OutCenterStorage oOut = en.Tbl_OutCenterStorage.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); // if (oOut==null) // res = (int)BatchStatus.中心仓库待出库审批; // else // res = (int)BatchStatus.现场仓库入库待审批; //} //else if (oPro != null) //{ // Tbl_OutProductBatch oOut = en.Tbl_OutProductBatch.Where(a => a.BuildBatchID == iBatchId).FirstOrDefault(); // if (oOut==null) // res = (int)BatchStatus.加工仓库待出库审批; // else // res = (int)BatchStatus.中心仓库入库待审批; //} //else //{ // //} track.STime = list; track.Status = res; } } catch (Exception ex) { track = new TrackMsg() { Status = -1 }; } return(track); }
private void Save(object data, int identify) { if (identify == (int)CurrentType.加工登录入库) { List <Tbl_Materies> lMa = data as List <Tbl_Materies>; List <Tbl_ProductBatch> lObj = new List <Tbl_ProductBatch>(); foreach (Tbl_Materies oPro in lMa) { Tbl_ProductBatch oSto = new Tbl_ProductBatch(); oSto.BuildID = oPro.BuildNum; oSto.BuildName = oPro.BuildName; oSto.Count = oPro.TotalNum; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = 0; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 1; oSto.PreAdmTime = DateTime.Now; oSto.NowAdmStatus = 1; oSto.NowAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.ProcessingNum; lObj.Add(oSto); } Msg msg = ProductModel.NEditInBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "编辑成功"); } // CallBack call = ReturnMsg; // Thread thread = new Thread(() => GetBarCode(lObj, call)); // thread.IsBackground = true; // thread.Start(); } else if (identify == (int)CurrentType.加工确认入库) { List <Tbl_ProductBatch> lMa = data as List <Tbl_ProductBatch>; List <Tbl_ProductStorage> lObj = new List <Tbl_ProductStorage>(); foreach (Tbl_ProductBatch oPro in lMa) { Tbl_ProductStorage oSto = new Tbl_ProductStorage(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.InCount = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 128; oSto.PreAdmTime = DateTime.Now; oSto.NowAdmStatus = 1; oSto.NowAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = ProductModel.NEnsureInBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.加工登录出库) { List <Tbl_ProductStorage> lMa = data as List <Tbl_ProductStorage>; List <Tbl_OutProductBatch> lObj = new List <Tbl_OutProductBatch>(); foreach (Tbl_ProductStorage oPro in lMa) { Tbl_OutProductBatch oSto = new Tbl_OutProductBatch(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.Count = oPro.InCount == null?0:(int)oPro.InCount; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 1; oSto.PreAdmTime = DateTime.Now; oSto.NowAdmStatus = 1; oSto.NowAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = ProductModel.NEditOurBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.加工确认出库) { List <Tbl_OutProductBatch> lMa = data as List <Tbl_OutProductBatch>; List <Tbl_CenterStorageBatch> lObj = new List <Tbl_CenterStorageBatch>(); foreach (Tbl_OutProductBatch oPro in lMa) { Tbl_CenterStorageBatch oSto = new Tbl_CenterStorageBatch(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.Count = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 128; oSto.PreAdmTime = DateTime.Now; oSto.NowAdmStatus = 1; oSto.NowAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = ProductModel.NEnsureOutBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.中心确认入库) { List <Tbl_CenterStorageBatch> lMa = data as List <Tbl_CenterStorageBatch>; List <Tbl_CenterStorage> lObj = new List <Tbl_CenterStorage>(); foreach (Tbl_CenterStorageBatch oPro in lMa) { Tbl_CenterStorage oSto = new Tbl_CenterStorage(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.InCount = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 128; oSto.PreAdmTime = DateTime.Now; oSto.NowAdmStatus = 1; oSto.NowAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = Center.NEnsureInBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.中心登录出库) { List <Tbl_CenterStorage> lMa = data as List <Tbl_CenterStorage>; List <Tbl_OutCenterStorage> lObj = new List <Tbl_OutCenterStorage>(); foreach (Tbl_CenterStorage oPro in lMa) { Tbl_OutCenterStorage oSto = new Tbl_OutCenterStorage(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.Count = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 1; oSto.PreAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = Center.NEditOutBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.中心确认出库) { List <Tbl_OutCenterStorage> lMa = data as List <Tbl_OutCenterStorage>; List <Tbl_SiteStorageBatch> lObj = new List <Tbl_SiteStorageBatch>(); foreach (Tbl_OutCenterStorage oPro in lMa) { Tbl_SiteStorageBatch oSto = new Tbl_SiteStorageBatch(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.Count = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 128; oSto.PreAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = Center.NEnsureOutBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.现场确认入库) { List <Tbl_SiteStorageBatch> lMa = data as List <Tbl_SiteStorageBatch>; List <Tbl_SiteStorage> lObj = new List <Tbl_SiteStorage>(); foreach (Tbl_SiteStorageBatch oPro in lMa) { Tbl_SiteStorage oSto = new Tbl_SiteStorage(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.InCount = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 128; oSto.PreAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = SiteStorageModel.NEnsureInBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.现场登录出库) { List <Tbl_SiteStorage> lMa = data as List <Tbl_SiteStorage>; List <Tbl_OutSiteStorage> lObj = new List <Tbl_OutSiteStorage>(); foreach (Tbl_SiteStorage oPro in lMa) { Tbl_OutSiteStorage oSto = new Tbl_OutSiteStorage(); oSto.BuildBatchID = (int)oPro.BuildBatchID; oSto.BuildID = oPro.BuildID; oSto.BuildName = oPro.BuildName; oSto.Count = oPro.Count; oSto.MateriesID = oPro.MateriesID; oSto.MateriesTasbleID = oPro.MateriesTasbleID; oSto.MateriesType = oPro.MateriesType; oSto.PlanID = oPro.PlanID; oSto.PreAdmStatus = 1; oSto.PreAdmTime = DateTime.Now; oSto.ProjectName = oPro.ProjectName; oSto.Time = DateTime.Now; oSto.WorkMapID = oPro.WorkMapID; lObj.Add(oSto); } Msg msg = SiteStorageModel.NEditOutBunch(lObj); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } else if (identify == (int)CurrentType.现场确认出库) { List <Tbl_OutSiteStorage> lMa = data as List <Tbl_OutSiteStorage>; Msg msg = SiteStorageModel.EnsureOutBunch(lMa); if (msg.Status) { PageHelper.ShowAlertMsg(this, "确认成功"); } else { PageHelper.ShowAlertMsg(this, "确认失败:" + msg.Message); } } }