示例#1
0
 public void SaveWorkCenter(Sender sender, SaveWorkCenterArgs args)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy(true))
         {
             WorkCenter obj = new WorkCenter();
             obj.WorkCenterID = args.WorkCenter.WorkCenterID;
             if (op.LoadWorkCenterByWorkCenterID(obj) == 0)
             {
                 args.WorkCenter.Created    = DateTime.Now;
                 args.WorkCenter.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                 args.WorkCenter.Modified   = DateTime.Now;
                 args.WorkCenter.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                 op.InsertWorkCenter(args.WorkCenter);
             }
             else
             {
                 args.WorkCenter.Modified   = DateTime.Now;
                 args.WorkCenter.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                 op.UpdateWorkCenterByWorkCenterID(args.WorkCenter);
             }
             op.CommitTransaction();
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
示例#2
0
        public void SaveWorkCenter()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    if (parm.WorkShopID == Guid.Empty)
                    {
                        throw new Exception("请选择车间。");
                    }
                    if (parm.WorkFlowID == Guid.Empty)
                    {
                        throw new Exception("请选择对应工序。");
                    }

                    if (parm.CountCapacityType == "请选择")
                    {
                        throw new Exception("请选择产能计算方式。");
                    }

                    SaveWorkCenterArgs args       = new SaveWorkCenterArgs();
                    WorkCenter         workcenter = p.Client.GetWorkCenter(SenderUser, parm.WorkCenterID);
                    if (workcenter == null)
                    {
                        workcenter = new WorkCenter();
                        workcenter.WorkCenterID = parm.WorkCenterID;
                    }
                    workcenter.WorkCenterCode    = parm.WorkCenterCode;
                    workcenter.WorkCenterName    = parm.WorkCenterName;
                    workcenter.WorkFlowID        = parm.WorkFlowID;
                    workcenter.MaxCapacity       = parm.MaxCapacity;
                    workcenter.WorkShopID        = parm.WorkShopID;
                    workcenter.Style             = parm.Style;
                    workcenter.Model             = parm.Model;
                    workcenter.Sequence          = parm.Sequence;
                    workcenter.Remark            = parm.Remark;
                    workcenter.CountCapacityType = parm.CountCapacityType;
                    args.WorkCenter = workcenter;
                    p.Client.SaveWorkCenter(SenderUser, args);
                }
                WriteSuccess();
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }