Example #1
0
 public PackingOrder(SessionInfo _session = null, PackingOrderModel model = null)
 {
     InitializeComponent();
     epiSession = _session;
     this._repo = new PackingOrderRepo();
     this.HeaderContent = new PackingOrderModel();
 }
Example #2
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 #3
0
        private void BindingContentsHeader(PackingOrderModel model)
        {
            ClearBindingContensHead();
            txtWorkOrderNum.DataBindings.Add("Text", model, "WorkOrderNum", false, DataSourceUpdateMode.OnPropertyChanged);
            txtRemark.DataBindings.Add("Text", model, "Remark", false, DataSourceUpdateMode.OnPropertyChanged);

            //Set value to DatePicker
            //dptIssueDate.Value = model.IssueDate;
            //dptDueDate.Value = model.DueDate;
        }
Example #4
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            HeaderContent = _repo.GetPackOrderByID(HeaderContent.WorkOrderId);

            ReportClass rptH = new ReportClass();
            dsPlanning ds = new dsPlanning();
            string outPath = Application.StartupPath + string.Format(@"\\Out\\{0}.pdf", HeaderContent.WorkOrderNum);
            rptH.FileName = Application.StartupPath + "\\Reports\\Planning\\PackingOrder.rpt";
            ds.PackingOrderHead.AddPackingOrderHeadRow(HeaderContent.Id, HeaderContent.WorkOrderId, HeaderContent.WorkOrderNum
                                          , HeaderContent.DueDate, HeaderContent.IssueDate, HeaderContent.PackOrderNum
                                          , HeaderContent.CompleteFlag, HeaderContent.Remark);
            foreach (var p in HeaderContent.PackStyles)
            {
                ds.PackStyleLines.AddPackStyleLinesRow(p.HeadLineID, p.Id, p.CustId, p.CustomerName, p.ThickMin, p.ThickMax
                                                     , p.WidthMin, p.WidthMax, p.StyleCode, p.Remarks);

                foreach (var k in HeaderContent.SkidPacks.Where(i => i.PackStyleId == p.Id))
                {
                    ds.SkidPackingDesign.AddSkidPackingDesignRow(k.PackStyleId, k.Seq, k.SkidNumber, k.Description, k.Id);
                    foreach (var s in HeaderContent.SerialLines.Where(i => i.PackStyleId == p.Id && i.PackingDesignId == k.Id))
                    {
                        ds.SerialsByPackingStyle.AddSerialsByPackingStyleRow(s.PackStyleId, s.SerialNo, s.Thick, s.Width, s.Length, s.PackingDesignId);
                    }
                }
            }
            rptH.Load();
            ds.AcceptChanges();
            rptH.SetDataSource(ds);
            rptH.Refresh();
            rptH.ExportToDisk(ExportFormatType.PortableDocFormat, outPath);
            OpenPdfFile(outPath);
        }
Example #5
0
 private void tlbClear_Click(object sender, EventArgs e)
 {
     HeaderContent = new PackingOrderModel();
     BindingContentsHeader(HeaderContent);
 }
Example #6
0
        private void tbutSave_Click(object sender, EventArgs e)
        {
            PackingOrderModel model = new PackingOrderModel();
            model.WorkOrderId = HeaderContent.WorkOrderId;
            model.Remark = txtRemark.Text.ToString();
            model.CompleteFlag = (HeaderContent.SerialLines.Where(i => i.DesignedPack == false).ToList().Count > 0) ? 0 : 1;
            if (_repo.SavePackOrder(epiSession, model, out HeaderContent))
            {
                PackStyleOrderModel styles = new PackStyleOrderModel();
                styles.HeadLineID = HeaderContent.Id;
                styles.StyleCode = dgvPackStyle.CurrentRow.Cells["packstyle"].Value.ToString();
                styles.Remarks = txtPackingRemark.Text.ToString();

                if (_repo.SavePackStyles(epiSession, null, styles))
                {
                    MessageBox.Show("Save complete.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    HeaderContent.PackStyles = _repo.GetPackStyleByPackOrder(HeaderContent.WorkOrderId).ToList();
                }
            }
        }
Example #7
0
        public bool SavePackOrder(SessionInfo _session, PackingOrderModel model, out PackingOrderModel resultRow)
        {
            bool isSuccess = false;
            resultRow = null;
            string sql = string.Format(@"IF NOT EXISTS
                                        (
	                                        SELECT * FROM ucc_pkg_Header (NOLOCK)
	                                        WHERE WorkOrderID = {2}
                                        )
	                                        BEGIN
		                                        INSERT INTO ucc_pkg_Header
				                                           (Plant
				                                           ,PackOrderNum
				                                           ,WorkOrderID
				                                           ,Remarks
				                                           ,CompleteFlag
				                                           ,CreationDate
				                                           ,LastUpdateDate
				                                           ,CreatedBy
				                                           ,UpdatedBy)
			                                         VALUES
				                                           (N'{0}' --<Plant, nvarchar(8),>
				                                           ,N'{1}' --<PackOrderNum, nvarchar(45),>
				                                           ,{2} --<WorkOrderID, bigint,>
				                                           ,N'{3}' --<Remarks, nvarchar(max),>
				                                           ,{4} --<CompleteFlag, int,>
				                                           ,GETDATE() --<CreationDate, datetime,>
				                                           ,GETDATE() --<LastUpdateDate, datetime,>
				                                           ,N'{5}' --<CreatedBy, nvarchar(45),>
				                                           ,N'{5}' --<UpdatedBy, nvarchar(45),>)
				                                           )
	                                        END
                                        ELSE
	                                        BEGIN
		                                        UPDATE ucc_pkg_Header
		                                           SET Remarks = N'{3}' --<Remarks, nvarchar(max),>
			                                          ,CompleteFlag = {4} --<CompleteFlag, int,>
			                                          ,LastUpdateDate = GETDATE() --<LastUpdateDate, datetime,>
			                                          ,UpdatedBy = N'{5}' --<UpdatedBy, nvarchar(45),>
		                                         WHERE WorkOrderID = {2}
	                                         END
                                        " + Environment.NewLine
                                         , _session.PlantID
                                         , model.PackOrderNum
                                         , model.WorkOrderId
                                         , model.Remark
                                         , model.CompleteFlag
                                         , _session.UserID);
            try
            {
                Repository.Instance.ExecuteWithTransaction(sql, "Update Planning");
                isSuccess = true;
                resultRow = GetPackOrderByID(model.WorkOrderId);
            }
            catch
            {
                isSuccess = false;
            }
            return isSuccess;
        }