Beispiel #1
0
        public void Create(MES_M201_Plan MES_M201_Plan)
        {
            MES_M201_Plan.CreateDt = DateTime.Now;
            tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User;

            MES_M201_Plan.CreateUser = tempUser.UserName;
            MES_M201_Plan.Validate();
            this.MES_M201_PlanRepository.Add(MES_M201_Plan);
            this.runtimeService.Commit();
        }
Beispiel #2
0
        public void Update(MES_M201_Plan MES_M201_Plan)
        {
            MES_M201_Plan.ModifyDt = DateTime.Now;
            tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User;

            MES_M201_Plan.ModifyUser = tempUser.UserName;
            MES_M201_Plan.Validate();
            var existstb_Sys_Menu = this.GetById(MES_M201_Plan.Id);

            this.MES_M201_PlanRepository.SetValues(MES_M201_Plan, existstb_Sys_Menu);
            this.runtimeService.Commit();
        }
Beispiel #3
0
        private void EditForm(string formText, string btnCommand)
        {
            MES_M201_Plan      temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
            MES201PlanEditForm edit = new MES201PlanEditForm(temp, planService);

            edit.Text = formText;
            edit.Tag  = btnCommand;

            if (edit.ShowDialog() != DialogResult.OK)
            {
                mESM201PlanBindingSource.CancelEdit();
            }
            else
            {
                mESM201PlanBindingSource_CurrentChanged(null, null);
            }
        }
Beispiel #4
0
 public override void OnBtnCommand(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // MessageBox.Show(e.Item.Caption);
     //新增
     if (e.Item.Caption == BtnCommandEnum.Add)
     {
         mESM201PlanBindingSource.AddNew();
         MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
         temp.PLDt   = DateTime.Now.Date;
         temp.PLType = "周计划";
         EditForm("生产计划单新增", BtnCommandEnum.Add);
     }
     else if (e.Item.Caption == BtnCommandEnum.Edit)
     {
         MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
         if (temp == null)
         {
             throw new AppException("请先选择要修改的数据");
         }
         if (!string.IsNullOrWhiteSpace(temp.PLAuditing))
         {
             throw new AppException("已审核的计划单不能修改");
         }
         EditForm("生产计划单修改", BtnCommandEnum.Edit);
     }
     else if (e.Item.Caption == BtnCommandEnum.Delete)
     {
         if (ERPHelper.Instance.MessageDel())
         {
             MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
             if (!string.IsNullOrEmpty(temp.PLAuditing))
             {
                 throw new AppException("单子已审核,无法删除");
             }
             planService.Delete(temp.Id);
             mESM201PlanBindingSource.RemoveCurrent();
         }
     }
     else if (e.Item.Caption == BtnCommandEnum.Watch)
     {
         MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
         if (temp == null)
         {
             throw new AppException("请先选择要查看的数据");
         }
         EditForm("生产计划单查看", BtnCommandEnum.Watch);
     }
     else if (e.Item.Caption == BtnCommandEnum.Refresh)
     {
         InitData();
     }
     else if (e.Item.Caption == "生成物料清单")
     {
         MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
         if (temp != null)
         {
             MES201ProductMaterialForm frm = new MES201ProductMaterialForm(temp.Id.ToString());
             frm.Tag = BtnCommandEnum.Add;
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 mESM201PlanDetailBindingSource_CurrentChanged(null, null);
             }
         }
     }
     else if (e.Item.Caption == "审核")
     {
         MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
         if (temp != null && string.IsNullOrWhiteSpace(temp.PLAuditing))
         {
             planService.ShenHe(temp);
             XtraMessageBox.Show("审核成功");
         }
         else
         {
             XtraMessageBox.Show("已审核");
         }
     }
     else if (e.Item.Caption == "反审")
     {
         MES_M201_Plan temp = mESM201PlanBindingSource.Current as MES_M201_Plan;
         if (temp != null && !string.IsNullOrWhiteSpace(temp.PLAuditing))
         {
             temp.PLAuditing   = "";
             temp.PLAuditingDt = null;
             planService.Update(temp);
             XtraMessageBox.Show("反审成功");
         }
         else
         {
             XtraMessageBox.Show("未审核");
         }
     }
 }
Beispiel #5
0
        public void Save(MES_M201_Plan plan, List <MES_M201_Plan_Detail> productList, List <MES_M201_Plan_Daily> planDailyList)
        {
            tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User;

            var existsplan = this.GetById(plan.Id);

            if (existsplan == null)
            {
                plan.CompCode   = tempUser.CompCode;
                plan.CreateDt   = DateTime.Now;
                plan.CreateUser = tempUser.UserName;
                plan.Validate();
                this.MES_M201_PlanRepository.Add(plan);
            }
            else
            {
                plan.ModifyDt   = DateTime.Now;
                plan.ModifyUser = tempUser.UserName;
                plan.Validate();
                this.MES_M201_PlanRepository.SetValues(plan, existsplan);
            }
            foreach (var product in productList)
            {
                var existsmatSupp = planDetailRepository.GetByID(product.Id);
                if (existsmatSupp == null)
                {
                    product.CompCode   = tempUser.CompCode;
                    product.CreateDt   = DateTime.Now;
                    product.CreateUser = tempUser.UserName;
                    product.PLNo       = plan.PLNo;
                    product.PlanId     = plan.Id;
                    product.Validate();
                    this.planDetailRepository.Add(product);
                }
                else
                {
                    product.ModifyDt   = DateTime.Now;
                    product.ModifyUser = tempUser.UserName;
                    product.Validate();
                    this.planDetailRepository.SetValues(product, existsmatSupp);
                }
            }
            foreach (var planDaily in planDailyList)
            {
                var existsmatSupp = planDailyRepository.GetByID(planDaily.Id);
                if (existsmatSupp == null)
                {
                    planDaily.CompCode = tempUser.CompCode;
                    planDaily.PLNo     = plan.PLNo;
                    planDaily.Validate();
                    this.planDailyRepository.Add(planDaily);
                }
                else
                {
                    planDaily.Validate();
                    this.planDailyRepository.SetValues(planDaily, existsmatSupp);
                }
            }

            this.runtimeService.Commit();
        }
Beispiel #6
0
 public MES201PlanEditForm(MES_M201_Plan model, IMES_M201_PlanService planService)
 {
     InitializeComponent();
     this.tempData    = model;
     this.planService = planService;
 }