Example #1
0
 public SimulateEntry(SessionInfo _session = null, PlanningHeadModel model = null, SimulateActionModel simModel = null)
 {
     InitializeComponent();
     this._repo = new WorkEntryRepo();
     HeadModel = model;
     SimModel = simModel;
     epiSession = _session;
 }
Example #2
0
 public SimulateReShear(SessionInfo _session = null, PlanningHeadModel model = null, SimulateReshearHeadModel data = null)
 {
     InitializeComponent();
     this._repo = new WorkEntryRepo();
     HeadModel = model;
     ReshearHead = data;
     epiSession = _session;
 }
Example #3
0
 public MaterialSelecting(SessionInfo _session, IEnumerable<MaterialModel> data, PlanningHeadModel workOrder)
 {
     InitializeComponent();
     this._repo = new WorkEntryRepo();
     epiSession = _session;
     this.model = data;
     this._selected = new MaterialModel();
     this.baseOrder = workOrder;
 }
Example #4
0
 public SerialList(SessionInfo _session = null, IEnumerable<GeneratedSerialModel> model = null, PlanningHeadModel head = null)
 {
     InitializeComponent();
     this._repo = new WorkEntryRepo();
     epiSession = _session;
     snList = model;
     workParent = head;
     GenSNComplete = true;
 }
Example #5
0
        private void butWorkOrder_Click(object sender, EventArgs e)
        {
            HeaderContent = new PackingOrderModel();
            PlanningHeadModel plan = new PlanningHeadModel();
            plan.Plant = epiSession.PlantID;
            plan.Completed = 1; //Completed.
            plan.GenSerialFlag = 1;  //Serial has created.
            plan.OperationState = 1; //Stay on production operation.

            var result = _repo.GetWorkAll(plan);
            using (WorkEntryDialog frm = new WorkEntryDialog(epiSession, result))
            {
                frm.ShowDialog();
                if (frm._selected != null)
                {
                    HeaderContent.WorkOrderId = frm._selected.WorkOrderID;
                    HeaderContent.WorkOrderNum = frm._selected.WorkOrderNum;
                    if (!_repo.PackOrderExist(HeaderContent.WorkOrderId))
                    {
                        PackingOrderModel model = new PackingOrderModel();
                        model.WorkOrderId = HeaderContent.WorkOrderId;
                        model.PackOrderNum = "PKG-" + HeaderContent.WorkOrderNum;
                        model.Remark = "";
                        model.CompleteFlag = 0;

                        if (_repo.SavePackOrder(epiSession, model, out HeaderContent))
                        {
                            var styles = _repo.GetPackStyleByWorkOrder(HeaderContent.WorkOrderId, HeaderContent.Id);
                            if (_repo.SavePackStyles(epiSession, styles))
                            {
                                var resultStyle = _repo.GetPackStyleByPackOrder(HeaderContent.WorkOrderId).ToList();
                                foreach (var item in resultStyle)
                                {
                                    var savingSn = _repo.GetSerialForFirstDefault(item);
                                    _repo.SaveSerialByStyle(epiSession, savingSn);
                                }
                            }
                        }
                    }

                    HeaderContent = _repo.GetPackOrderByID(HeaderContent.WorkOrderId);
                }
            }

            BindingContentsHeader(HeaderContent);

            ListPackingStyleToGrid(HeaderContent.PackStyles);
            string styleId = dgvPackStyle.CurrentRow.Cells["styleid"].Value.GetString();
            ListSerialCuttingToGrid(HeaderContent.SerialLines.Where(i => i.PackStyleId == Convert.ToInt32(styleId)));
            ListSkidWithinSerial(HeaderContent.SkidPacks.Where(i => i.PackStyleId == Convert.ToInt32(styleId)));
        }
Example #6
0
        private void SetHeadContent(PlanningHeadModel model)
        {
            ClearHeaderContent();
            model.PIC = epiSession.UserID;
            model.PICName = epiSession.UserName;

            //ComboBox
            cmbProcessLine.DataSource = model.Resources.ToList();
            cmbProcessLine.DisplayMember = "ResourceDescription";
            cmbProcessLine.ValueMember = "ResourceID";
            cmbProcessLine.DataBindings.Add("SelectedValue", model, "ProcessLineId", false, DataSourceUpdateMode.OnPropertyChanged);
            cmbOrderType.DataSource = model.OrderTypeList.ToList();
            cmbOrderType.DisplayMember = "CodeDesc";
            cmbOrderType.ValueMember = "CodeID";
            cmbOrderType.DataBindings.Add("SelectedValue", model, "OrderType", false, DataSourceUpdateMode.OnPropertyChanged);
            cmbPossession.DataSource = model.Possessions.ToList();
            cmbPossession.DisplayMember = "CodeDesc";
            cmbPossession.ValueMember = "CodeID";
            cmbPossession.DataBindings.Add("SelectedValue", model, "Possession", false, DataSourceUpdateMode.OnPropertyChanged);
        }
Example #7
0
        public IEnumerable<PlanningHeadModel> GetWorkAll(PlanningHeadModel model)
        {
            string whereCluase = string.Empty;
            if (model.Completed != 0) whereCluase = string.Format(@"AND Completed = {0}", model.Completed);
            if (model.GenSerialFlag != 0) whereCluase += string.Format(@"AND GenSerialFlag = {0}", model.GenSerialFlag);
            if (model.OperationState != 0) whereCluase += string.Format(@"AND OperationState = {0}", model.OperationState);

            string sql = string.Format(@"SELECT uf.Name as PICName, busi.Character01 as BussinessTypeName, plh.*
                                            FROM ucc_pln_PlanHead plh (NOLOCK)
                                                LEFT JOIN UserFile uf ON(plh.PIC = uf.DcdUserID)
	                                            LEFT JOIN UD25 busi ON(plh.BT = busi.Key1)
	                                            INNER JOIN (select Count(*) as lines, WorkOrderID 
				                                            from ucc_pln_SerialGenerated 				
				                                            where Status = 'F'
				                                            group by WorkOrderID) ln
						                                            ON(plh.WorkOrderID = ln.WorkOrderID)
                                            WHERE plh.Plant = N'{0}' AND PackingOrderFlag = 0 {1}", model.Plant, whereCluase);

            var result = Repository.Instance.GetMany<PlanningHeadModel>(sql);
            return result;
        }
Example #8
0
        public WorkEntry(SessionInfo _session = null, PlanningHeadModel model = null)
        {
            InitializeComponent();
            this._repoRes = new ResourceRepo();
            this._repoUcd = new UserCodeRepo();
            this._repo = new WorkEntryRepo();
            this._reRes = new ResourceRepo();
            this._repoSale = new SaleOrderRepo();
            this._repoCls = new ClassMasterRepo();

            this.HeaderContent = new PlanningHeadModel();
            this._class = new ClassMasterModel();

            //Initial Session and content
            this.HeaderContent = new PlanningHeadModel();
            epiSession = _session;
            if (model != null)
            {
                this.HeaderContent = model;
            }
        }
Example #9
0
        public bool ClearSerialInEpicor(SessionInfo _session, PlanningHeadModel model, out string msg)
        {
            msg = string.Empty;
            bool IsSuccess = true;
            string sql = string.Empty;
            Session currSession = null;
            var resultContinue = GetSerialAllByWorkOrder(model.WorkOrderID).ToList();
            try
            {
                currSession = new Session(_session.UserID, _session.UserPassword, _session.AppServer, Session.LicenseType.Default);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                IsSuccess = false;
            }

            foreach (var item in resultContinue)
            {
                try
                {
                    LotSelectUpdate lotPart = new LotSelectUpdate(currSession.ConnectionPool);
                    lotPart.DeleteByID(string.IsNullOrEmpty(item.NORNum) ? item.MCSSNo : item.NORNum, item.SerialNo);
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    IsSuccess = false;
                }

                //TODO : There are has one more case for delete S/N.
                sql += string.Format(@"DELETE FROM ucc_pln_SerialGenerated WHERE WorkOrderID = {0} AND SerialNo = '{1}' {2}{3}{4}"
                                        , item.WorkOrderID, item.SerialNo, Environment.NewLine, "", Environment.NewLine);
            }

            sql += string.Format(@"UPDATE ucc_pln_PlanHead SET GenSerialFlag = 0 WHERE WorkOrderID = {0} ", model.WorkOrderID);
            Repository.Instance.ExecuteWithTransaction(sql, "Delete Serial");
            return IsSuccess;
        }
Example #10
0
        public IEnumerable<OrderHeadModel> GetOrderHeader(PlanningHeadModel model, string orderNum = null)
        {
            string sql = string.Format(@"SELECT soh.OrderNum, soh.OrderDate, soh.RequestDate, cust.CustID, cust.Name as CustomerName
	                                            , ensr.CustID as EndUserCode, ensr.Name as EndUserName, vend.CustID as ShipTo, vend.Name as ShipToName
	                                            , soh.PONum, socd.Key1 as SOCode, socd.Character01 as SOCodeName, soh.TermsCode
	                                            , busi.Key1 as BussinessType, busi.Character01 as BussinessTypeName, soh.ShortChar04
	                                            , soh.EntryPerson, soh.Number03 as TotalWeight, soh.Number04 as TotalAmount
                                            FROM OrderHed soh
                                                LEFT JOIN Customer cust ON(soh.CustNum = cust.CustNum)
                                                LEFT JOIN Customer ensr ON(soh.ShortChar07 = ensr.CustID)
                                                LEFT JOIN Customer vend ON(soh.ShortChar09 = vend.CustID)
                                                LEFT JOIN UD33 socd ON(soh.ShortChar02 = socd.Key1)
                                                LEFT JOIN UD25 busi ON(soh.ShortChar03 = busi.Key1)
                                            WHERE soh.OpenOrder = 1 AND soh.VoidOrder = 0");

            var result = Repository.Instance.GetMany<OrderHeadModel>(sql);
            if (!string.IsNullOrEmpty(model.OrderType)) result = result.Where(p => p.OrderType.GetString() == model.OrderType);
            //if (!string.IsNullOrEmpty(model.BussinessType)) result = result.Where(p => p.BussinessType.GetString() == model.BussinessType);
            if (!string.IsNullOrEmpty(orderNum)) result = result.Where(p => p.OrderNum.GetString() == orderNum);

            return result;
        }
Example #11
0
 /// <summary>
 /// Sum Yield percent on header
 /// </summary>
 /// <param name="model"></param>
 public void SumYeild(PlanningHeadModel model)
 {
     Yield = CalYeildPercent(Math.Round(OutputWeight, 0), Math.Round(InputWeight, 0), Math.Round(RewindWeight, 0));
 }
Example #12
0
 /// <summary>
 /// Sum Rewind weight on header
 /// </summary>
 /// <param name="model"></param>
 public void SumRewindWeight(PlanningHeadModel model)
 {
     if (model.CoilBacks.ToList().Count != 0)
     {
         RewindWeight = Math.Round(model.CoilBacks.Sum(p => p.Weight), 0);
     }
     else
     {
         RewindWeight = 0;
     }
 }
Example #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="model"></param>
 public void SumProductWidth(PlanningHeadModel model)
 {
     TotalWidth = (from item in model.CuttingDesign
                   where item.Status != "S"
                   select item).Sum(i => i.Width * i.Stand);
 }
Example #14
0
 /// <summary>
 /// Sum Output weight on header
 /// </summary>
 /// <param name="model"></param>
 public void SumOutputWeight(PlanningHeadModel model)
 {
     if (model.CuttingDesign.ToList().Count != 0)
     {
         OutputWeight = Math.Round(model.CuttingDesign.Where(p => p.Status != "S").Sum(i => i.TotalWeight), 0);
     }
     else
     {
         OutputWeight = 0;
     }
 }
Example #15
0
 /// <summary>
 /// Sum Loss weight on header
 /// </summary>
 /// <param name="model"></param>
 public void SumLossWeight(PlanningHeadModel model)
 {
     LossWeight = InputWeight.GetDecimal() - RewindWeight.GetDecimal() - OutputWeight.GetDecimal();
 }
Example #16
0
        private void butSimulate_Click(object sender, EventArgs e)
        {
            if (HeaderContent.ProcessLine.ResourceGrpID == "S")
            {
                SimulateActionModel simModel = new SimulateActionModel();
                simModel.WorkOrderID = HeaderContent.WorkOrderID;
                simModel.WorkOrderNum = HeaderContent.WorkOrderNum;
                simModel.MaterialWeight = HeaderContent.InputWeight;
                simModel.ProductWeight = HeaderContent.OutputWeight;
                simModel.Yield = HeaderContent.Yield;
                simModel.TrimWeight = HeaderContent.CuttingDesign.Where(i => i.Status.Equals("S")).Sum(i => i.TotalWeight);
                simModel.Cuttings = _repo.GetSimulateAll(HeaderContent.WorkOrderID).ToList();
                simModel.Materials = HeaderContent.Materials.ToList();
                using (SimulateEntry frm = new SimulateEntry(epiSession, HeaderContent, simModel))
                {
                    frm.ShowDialog();
                    HeaderContent = frm.HeadModel;
                }
            }

            SetHeadContent(HeaderContent);
            ListMaterialGrid(HeaderContent.Materials);
            ListCuttingGrid(HeaderContent.CuttingDesign);
            ListCoilBackGrid(HeaderContent.CoilBacks);
            dgvMaterial.EndEdit();
        }
Example #17
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (dgvWorkOrder.Rows.Count >= 1)
            {
                int iRow = dgvWorkOrder.CurrentRow.Index;
                string WrkNoPara = dgvWorkOrder.Rows[iRow].Cells["workorderid"].Value.ToString();
                string ProcessStepPara = dgvWorkOrder.Rows[iRow].Cells["ProcessStep"].Value.ToString();

                if (!string.IsNullOrEmpty(WrkNoPara))
                {
                    _selected = _repo.GetWorkById(Convert.ToInt32(WrkNoPara), Convert.ToInt32(ProcessStepPara), epiSession.PlantID);
                    _selected.Materials = _repo.GetAllMaterial(epiSession.PlantID, _selected.WorkOrderID).ToList();
                    _selected.CuttingDesign = _repo.GetCuttingLines(_selected.WorkOrderID).ToList();
                    _selected.ProcessLine = _repoRes.GetByID(epiSession.PlantID, _selected.ProcessLineId);
                    this.Close();
                }
            }
        }
Example #18
0
        private void WorkEntryDialog_Load(object sender, EventArgs e)
        {
            Header = new PlanningHeadModel();
            Header.Resources = _repoRes.GetAll(epiSession.PlantID).Where(p => p.ResourceGrpID.Equals("L") || p.ResourceGrpID.Equals("R") || p.ResourceGrpID.Equals("S")).ToList();
            Header.OrderTypeList = _repoUcd.GetAll("OrderType").ToList();
            Header.Possessions = _repoUcd.GetAll("Pocessed").ToList();

            SetHeadContent(Header);
            //ClearHeaderContent();

            if (_model == null)
            {
                PlanningHeadModel plan = new PlanningHeadModel();
                plan.Plant = epiSession.PlantID;
                _model = _repo.GetWorkAll(plan);
            }
            SetGrid(_model);
        }
Example #19
0
 private void butConfirm_Click(object sender, EventArgs e)
 {
     if (HeaderContent.Completed == 1 && HeaderContent.SimulateFlag == 1 && HeaderContent.GenSerialFlag == 0)
     {
         DialogResult diaResulta = MessageBox.Show("Are you sure to unconfirm.", "Question.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (diaResulta == DialogResult.Yes)
         {
             if (_repo.UnConfirmWork(HeaderContent.WorkOrderID))
             {
                 MessageBox.Show("Unconfirmed Order completed.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 HeaderContent = _repo.GetWorkById(HeaderContent.WorkOrderID, Convert.ToInt32(HeaderContent.ProcessStep), epiSession.PlantID);
                 SetHeadContent(HeaderContent);
                 ListMaterialGrid(HeaderContent.Materials);
             }
         }
     }
 }
Example #20
0
        public bool ValidateByRow(PlanningHeadModel head, out string risk, out string msg)
        {
            bool valid = true;
            risk = string.Empty;
            msg = string.Empty;
            var r = this.Thick.ToString();

            if (string.IsNullOrEmpty(Status))
            {
                risk = "WARNNING";
                msg = "";
                return false;
            }

            if (head.CuttingDesign.Where(p => p.Status.ToString().Equals("S") && p.LineID != LineID).ToList().Count != 0 && Status == "S")
            {
                risk = "WARNNING";
                msg = "Status 'S' is already exist in cutting lines.";
                return false;
            }

            if (head.Materials.ToList().Count > 0)
            {
                if (head.ProcessLine.ResourceGrpID == "S")
                {
                    decimal totalWidth = (from item in head.CuttingDesign
                                          select item).Sum(i => i.Width * i.Stand);
                    var totalMatWidth = (from mat in head.Materials
                                         select mat).First();

                    if (totalMatWidth.Width < totalWidth)
                    {
                        risk = "ERROR";
                        msg = "Total width in cutting line is greater than material width.";
                        return false;
                    }
                }
            }

            if (head.ProcessLine.ResourceGrpID == "L")
            {
                if (CalQuantity == 0)
                {
                    risk = "WARNNING";
                    msg = "Calculate quantity invalid.";
                    return false;
                }

                if (Pack != (CalQuantity / ((QtyPack == 0) ? 1 : QtyPack)))
                {
                    risk = "WARNNING";
                    msg = "Pack invalid.";
                    return false;
                }
            }

            if (!string.IsNullOrEmpty(SONo) && SOLine == 0)
            {
                if (string.IsNullOrEmpty(SONo) || SOLine == 0)
                {
                    risk = "WARNNING";
                    msg = "Please select SO Line.";
                    return false;
                }
            }

            if (!string.IsNullOrEmpty(NORNum))
            {
                if (Status == "S")
                {
                    risk = "ERROR";
                    msg = "Please change status = 'F' for S/O line.";
                    return false;
                }
            }

            if (Stand == 0)
            {
                risk = "ERROR";
                msg = "Stand value must be more than zero.";
                return false;
            }

            if (CutDivision == 0)
            {
                risk = "ERROR";
                msg = "Cut Division value must be more than zero.";
                return false;
            }
            return valid;
        }
Example #21
0
 public void CalculateRows(PlanningHeadModel head)
 {
     //Fix bug in case Materials is null.
     if (head.ProcessLine.ResourceGrpID == "S")
     {
         decimal widthMat = 0;
         if (head.Materials.ToList().Count > 0) widthMat = head.Materials.Max(p => p.Width);
         UnitWeight = Math.Round(CalUnitWgtByUsingWgt(head.UsingWeight, widthMat, Width), 2) / ((CutDivision == 0) ? 1 : CutDivision);
         TotalWeight = Math.Round(UnitWeight * (CutDivision * Stand), 2);
         decimal matLengthM = head.Materials.Sum(i => i.LengthM);
         decimal matWeight = head.Materials.Sum(i => i.Weight);
         decimal matUsingWeight = head.Materials.Sum(i => i.UsingWeight);
         TotalLength = CalUsingLength(matLengthM, matWeight, matUsingWeight, CutDivision);
     }
     else if (head.ProcessLine.ResourceGrpID == "L")
     {
         UnitWeight = CalUnitWgt(Thick, Width, Length / 1000, Gravity, FrontPlate, BackPlate);
         TotalWeight = UnitWeight * SOQuantity;
         Pack = CalQuantity / ((QtyPack == 0 ? 1 : QtyPack));
         TotalLength = Length * CalQuantity;
     }
 }
Example #22
0
 private void butWorkOrder_Click_1(object sender, EventArgs e)
 {
     using (WorkEntryDialog frm = new WorkEntryDialog(epiSession))
     {
         frm.ShowDialog();
         if (frm._selected != null)
         {
             HeaderContent = frm._selected;
             HeaderContent.FormState = 3;
             SetFormState();
             //Summaries using weight
             HeaderContent.SumUsingWeight(HeaderContent.Materials);
             //Set content and list Material was add from dialog.
             SetHeadContent(HeaderContent);
             //Set Material Grid.
             try
             {
                 ListMaterialGrid(HeaderContent.Materials);
                 ListCuttingGrid(HeaderContent.CuttingDesign);
                 ListCoilBackGrid(HeaderContent.CoilBacks);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
             }
         }
     }
 }
Example #23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <param name="invalidObject"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool ValidateToSave(PlanningHeadModel model, out string invalidObject, out string msg)
        {
            invalidObject = "";
            msg = "";
            bool valid = true;

            #region Validate Process Line Selected.

            if (ProcessLineId == null)
            {
                invalidObject = "ProcessLine";
                msg = "Please select Process Line.";
                return false;
            }
            else
            {
                if (ProcessLine.ResourceGrpID != "S" && PackingPlan == true)
                {
                    invalidObject = "ProcessLine";
                    msg = "Packing Plan can be select for Slitter only.";
                    return false;
                }

                if (ProcessLine.ResourceGrpID != "L" && LVTrim == true)
                {
                    invalidObject = "ProcessLine";
                    msg = "Trim can be select for Leveller only.";
                    return false;
                }
            }

            #endregion Validate Process Line Selected.

            #region Validate compatible between Machine and Material.

            if (Materials.ToList().Count() > 0)
            {
                //Validate Possession.
                if (Possession == null)
                {
                    invalidObject = "Possession";
                    msg = "Please select Possession.";
                    return false;
                }

                decimal valmin = Materials.Min(i => i.Width);
                if (ProcessLine.WidthMin > valmin)
                {
                    invalidObject = "ProcessLine";
                    msg = string.Format(@"Machine and Material is not compatible for Machine width min = {0} and Material width = {1}.",
                                        ProcessLine.WidthMin.ToString("#,##0.00"), valmin.ToString("#,##0.00"));
                    return false;
                }

                decimal valmax = Materials.Max(i => i.Width);
                if (ProcessLine.WidthMax < valmax)
                {
                    invalidObject = "ProcessLine";
                    msg = string.Format(@"Machine and Material is not compatible for Machine width max = {0} and Material width = {1}.",
                                        ProcessLine.WidthMin.ToString("#,##0.00"), valmax.ToString("#,##0.00"));
                    return false;
                }

                var resSumUsingWgt = Materials.Sum(i => i.UsingWeight);
                var resSumRem = Materials.Sum(i => i.RemainWeight);
                if (Math.Round((resSumUsingWgt + resSumRem), 0) != Math.Round(InputWeight, 0))
                {
                    invalidObject = "InputWeight";
                    msg = @"Input weight invalid.";
                    return false;
                }
            }

            #endregion Validate compatible between Machine and Material.

            #region Cutting line dose existing.

            if (CuttingDesign.ToList().Count > 0)
            {
                //Line from Sale Order
                if (CuttingDesign.Where(i => i.SONo != "").ToList().Count > 0)
                {
                    //Validate OrderType Selected.
                    if (OrderType == null)
                    {
                        invalidObject = "OrderType";
                        msg = "Please select Order Type.";
                        return false;
                    }
                }

                var resSumTotalWgt = CuttingDesign.Where(i => i.Status != "S").Sum(i => i.TotalWeight);
                if (Math.Round(OutputWeight, 0) != Math.Round(resSumTotalWgt, 0))
                {
                    invalidObject = "OutputWeight";
                    msg = @"Output weight invalid.";
                    return false;
                }
            }

            #endregion Cutting line dose existing.

            #region Compare date between Issue date and Due date.

            if (IssueDate > DueDate)
            {
                invalidObject = "IssueDate";
                msg = "Please change Due Date to be greater than Issue Date.";
                return false;
            }

            #endregion Compare date between Issue date and Due date.

            return valid;
        }
Example #24
0
        private void tbutSimulate_Click(object sender, EventArgs e)
        {
            if (HeaderContent.Completed == 1)
            {
                MessageBox.Show("This work order has completed process, can't re-simulate.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (HeaderContent.GenSerialFlag == 1)
            {
                MessageBox.Show("This work order has generated serial, can't re-simulate.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (HeaderContent.ProcessLine.ResourceGrpID == "S")
            {
                //Simulated Complete.
                var resExisting = _repo.GetSimulateAll(HeaderContent.WorkOrderID);
                if (resExisting.ToList().Count > 0)
                {
                    DialogResult diaResult = MessageBox.Show("Simulate line has already, are you sure to clear all.", "Question.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (diaResult == DialogResult.Yes)
                    {
                        _repo.ClearSimulateLines(HeaderContent.WorkOrderID);
                    }
                    else
                    {
                        return;
                    }
                }
                SimulateActionModel simModel = new SimulateActionModel();
                simModel.WorkOrderID = HeaderContent.WorkOrderID;
                simModel.WorkOrderNum = HeaderContent.WorkOrderNum;
                simModel.MaterialWeight = HeaderContent.InputWeight;
                simModel.ProductWeight = HeaderContent.OutputWeight;
                simModel.RewindWeight = HeaderContent.RewindWeight;
                simModel.Yield = HeaderContent.Yield;
                simModel.TrimWeight = HeaderContent.CuttingDesign.Where(i => i.Status.Equals("S")).Sum(i => i.TotalWeight);

                simModel.Cuttings = _repo.InsertSimulate(epiSession, HeaderContent).ToList();
                simModel.Materials = HeaderContent.Materials.ToList();
                using (SimulateEntry frm = new SimulateEntry(epiSession, HeaderContent, simModel))
                {
                    frm.ShowDialog();
                    HeaderContent = frm.HeadModel;
                }

                SetHeadContent(HeaderContent);
                ListMaterialGrid(HeaderContent.Materials);
                ListCuttingGrid(HeaderContent.CuttingDesign);
                ListCoilBackGrid(HeaderContent.CoilBacks);
                tbutCalculate_Click(sender, e);
                //tbutSave_Click(sender, e);
                HeaderContent.SimulateFlag = 1;
            }
            else if (HeaderContent.ProcessLine.ResourceGrpID == "R")
            {
                SimulateReshearHeadModel simModel = new SimulateReshearHeadModel();
                simModel.Materials = HeaderContent.Materials.ToList();
                simModel.Cuttings = HeaderContent.CuttingDesign.ToList();
                simModel.WorkOrderID = HeaderContent.WorkOrderID;
                simModel.WorkOrderNum = HeaderContent.WorkOrderNum;

                using (SimulateReShear frm = new SimulateReShear(epiSession, HeaderContent, simModel))
                {
                    frm.ShowDialog();
                    HeaderContent = frm.HeadModel;
                }
            }
        }
Example #25
0
        private void tbutNew_Click(object sender, EventArgs e)
        {
            HeaderContent = new ProductionHeadModel();
            SetHeadContent(HeaderContent);
            SetTimeControl("Normal");

            PlanningHeadModel plan = new PlanningHeadModel();
            plan.Plant = epiSession.PlantID;
            plan.Completed = 1; //Completed.
            plan.GenSerialFlag = 1;  //Serial has created.
            plan.OperationState = 1; //Stay on planing operation.

            var result = _repoPlan.GetWorkAll(plan);
            using (WorkEntryDialog frm = new WorkEntryDialog(epiSession, result))
            {
                frm.ShowDialog();
                if (frm._selected != null)
                {
                    HeaderContent.OperationState = frm._selected.OperationState;
                    HeaderContent.WorkOrderID = frm._selected.WorkOrderID;
                    HeaderContent.WorkOrderNum = frm._selected.WorkOrderNum;
                    HeaderContent.ProcessLines = frm._selected.Resources.ToList();
                    HeaderContent.ProcessLineID = frm._selected.ProcessLineId;
                    HeaderContent.SerialLines = _repo.GetAllSerialByWorkOrder(HeaderContent.WorkOrderID).ToList();
                    HeaderContent.Materials = frm._selected.Materials.ToList();
                    HeaderContent.Reasons = _repo.GetAllReasonAll().ToList();
                    //Set content and list Material was add from dialog.
                    SetHeadContent(HeaderContent);
                }
                else
                {
                    SetTimeControl("Normal");
                    return;
                }
            }

            if (HeaderContent.OperationState == 3 || HeaderContent.OperationState == 4)
            {
                SetTimeControl("Lock");
            }
            else
            {
                SetTimeControl("Ready");
            }
        }
Example #26
0
 /// <summary>
 /// Sum Input Weight on header
 /// </summary>
 /// <param name="model"></param>
 public void SumInputWeight(PlanningHeadModel model)
 {
     if (model.Materials.ToList().Count != 0)
     {
         InputWeight = Math.Round(model.Materials.Sum(p => p.Weight), 0);
     }
     else
     {
         InputWeight = 0;
     }
 }
Example #27
0
        private void nextProcessStepToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            PlanningHeadModel newWork = new PlanningHeadModel();

            if (dgvCutting.Rows.Count >= 1)
            {
                int iRow = dgvCutting.CurrentRow.Index;
                string mcssno = dgvCutting.Rows[iRow].Cells["mcssno"].Value.ToString();
                string lotno = dgvCutting.Rows[iRow].Cells["serialNo"].Value.ToString();

                if (!string.IsNullOrEmpty(mcssno))
                {
                    var mat = _repo.GetMaterial(epiSession.PlantID, mcssno, lotno);

                    if (mat == null)
                    {
                        MessageBox.Show("This Material is not available.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    newWork.ProcessStep = _repo.GetStepByWorkOrder(workParent.WorkOrderID);
                    newWork.WorkOrderID = workParent.WorkOrderID;
                    newWork.WorkOrderNum = workParent.WorkOrderNum;
                    newWork.IssueDate = DateTime.Now;
                    newWork.DueDate = DateTime.Now;
                    newWork.OpenFlag = 1;
                    newWork = _repo.Save(epiSession, newWork);

                    mat.WorkOrderID = newWork.WorkOrderID;
                    mat.WorkOrderNum = newWork.WorkOrderNum;
                    mat.WorkDate = newWork.IssueDate;
                    mat.SetQuantityPack();
                    mat.SetUsingWeight();
                    mat.SetUsingQuantity();
                    var result = _repo.SaveMaterial(epiSession, mat);
                }
                using (WorkEntry frm = new WorkEntry(epiSession, newWork))
                {
                    frm.Show();
                }
                this.Close();
            }
        }
Example #28
0
        private void SetHeadContent(PlanningHeadModel model)
        {
            //Call clear binding data that anchor with object.
            ClearHeaderContent();
            model.CalculationHeader(model);

            //Default PIC.
            model.PIC = epiSession.UserID;
            model.PICName = epiSession.UserName;

            #region Binding data to TextBox objects.

            txtWorkOrderNum.DataBindings.Add("Text", model, "WorkOrderNum", false, DataSourceUpdateMode.OnPropertyChanged);
            txtProcessStep.DataBindings.Add("Text", model, "ProcessStep", false, DataSourceUpdateMode.OnPropertyChanged);
            txtPICName.DataBindings.Add("Text", model, "PICName", false, DataSourceUpdateMode.OnPropertyChanged);
            txtUsingWeight.DataBindings.Add("Text", model, "UsingWeight", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0");
            txtInputWeight.DataBindings.Add("Text", model, "InputWeight", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0");
            txtRewindWeight.DataBindings.Add("Text", model, "RewindWeight", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0");
            txtOutputWeight.DataBindings.Add("Text", model, "OutputWeight", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0");
            txtBT.DataBindings.Add("Text", model, "BT", false, DataSourceUpdateMode.OnPropertyChanged);
            txtLossWeight.DataBindings.Add("Text", model, "LossWeight", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0");
            txtYield.DataBindings.Add("Text", model, "Yield", true, DataSourceUpdateMode.OnPropertyChanged, 1, "##0.00");
            txtTotalMaterialAmount.DataBindings.Add("Text", model, "TotalMaterialAmount", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0.00");
            txtTotalWidth.DataBindings.Add("Text", model, "TotalWidth", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,###,##0.00");

            #endregion Binding data to TextBox objects.

            #region Binding data to ComboBox objects.

            cmbProcessLine.DataSource = model.Resources.ToList();
            cmbProcessLine.DisplayMember = "ResourceDescription";
            cmbProcessLine.ValueMember = "ResourceID";
            cmbProcessLine.DataBindings.Add("SelectedValue", model, "ProcessLineId", false, DataSourceUpdateMode.OnPropertyChanged);

            cmbOrderType.DataSource = model.OrderTypeList.ToList();
            cmbOrderType.DisplayMember = "CodeDesc";
            cmbOrderType.ValueMember = "CodeID";
            cmbOrderType.DataBindings.Add("SelectedValue", model, "OrderType", false, DataSourceUpdateMode.OnPropertyChanged);

            cmbPossession.DataSource = model.Possessions.ToList();
            cmbPossession.DisplayMember = "CodeDesc";
            cmbPossession.ValueMember = "CodeID";
            cmbPossession.DataBindings.Add("SelectedValue", model, "Possession", false, DataSourceUpdateMode.OnPropertyChanged);

            #endregion Binding data to ComboBox objects.

            #region Binding data to CheckBox objects.

            chkPackingPlan.DataBindings.Add("Checked", model, "PackingPlan", false, DataSourceUpdateMode.OnPropertyChanged);
            chkLVTrim.DataBindings.Add("Checked", model, "LVTrim", false, DataSourceUpdateMode.OnPropertyChanged);

            #endregion Binding data to CheckBox objects.

            #region Set value to DatePicker

            dptIssueDate.Value = model.IssueDate;
            dptDueDate.Value = model.DueDate;

            #endregion Set value to DatePicker

            #region Automate set Yield status.

            if (model.CheckYeild(model.Yield))
            {
                //If work-order is Hold status. But yield value is OK and then system will be automatic unlock holding.
                if (model.Completed == 2)
                    model.Completed = Convert.ToInt32(_repo.UnlockHold(HeaderContent.WorkOrderID));
            }
            else
            {
                txtYield.BackColor = Color.Yellow;
            }

            #endregion Automate set Yield status.

            #region Lock object can be modify depend on the Cutting Line and Materials.

            if (model.CuttingDesign.ToList().Count > 0 || model.Materials.ToList().Count > 0)
            {
                cmbProcessLine.Enabled = false;
                cmbOrderType.Enabled = false;
                cmbPossession.Enabled = false;
            }
            else
            {
                cmbOrderType.Enabled = true;
                cmbProcessLine.Enabled = true;
                cmbPossession.Enabled = true;
            }

            #endregion Lock object can be modify depend on the Cutting Line and Materials.

            #region Lock object can be modify depend on the Complete status.

            if (model.Completed == 1)
            {   //Green color.
                butConfirm.BackColor = Color.FromArgb(161, 205, 95);
                dptIssueDate.Enabled = false;
                dptDueDate.Enabled = false;
                //txtProcessStep.ReadOnly = true;
                chkPackingPlan.Enabled = false;
                chkLVTrim.Enabled = false;

                //Set visible properties to status buttons.
                butConfirm.Visible = Convert.ToBoolean(model.Completed);
                butSimulate.Visible = Convert.ToBoolean(model.SimulateFlag);
                butGenSN.Visible = Convert.ToBoolean(model.Completed);
            }
            else if (model.Completed == 0)
            {
                dptIssueDate.Enabled = true;
                dptDueDate.Enabled = true;
                //txtProcessStep.ReadOnly = false;
                chkPackingPlan.Enabled = true;
                chkLVTrim.Enabled = true;

                //Set visible properties to status buttons.
                butConfirm.Visible = Convert.ToBoolean(model.Completed);
                butSimulate.Visible = Convert.ToBoolean(model.SimulateFlag);
                butGenSN.Visible = Convert.ToBoolean(model.Completed);
            }
            else if (model.Completed == 2)
            {
                butConfirm.Visible = true;
                butSimulate.Visible = true;
                butConfirm.BackColor = Color.Red;
            }

            #endregion Lock object can be modify depend on the Complete status.

            //Set text properties to status buttons.
            butConfirm.Text = model.CompletedStr;
            butSimulate.Text = model.SimulateFlagStr;
            butGenSN.Text = model.GenSerialFlagStr.Replace("_", " ");
        }
Example #29
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="model"></param>
 public void CalculationHeader(PlanningHeadModel model)
 {
     SumUsingWeight(model.Materials);
     SumInputWeight(model);
     SumRewindWeight(model);
     SumOutputWeight(model);
     SumLossWeight(model);
     SumYeild(model);
     SumProductWidth(model);
 }
Example #30
0
        private void tbutSave_Click(object sender, EventArgs e)
        {
            string objectValid;
            string messageValid;

            RecheckCuttingByRow();
            SetHeadContent(HeaderContent);
            ListCuttingGrid(HeaderContent.CuttingDesign);

            IEnumerable<MaterialModel> model = new List<MaterialModel>();
            HeaderContent.ProcessLine = _reRes.GetByID(epiSession.PlantID, HeaderContent.ProcessLineId);

            var result = HeaderContent.ValidateToSave(HeaderContent, out objectValid, out messageValid);

            if (!result)
            {
                MessageBox.Show(messageValid, "Validate data error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                if (HeaderContent.ProcessLine.ResourceGrpID == "L" && HeaderContent.SimulateFlag == 1 && HeaderContent.Completed == 0 && HeaderContent.CheckYeild(HeaderContent.Yield))
                {
                    DialogResult diaResult = MessageBox.Show("This Order already simulated. Do you want to confirm.", "Question.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (diaResult == DialogResult.Yes)
                    {
                        HeaderContent.Completed = 1;
                    }
                }

                HeaderContent.OperationState = 1;
                HeaderContent = _repo.Save(epiSession, HeaderContent);
            }

            //Validate completed.
            HeaderContent.Saved();
            SetHeadContent(HeaderContent);
            SetFormState();

            //ListCuttingGrid need final step only.
            ListCuttingGrid(HeaderContent.CuttingDesign);
        }