예제 #1
0
        /// <summary>
        /// set mold cut
        /// </summary>
        /// <param name="moldNr"></param>
        /// <param name="currentCut"></param>
        /// <param name="totalCut"></param>
        /// <returns></returns>
        public string SetMoldCut(string moldNr, string currentCut, string totalCut)
        {
            Mold mold = null;

            try
            {
                using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                {
                    IMoldRepository moldRep = new MoldRepository(unitwork);
                    mold = moldRep.GetById(moldNr);
                    if (mold != null)
                    {
                        // update mold state
                        mold.CurrentCuttimes = int.Parse(currentCut);
                        mold.Cuttedtimes     = int.Parse(totalCut);
                    }
                    unitwork.Submit();
                }
            }
            catch (Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
            }
            return(moldNr);
        }
예제 #2
0
        public static Mold GetByCode(int code)
        {
            const string strSql = "SELECT Id, Code, Reference FROM Molds WHERE Code=@Code";
            var          mold   = new Mold();

            try
            {
                using (var connection = SqlServer.OpenConnection())
                {
                    using (var command = new SqlCommand(strSql, connection))
                    {
                        command.Parameters.AddWithValue("@Code", code);

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                mold.Id        = Convert.ToInt32(reader["Id"]);
                                mold.Code      = Convert.ToInt32(reader["Code"]);
                                mold.Reference = reader["Reference"].ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(mold);
        }
예제 #3
0
        public void SimpleFlow_HappyPath()
        {
            var integrationMock = new IntegrationMock <TestMockAddresses>();

            integrationMock
            .SetupReceive(a => a.ReceiveFirstMessage_FILE)
            .SetupSend(a => a.SendFirstMessage_FILE);

            var mold = new Mold <TestMockAddresses>(integrationMock);

            mold.WireUp()
            //.Send(r => r.ReceiveFirstMessage_FILE,
            //    ep => {
            //        ep.RequestFilePath = "TestFileIn.txt";
            //        ep.TimeoutInSeconds = 10;
            //        ep.MessageEncoding = System.Text.Encoding.UTF8;
            //        },
            //    ctx => ctx.DebugInfo("Fire in the hall")
            //)
            .Send(r => r.ReceiveFirstMessage_FILE,
                  ep => ep.RequestFilePath  = "TestFileIn.txt",
                  ep => ep.MessageEncoding  = System.Text.Encoding.UTF8,
                  ep => ep.TimeoutInSeconds = 10,
                  ctx => ctx.DebugInfo("Fire in the hall")
                  )
            .Receive(
                s => s.SendFirstMessage_FILE,
                ep => {
                ep.TimeoutInSeconds = 10;
                ep.MessageEncoding  = System.Text.Encoding.UTF8;
            },
                ctx => ctx.DebugInfo("Yet one more blast!"),
                (i, v) => { return(v.Length > 0); });
        }
예제 #4
0
        /// <summary>
        /// obtains a detail of mold
        /// </summary>
        /// <param name="id">identifier of mold</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Detail(int?id)
        {
            MoldRepository objMold = new MoldRepository(SessionCustom);
            Mold           mold    = null;
            XmlDocument    xmlDoc  = null;

            if (id != null)
            {
                objMold.Entity.MoldId = id;
                objMold.Load();
                mold       = objMold.Entity;
                ViewBag.id = id;
                xmlDoc     = new XmlDocument();
                xmlDoc.LoadXml(objMold.Entity.Xmlcontent);
            }

            return(this.View(new Molde()
            {
                UserPrincipal = CustomUser,
                Module = this.Module,
                Mold = mold,
                ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext),
                CurrentLanguage = CurrentLanguage,
                Xmldocument = xmlDoc
            }));
        }
            public Mold GetBase()
            {
                var mx = new Mold()
                {
                    ID           = base.ID,
                    Guid         = base.Guid,
                    Name         = base.Name,
                    IsEnabled    = base.IsEnabled,
                    ControllerId = base.ControllerId,
                    Created      = base.Created,
                    Modified     = base.Modified
                };

                if (Settings != null && Settings.Count > 0)
                {
                    var data = RunLengthEncoder.Decode(Settings);
                    for (var x = 0; x < data.Count; x++)
                    {
                        if (x < data.Count - 1 && data[x] == 0)
                        {
                            continue;
                        }
                        mx.MoldSettings.Add(new MoldSetting()
                        {
                            Mold = mx, Offset = (short)x, RawData = data[x]
                        });
                    }
                }

                return(mx);
            }
            public void AddMold(Mold item)
            {
                var temp = MoldDepot.ToList();

                temp.Add(item);
                MoldDepot = temp.ToArray();

                InitParamaters();
            }
예제 #7
0
        private void GetData()
        {
            //Get Data Table Mold
            Mold mold = _moldRepository.Get(_id);

            txtMoldNo.Text   = mold.MoldNo;
            txtNote.Text     = mold.Note;
            chkUsing.Checked = (mold.Status == GlobalConstants.StatusValue.Using);
        }
            public void RemoveMold(Mold item)
            {
                var temp = MoldDepot.ToList();
                var idx  = temp.IndexOf(item);

                temp.RemoveAt(idx);
                MoldDepot = temp.ToArray();

                InitParamaters();
            }
예제 #9
0
        public AddAMoldWindow(Mold mold, Order order_OutsoleCode, List <SizeRun> sizeRunList, List <OffDay> offDayList)
        {
            this.mold = mold;
            this.order_OutsoleCode = order_OutsoleCode;
            this.sizeRunList       = sizeRunList;
            this.offDayList        = offDayList;

            sizeRunListClicked = new List <SizeRun>();
            InitializeComponent();
        }
예제 #10
0
 public SpriteEdit(SpriteAction action, List <Mold> molds, ListBox listbox, Mold moldA, Mold moldB, int index, int indexB)
 {
     this.action  = action;
     this.molds   = molds;
     this.listbox = listbox;
     this.moldA   = moldA.Copy();
     this.moldB   = moldB.Copy();
     this.index   = index;
     this.indexB  = indexB;
 }
예제 #11
0
        private static void CreateProductionOrder(Station station, Pallet pallet, Mold mold)
        {
            var productionOrder = new ProductionOrder
            {
                Mold   = mold,
                Pallet = pallet,
                Status = ProductionOrderStatus.Active
            };

            station.ActiveProductionOrder = productionOrder;
            ProductionOrderRepository.SaveOrUpdate(productionOrder);
        }
예제 #12
0
        /// <summary>
        /// 模具测试
        /// </summary>
        /// <param name="moldNR">模具号</param>
        /// <param name="operatorNR">操作员工号</param>
        /// <param name="files">文件列表</param>
        /// <returns>测试信息</returns>
        public Message  MoldTest(string moldNR, string operatorNR, FileUP[] files, int currentCutTimes, bool moldNormal)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                    {
                        IReportRepository reportRep = new ReportRepository(unitwork);

                        Report report = new Report();
                        report.ReportId   = GuidUtil.GenerateGUID();
                        report.MoldID     = moldNR;
                        report.ReportType = ReportType.TestReport;
                        report.OperatorID = operatorNR;
                        report.Date       = DateTime.Now;

                        //upload files
                        FileUpLoad(files, report.ReportId.ToString());

                        reportRep.Add(report);

                        // update the last released date
                        IMoldRepository moldRep = new MoldRepository(unitwork);
                        Mold            mold    = moldRep.GetById(moldNR);
                        mold.LastReleasedDate = report.Date;
                        mold.Cuttedtimes     += mold.CurrentCuttimes;
                        mold.CurrentCuttimes  = 0;
                        if (moldNormal)
                        {
                            mold.State = MoldStateType.Normal;
                        }
                        unitwork.Submit();

                        ts.Complete();

                        return(new Message()
                        {
                            MsgType = MsgType.OK, Content = "实验报告上传成功!"
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
                return(new Message()
                {
                    MsgType = MsgType.Error, Content = ex.Message
                });
            }
        }
예제 #13
0
        private static void StartRegisterOperation(Pallet pallet, Mold mold, Operation operation)
        {
            var operationRegister = new OperationRegister
            {
                Pallet       = pallet,
                InitDateTime = DateTime.Now,
                Mold         = mold,
                OperationIn  = operation,
                Part         = ProductionOrderRepository.GetActiveByPallet(pallet).ActivePart
            };

            OperationRegisterRepository.SaveOrUpdate(operationRegister);
        }
예제 #14
0
        private void btnAddMold_Click(object sender, RoutedEventArgs e)
        {
            int quota = 0;

            Int32.TryParse(txtQuota.Text.ToString(), out quota);
            if (quota == 0)
            {
                MessageBox.Show("Input Quota (Pairs / Day)", "Mold-Calculator", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var moldCreate = new Mold()
            {
                MoldName     = "",
                Quota        = quota,
                OutsoleCode  = orderClicked.OutsoleCode,
                SupplierID   = supplierClicked.SupplierID,
                ComponentID  = componentClicked.ComponentID,
                Round        = 1,
                StartDate    = dpStartDate.SelectedDate.Value.Date,
                RequestDate  = dpRequestDate.SelectedDate.Value.Date,
                CreatedTime  = DateTime.Now,
                ModifiedTime = DateTime.Now
            };

            var sizeRunListTranfer = sizeRunList.Where(w => w.OutsoleCode == orderClicked.OutsoleCode).ToList();

            if (sizeNoClickedList.Count() > 0)
            {
                sizeRunListTranfer = sizeRunListTranfer.Where(w => sizeNoClickedList.Contains(w.SizeNo) == false).ToList();
            }
            var order_OutsoleCode      = orderList.SingleOrDefault(w => w.OutsoleCode == orderClicked.OutsoleCode);
            var offDayMapList_Supplier = offDayMapList.Where(w => w.SupplierID == supplierClicked.SupplierID).ToList();
            var offDayTranferList      = offDayList.Where(w => offDayMapList_Supplier.Select(s => s.OffDayID).Contains(w.OffDayID)).ToList();

            AddAMoldWindow window = new AddAMoldWindow(moldCreate, order_OutsoleCode, sizeRunListTranfer, offDayTranferList);

            window.ShowDialog();
            if (window.isEdit == true)
            {
                moldCreate.Quantity   = window.mold.Quantity;
                moldCreate.SizeNo     = window.mold.SizeNo;
                moldCreate.Pairs      = window.mold.Pairs;
                moldCreate.WorkingDay = window.mold.WorkingDay;
                moldCreate.FinishDate = window.mold.FinishDate;

                currentMoldList.Add(moldCreate);
                sizeNoClickedList.AddRange(window.sizeRunListClicked.Select(s => s.SizeNo));

                ShowData(currentMoldList);
            }
        }
예제 #15
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckData())
         {
             return;
         }
         //Table Mold
         Mold mold = new Mold();
         mold.Id     = _id;
         mold.MoldNo = txtMoldNo.Text.Trim();
         mold.Note   = txtNote.Text.Trim();
         mold.Status = (chkUsing.Checked ? GlobalConstants.StatusValue.Using : GlobalConstants.StatusValue.NoUse);
         _moldRepository.Save(mold);
         UnitOfWork unitOfWork = new UnitOfWork(_projectDataContext);
         int        result     = unitOfWork.Complete();
         if (result > 0)
         {
             if (String.IsNullOrEmpty(_id))
             {
                 if (_quickAdd)
                 {
                     this.Tag     = txtMoldNo.Text.Trim();
                     DialogResult = DialogResult.OK;
                     Close();
                 }
                 else
                 {
                     XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thành công"), LanguageTranslate.ChangeLanguageText("Thông báo"));
                     Clear();
                 }
             }
             else
             {
                 DialogResult = DialogResult.OK;
                 Close();
             }
         }
         else
         {
             XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
 }
예제 #16
0
 public void Execute()
 {
     if (action == SpriteAction.Edit)
     {
         this.molds[index] = this.moldB.Copy();
         Mold temp = this.moldA.Copy();
         this.moldA = this.moldB.Copy();
         this.moldB = temp;
         this.listbox.SelectedIndex = this.index;
     }
     else if (action == SpriteAction.Create)
     {
         this.molds.RemoveAt(index);
         this.listbox.Items.RemoveAt(index);
         this.listbox.SelectedIndex = Math.Min(this.index, this.listbox.Items.Count - 1);
         this.action = SpriteAction.Delete;
     }
     else if (action == SpriteAction.Delete)
     {
         this.molds.Insert(index, moldB.Copy());
         this.listbox.Items.Insert(index, "Mold " + index);
         this.listbox.SelectedIndex = Math.Min(this.index, this.listbox.Items.Count - 1);
         this.action = SpriteAction.Create;
     }
     else if (action == SpriteAction.MoveDown)
     {
         this.molds.Reverse(index, 2);
         this.listbox.SelectedIndex = index;
         this.action = SpriteAction.MoveUp;
     }
     else if (action == SpriteAction.MoveUp)
     {
         this.molds.Reverse(index, 2);
         this.listbox.SelectedIndex = index + 1;
         this.action = SpriteAction.MoveDown;
     }
     else if (action == SpriteAction.IndexChange)
     {
         this.listbox.SelectedIndex = this.indexB;
         int index = this.index;
         this.index  = this.indexB;
         this.indexB = index;
     }
     //
 }
예제 #17
0
        static public void Initialize(TestContext context)
        {
            {
                var mold = new Mold("굴림체", 12, 12);
                mold.Area.X -= 3;
                var printer = new Printer(mold);

                // 기본 라틴
                // Basic Latin: 0021 ~ 007E
                // 0000~0020, and 007F are control charactor.
                printer
                .Add(0x0021, 0x007E)

                // 원 기호
                // WON SIGN: 0x20A9
                .Add(0x20A9);

                ASCIIDict = printer.Print();
            }

            // where is the OrderedTest???
            //PressKorean();
            //ExportKorean();
            {
                var mold = new Mold("굴림체", 12, 12);
                mold.Area.X -= 3;
                var printer = new Printer(mold);

                printer
                // 한글 완성형
                // Hangul Syllables: AC00 ~ D7AF
                // D7A4~D7AF are invalid charactor.
                .Add(0xAC00, 0xD7A3)

                // 한글 자모
                // Hangul Compatibility Jamo: 3130 ~ 318F
                // 3130 is invalid charactor.
                // 3164~318F are not commonly used.
                .Add(0x3131, 0x3163);

                KoreanDict = printer.Print();

                var isDone = KoreanDict.TryExportTo(@"KoreanDict.dat");
            }
        }
            public void AddPanel(RigidTransformation tr, Mold mold)
            {
                if (!MoldDepot.Contains(mold))
                {
                    AddMold(mold);
                }
                var ttr = Transformations.ToList();

                ttr.Add(tr);
                Transformations = ttr.ToArray();

                var tpm = PanelMoldSelection.ToList();

                tpm.Add(mold);
                PanelMoldSelection = tpm.ToArray();

                InitParamaters();
            }
예제 #19
0
        public void PressKorean()
        {
            var mold = new Mold("굴림체", 12, 12);

            mold.Area.X -= 3;
            var printer = new Printer(mold);

            printer
            // 한글 완성형
            // Hangul Syllables: AC00 ~ D7AF
            // D7A4~D7AF are invalid charactor.
            .Add(0xAC00, 0xD7A3)

            // 한글 자모
            // Hangul Compatibility Jamo: 3130 ~ 318F
            // 3130 is invalid charactor.
            // 3164~318F are not commonly used.
            .Add(0x3131, 0x3163);

            KoreanDict = printer.Print();
        }
예제 #20
0
        private bool CheckData()
        {
            if (txtMoldNo.Text.Trim() == "")
            {
                XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Chưa điền dữ liệu"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMoldNo.Focus();
                return(false);
            }
            Mold mold = _moldRepository.FirstOrDefault(_ => _.MoldNo.Equals(txtMoldNo.Text.Trim()));

            if (mold != null &&
                (
                    String.IsNullOrEmpty(_id) ||
                    (!String.IsNullOrEmpty(_id) && txtMoldNo.Text.Trim() != mold.MoldNo)
                ))
            {
                XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Dữ liệu đã tồn tại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMoldNo.Focus();
                return(false);
            }
            return(true);
        }
            public MoldX(Mold mold) : base()
            {
                this.ID           = mold.ID;
                this.Guid         = mold.Guid;
                this.Name         = mold.Name;
                base.IsEnabled    = mold.IsEnabled;
                this.ControllerId = mold.ControllerId;
                this.Created      = mold.Created;
                this.Modified     = mold.Modified;

                var data = mold.MoldSettings.OrderBy(s => s.Offset).ToList();

                if (data.Count > 0)
                {
                    var list = new ushort[data[data.Count - 1].Offset + 1];
                    foreach (var s in data)
                    {
                        list[s.Offset] = s.RawData;
                    }
                    this.Settings    = RunLengthEncoder.Encode(list);
                    this.NumSettings = list.Length;
                }
            }
예제 #22
0
 /// <summary>
 /// 新建模具
 /// </summary>
 /// <param name="mold">模具</param>
 public void Add(Mold mold)
 {
     context.Mold.InsertOnSubmit(mold);
 }
예제 #23
0
        private void AskForReferencePart(Station station, Pallet pallet, Operation operation, Mold mold)
        {
            var reference = string.Empty;
            FrmPartReference frmPartReference = new FrmPartReference();

            frmPartReference.ShowDialog();
            reference = frmPartReference.Reference;

            OperationRegisterController.Register(station, pallet, operation, mold, reference);

            AppGlobal.Snap7Server.WriteWord(station.StatusChangeS7Ack, (ushort)operation.Code);

            station.Bussy = false;
        }
예제 #24
0
        /// <summary>
        /// 申领模具
        /// </summary>
        /// <param name="moldUseType">模具使用类型</param>
        /// <param name="moldNR">模具号</param>
        /// <param name="applicantNR">申请员工工号</param>
        /// <param name="operatorNR">操作员工工号</param>
        /// <param name="workstationNR">操作台号</param>
        /// <returns>申请信息</returns>
        public Message ApplyMold(MoldUseType moldUseType, string moldNR, string applicantNR, string operatorNR, string workstationNR)
        {
            try
            {
                using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                {
                    IWorkstationRepository workstationRep = new WorkstationRepository(unitwork);
                    IMoldRepository        moldRep        = new MoldRepository(unitwork);
                    Mold mold = moldRep.GetById(moldNR);

                    // check mold is available for apply
                    if (mold.State == MoldStateType.NotReturned)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具处于不可借状态!"
                               }
                    }
                    ;

                    // check workstaition reach the max mold apply number
                    if (workstationRep.OverAppliedMold(workstationNR) == false && Settings.Default.AllowOverApply == false)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "申领已到达上限!"
                               }
                    }
                    ;

                    if (mold.CurrentCuttimes != null && mold.MaxCuttimes != null)
                    {
                        if (mold.CurrentCuttimes.Value > mold.MaxCuttimes.Value)
                        {
                            return(new Message()
                            {
                                MsgType = MsgType.Warn, Content = "模具压接次数超过上限!"
                            });
                        }
                    }


                    IPositionRepository positionRep = new PositionRepository(unitwork);
                    Position            position    = positionRep.GetByFacilictyNR(moldNR);

                    //set value of storage record
                    IStorageRecordRepository recordRep     = new StorageRecordRepository(unitwork);
                    StorageRecord            storageRecord = new StorageRecord();
                    storageRecord.StorageRecordNR = GuidUtil.GenerateGUID();
                    storageRecord.PositionId      = position.PositionID;
                    storageRecord.Source          = position.PositionNR;
                    storageRecord.Destination     = workstationNR;
                    storageRecord.OperatorId      = operatorNR;
                    storageRecord.ApplicantId     = applicantNR;
                    storageRecord.Quantity        = 1;
                    storageRecord.Date            = DateTime.Now;
                    storageRecord.TargetNR        = moldNR;
                    storageRecord.RecordType      = (StorageRecordType)moldUseType;

                    // add new storage record
                    recordRep.Add(storageRecord);

                    // update mold last apply storage record nr
                    IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork);
                    MoldLastRecord            lastRecord    = lastRecordRep.GetByMoldNR(moldNR);
                    lastRecord.StorageRecordNR = storageRecord.StorageRecordNR;


                    // update mold state
                    mold       = moldRep.GetById(storageRecord.TargetNR);
                    mold.State = MoldStateType.NotReturned;

                    // update the workstation current mold count
                    Workstation workstation = workstationRep.GetById(storageRecord.Destination);
                    workstation.CurrentMoldCount++;

                    unitwork.Submit();
                    return(new Message()
                    {
                        MsgType = MsgType.OK, Content = "申领成功"
                    });
                }
            }
            catch (Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
                return(new Message()
                {
                    MsgType = MsgType.Error, Content = "请核实所填数据的准确性"
                });
            }
        }
예제 #25
0
 public App()
 {
     InitializeComponent();
     _mold    = new Mold();
     MainPage = new LoginPage();
 }
예제 #26
0
        /// <summary>
        /// 模具移动工作台
        /// </summary>
        /// <param name="moldNR">模具号</param>
        /// <param name="operatorNR">操作员工号</param>
        /// <param name="targetWStationNR">目标工作台号</param>
        /// <returns>移动信息</returns>
        public Message MoldMoveWorkStation(string moldNR, string operatorNR, string targetWStationNR)
        {
            try
            {
                using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                {
                    IWorkstationRepository workstationRep = new WorkstationRepository(unitwork);
                    IMoldRepository        moldRep        = new MoldRepository(unitwork);
                    IEmployeeRepository    empRep         = new EmployeeRepository(unitwork);

                    Mold mold = moldRep.GetById(moldNR);

                    if (!empRep.Exist(operatorNR))
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "操作员不存在!"
                               }
                    }
                    ;
                    if (mold == null)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具不存在!"
                               }
                    }
                    ;
                    Workstation tworkstation = workstationRep.GetById(targetWStationNR);
                    if (tworkstation == null)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "目标工作台不存在!"
                               }
                    }
                    ;

                    // check mold is available for move
                    if (mold.State != MoldStateType.NotReturned)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具未被借用,请先借用!"
                               }
                    }
                    ;

                    MoldView moldview = moldRep.GetMoldViewByMoldNR(moldNR);

                    string currentWorkPosi = moldview.StorageRecordNR == null ? string.Empty : moldRep.GetMoldCurrPosiByRecordNR((Guid)moldview.StorageRecordNR);

                    //   if(workstationRep.GetById(currentWorkPosi)==null)
                    //      return new Message() { MsgType = MsgType.Warn, Content = "模具正在使用的工作台号已经被修改,请先归还此模具再做后续操作!" };

                    if (currentWorkPosi.Equals(targetWStationNR))
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具已经在此工作台,不可重复移动!"
                               }
                    }
                    ;



                    // check workstaition reach the max mold apply number
                    if (workstationRep.OverAppliedMold(targetWStationNR) == false && Settings.Default.AllowOverApply == false)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "目标工作台已经到达模具使用上限!"
                               }
                    }
                    ;


                    IPositionRepository positionRep = new PositionRepository(unitwork);
                    Position            position    = positionRep.GetByFacilictyNR(moldNR);

                    //set value of storage record
                    IStorageRecordRepository recordRep     = new StorageRecordRepository(unitwork);
                    StorageRecord            storageRecord = new StorageRecord();
                    storageRecord.StorageRecordNR = GuidUtil.GenerateGUID();
                    storageRecord.PositionId      = position.PositionID;
                    storageRecord.Source          = currentWorkPosi;
                    storageRecord.Destination     = targetWStationNR;
                    storageRecord.OperatorId      = operatorNR;
                    storageRecord.Quantity        = 1;
                    storageRecord.Date            = DateTime.Now;
                    storageRecord.TargetNR        = moldNR;
                    storageRecord.RecordType      = StorageRecordType.MoveWStation;

                    // add new storage record
                    recordRep.Add(storageRecord);

                    // update mold last apply storage record nr
                    IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork);
                    MoldLastRecord            lastRecord    = lastRecordRep.GetByMoldNR(moldNR);
                    lastRecord.StorageRecordNR = storageRecord.StorageRecordNR;

                    // update the workstation current mold count
                    //Workstation tworkstation = workstationRep.GetById(storageRecord.Destination);
                    //if(tworkstation!=null)
                    tworkstation.CurrentMoldCount++;

                    Workstation sworkstation = workstationRep.GetById(storageRecord.Source);
                    if (sworkstation != null)
                    {
                        sworkstation.CurrentMoldCount--;
                    }

                    unitwork.Submit();
                    return(new Message()
                    {
                        MsgType = MsgType.OK, Content = "移动工作台成功!"
                    });
                }
            }
            catch (Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
                return(new Message()
                {
                    MsgType = MsgType.Error, Content = "请核实所填数据的准确性"
                });
            }
        }
예제 #27
0
        /// <summary>
        /// 归还模具
        /// </summary>
        /// <param name="moldNR">模具号</param>
        /// <param name="applicantNR">申请员工工号</param>
        /// <param name="operatorNR">操作员工工号</param>
        /// <param name="remark">备注</param>
        /// <param name="moldState">模具状态</param>
        /// <returns>归还信息</returns>
        public Message ReturnMold(string moldNR, string applicantNR, string operatorNR, string remark, MoldReturnStateType moldState)
        {
            try
            {
                using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                {
                    IMoldRepository moldRep = new MoldRepository(unitwork);
                    Mold            mold    = moldRep.GetById(moldNR);

                    if (mold.State != MoldStateType.NotReturned)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具已归还!"
                               }
                    }
                    ;

                    StorageRecord storageRecord = new StorageRecord();

                    //set value of storage record
                    IPositionRepository positionRep = new PositionRepository(unitwork);
                    //Position position = positionRep.GetByFacilictyNR(moldNR);
                    Position position = positionRep.GetPartPoolPosition(Settings.Default.MoldPoolPosiNr);
                    storageRecord.PositionId      = position.PositionID;
                    storageRecord.StorageRecordNR = GuidUtil.GenerateGUID();
                    storageRecord.Source          = moldRep.GetMoldCurrPosiByMoldNR(moldNR);
                    storageRecord.Destination     = position.PositionNR;
                    storageRecord.OperatorId      = operatorNR;
                    storageRecord.ApplicantId     = applicantNR;
                    storageRecord.Date            = DateTime.Now;
                    storageRecord.Quantity        = 1;
                    storageRecord.TargetNR        = moldNR;
                    storageRecord.Remark          = remark;
                    storageRecord.RecordType      = StorageRecordType.Return;

                    // add new storage record
                    IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork);
                    recordRep.Add(storageRecord);

                    // update mold last apply storage record nr
                    IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork);
                    MoldLastRecord            lastRecord    = lastRecordRep.GetByMoldNR(moldNR);
                    lastRecord.StorageRecordNR = storageRecord.StorageRecordNR;

                    // update mold state
                    mold       = moldRep.GetById(storageRecord.TargetNR);
                    mold.State = (MoldStateType)moldState;

                    // update workstation mold count
                    IWorkstationRepository workstationRep = new WorkstationRepository(unitwork);
                    Workstation            workstation    = workstationRep.GetById(storageRecord.Source);
                    if (workstation != null)
                    {
                        workstation.CurrentMoldCount--;
                    }

                    unitwork.Submit();
                    return(new Message()
                    {
                        MsgType = MsgType.OK, Content = "归还成功"
                    });
                }
            }
            catch (Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
                return(new Message()
                {
                    MsgType = MsgType.Error, Content = ex.Message
                });
            }
        }
예제 #28
0
        /// <summary>
        /// 根据模具号删除模具
        /// </summary>
        /// <param name="moldNR">模具号</param>
        public void DeleteById(string moldNR)
        {
            Mold mold = GetById(moldNR);

            context.Mold.DeleteOnSubmit(mold);
        }
예제 #29
0
        /// <summary>
        /// 根据模具号获得模具
        /// </summary>
        /// <param name="moldNR">模具号</param>
        /// <returns>模具实例</returns>
        public Mold GetById(string moldNR)
        {
            Mold mold = context.Mold.SingleOrDefault(m => m.MoldNR.Equals(moldNR));

            return(mold);
        }
예제 #30
0
        /// <summary>
        /// 将模具从缓冲区移到库位
        /// </summary>
        /// <param name="moldNR">模具号</param>
        /// <param name="operatorNR">操作员工号</param>
        /// <param name="remark">备注</param>
        /// <returns>操作信息</returns>
        public Message ReturnMoldInPosition(string moldNR, string operatorNR, string remark)
        {
            try
            {
                using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                {
                    IMoldRepository moldRep = new MoldRepository(unitwork);
                    Mold            mold    = moldRep.GetById(moldNR);

                    if (mold.State == MoldStateType.NotReturned)
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具还未归还,请归还后再入库!"
                               }
                    }
                    ;

                    string currentPosi = moldRep.GetMoldCurrPosiByMoldNR(moldNR);

                    if (!currentPosi.Equals(GetPartPoolPosiNr()))
                    {
                        return new Message()
                               {
                                   MsgType = MsgType.Warn, Content = "模具已经入库!"
                               }
                    }
                    ;
                    StorageRecord storageRecord = new StorageRecord();

                    //set value of storage record

                    IPositionRepository positionRep = new PositionRepository(unitwork);
                    Position            position    = positionRep.GetByFacilictyNR(moldNR);
                    storageRecord.PositionId      = position.PositionID;
                    storageRecord.StorageRecordNR = GuidUtil.GenerateGUID();
                    storageRecord.Source          = currentPosi;
                    storageRecord.Destination     = position.PositionNR;
                    storageRecord.OperatorId      = operatorNR == null?string.Empty: operatorNR.ToString();
                    storageRecord.Date            = DateTime.Now;
                    storageRecord.Quantity        = 1;
                    storageRecord.TargetNR        = moldNR;
                    storageRecord.Remark          = remark == null?string.Empty:remark.ToString();
                    storageRecord.RecordType      = StorageRecordType.MoveStore;

                    // add new storage record
                    IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork);
                    recordRep.Add(storageRecord);

                    // update mold last apply storage record nr
                    IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork);
                    MoldLastRecord            lastRecord    = lastRecordRep.GetByMoldNR(moldNR);
                    lastRecord.StorageRecordNR = storageRecord.StorageRecordNR;
                    unitwork.Submit();
                    return(new Message()
                    {
                        MsgType = MsgType.OK, Content = "入库成功"
                    });
                }
            }
            catch (Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
                return(new Message()
                {
                    MsgType = MsgType.Error, Content = ex.Message
                });
            }
        }