private void frmSplitCutSheet_Load(object sender, EventArgs e) { using (var context = new TTI2Entities()) { TLCUT_CutSheet CS = context.TLCUT_CutSheet.Find(_CsPk); if (CS != null) { txtCutSheet.Text = CS.TLCutSH_No; var Detail = context.TLCUT_CutSheetDetail.Where(x => x.TLCutSHD_CutSheet_FK == CS.TLCutSH_Pk).ToList(); foreach (var Row in Detail) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = Row.TLCutSHD_Pk; dataGridView1.Rows[index].Cells[2].Value = false; var DyeBatchDetail = context.TLDYE_DyeBatchDetails.Find(Row.TLCutSHD_DyeBatchDet_FK); if (DyeBatchDetail != null) { dataGridView1.Rows[index].Cells[1].Value = DyeBatchDetail.DYEBD_Pk; dataGridView1.Rows[index].Cells[3].Value = context.TLKNI_GreigeProduction.Find(DyeBatchDetail.DYEBD_GreigeProduction_FK).GreigeP_PieceNo; } var DyeBatch = DyeBatchDetail.DYEBD_DyeBatch_FK; dataGridView1.Rows[index].Cells[4].Value = context.TLDYE_DyeBatch.Find(DyeBatch).DYEB_BatchNo; dataGridView1.Rows[index].Cells[5].Value = Row.TLCUTSHD_NettWeight; } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null) { using (var context = new TTI2Entities()) { TLCUT_CutSheet CS = context.TLCUT_CutSheet.Where(x => x.TLCutSH_No == txtCutSheet.Text).FirstOrDefault(); if (CS != null) { frmCMTView_Load(this, null); var CSR = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_CutSheet_FK == CS.TLCutSH_Pk).FirstOrDefault(); if (CSR != null) { if (!CSR.TLCUTSHR_Issued) { MessageBox.Show("This CutSheet is still in its respective Panel Store and is yet to be issued"); return; } txtStyle.Text = context.TLADM_Styles.Find(CSR.TLCUTSHR_Style_FK).Sty_Description; txtColour.Text = context.TLADM_Colours.Find(CSR.TLCUTSHR_Colour_FK).Col_Display; var SizeDetails = context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CSR.TLCUTSHR_Pk).ToList(); foreach (var SizeDetail in SizeDetails) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = context.TLADM_Sizes.Find(SizeDetail.TLCUTSHRD_Size_FK).SI_Description; dataGridView1.Rows[index].Cells[1].Value = SizeDetail.TLCUTSHRD_BundleQty; dataGridView1.Rows[index].Cells[2].Value = SizeDetail.TLCUTSHRD_BoxUnits; dataGridView1.Rows[index].Cells[3].Value = SizeDetail.TLCUTSHRD_BoxNumber; } var PID = context.TLCMT_PanelIssueDetail.Where(x => x.CMTPID_CutSheet_FK == CSR.TLCUTSHR_Pk).FirstOrDefault(); if (PID != null) { var PI = context.TLCMT_PanelIssue.Find(PID.CMTPID_PI_FK); if (PI != null) { txtTransferDate.Text = PI.CMTPI_Date.ToShortDateString(); txtTransnumber.Text = PI.CMTPI_Number.ToString(); txtPanelStore.Text = context.TLADM_Departments.Find(PI.CMTPI_Department_FK).Dep_Description; } } var LineIssue = context.TLCMT_LineIssue.Where(x => x.TLCMTLI_CutSheet_FK == CSR.TLCUTSHR_CutSheet_FK).FirstOrDefault(); if (LineIssue != null && LineIssue.TLCMTLI_IssuedToLine) { if (LineIssue.TLCMTLI_LineNo_FK != 0) { txtLineNo.Text = context.TLCMT_FactConfig.Find(LineIssue.TLCMTLI_LineNo_FK).TLCMTCFG_Description; } rbOnHold.Checked = LineIssue.TLCMTLI_OnHold; if (LineIssue.TLCMTLI_WorkCompleted) { var CompletedWork = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_CutSheet_FK == LineIssue.TLCMTLI_CutSheet_FK).FirstOrDefault(); if (CompletedWork != null && CompletedWork.TLCMTWC_BoxReceiptedWhse) { if (CompletedWork.TLCMTWC_ToWhse_FK != 0) { txtToWareHouse.Text = context.TLADM_WhseStore.Find(CompletedWork.TLCMTWC_ToWhse_FK).WhStore_Description; } else { txtToWareHouse.Text = "Unknown Warehouse"; } if (CompletedWork.TLCMTWC_Picked && CompletedWork.TLCMTWC_PickList_FK != null) { var BoxSelected = context.TLCSV_BoxSelected.Find(CompletedWork.TLCMTWC_PickList_FK); if (BoxSelected != null) { DateTime dt = new DateTime(); if (BoxSelected.TLCSV_DespatchedDate != null) { dt = (DateTime)BoxSelected.TLCSV_DespatchedDate; txtDeliveryNoteDate.Text = dt.ToString("dd/MM/yyyy"); } if (BoxSelected.TLCSV_PLTransDate != null) { dt = (DateTime)BoxSelected.TLCSV_PLTransDate; txtPickingListDate.Text = dt.ToString("dd/MM/yyyy"); } txtPickingList.Text = BoxSelected.TLCSV_PLDetails; txtDeliveryNote.Text = BoxSelected.TLCSV_DNDeails; } } } } } } } else { MessageBox.Show("No Cutsheet matching number entered found in the database"); } } } }
private void cmboCMTLine_SelectedIndexChanged(object sender, EventArgs e) { ComboBox oCmbo = sender as ComboBox; if (oCmbo != null && formloaded) { var selected = (int)oCmbo.SelectedValue; if (selected != 0) { formloaded = false; dataGridView1.Rows.Clear(); dataGridView2.Rows.Clear(); formloaded = true; txtDifference.Text = "0"; txtTotAGrade.Text = "0"; txtTotBGrade.Text = "0"; txtTPIssued.Text = "0"; txtTPPanels.Text = "0"; txtNoBoxes.Text = "0"; using (var context = new TTI2Entities()) { var LI = context.TLCMT_LineIssue.Find(selected); if (LI != null) { CS = context.TLCUT_CutSheet.Find(LI.TLCMTLI_CutSheet_FK); if (CS != null) { CSR = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_CutSheet_FK == CS.TLCutSH_Pk).FirstOrDefault(); if (CSR == null) { MessageBox.Show("Technical error encounted. Qoute number 1400"); frmCompleted_Load(this, null); return; } //------------------------------------------------------- //We have to check that all the BFA Data has been recorded //-------------------------------------------------------------------- int BFACount = context.TLCMT_AuditMeasureRecorded.Where(x => x.TLBFAR_CutSheet_FK == CS.TLCutSH_Pk).Count(); if (BFACount == 0) { MessageBox.Show("Please enter the BFA Audit information" + Environment.NewLine + "using the facility provided"); frmCompleted_Load(this, null); return; } //------------------------------------------------------ // We have to now //========================================= var ExpectUnits = context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == CS.TLCutSH_Pk).ToList(); foreach (var Unit in ExpectUnits) { TLADM_Sizes Size = new TLADM_Sizes(); Size.SI_Description = context.TLADM_Sizes.Find(Unit.TLCUTE_Size_FK).SI_Description; Size.SI_id = Unit.TLCUTE_Size_FK; oCmboA.Items.Add(Size); } //--------------------------------------------------------------- //If expected units data not available, for what ever reason, go back to the original order //========================================================================== if (oCmboA.Items.Count == 0) { var CutSheetDetail = context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CSR.TLCUTSHR_Pk).GroupBy(x => x.TLCUTSHRD_Size_FK); foreach (var Grouped in CutSheetDetail) { var Size_Pk = Grouped.FirstOrDefault().TLCUTSHRD_Size_FK; TLADM_Sizes Size = new TLADM_Sizes(); Size.SI_Description = context.TLADM_Sizes.Find(Size_Pk).SI_Description; Size.SI_id = Size_Pk; oCmboA.Items.Add(Size); } } oCmboA.DisplayMember = "SI_Description"; oCmboA.ValueMember = "SI_Id"; txtCutSheet.Text = CS.TLCutSH_No; var DB = context.TLDYE_DyeBatch.Find(CS.TLCutSH_DyeBatch_FK); if (DB != null) { var DO = context.TLDYE_DyeOrder.Find(DB.DYEB_DyeOrder_FK); if (DO != null) { var dt = core.FirstDateOfWeek(DO.TLDYO_OrderDate.Year, DO.TLDYO_CMTReqWeek); txtDateRequired.Text = dt.AddDays(5).ToString("dd/MM/yyyy"); } } Styles = context.TLADM_Styles.Find(CS.TLCutSH_Styles_FK); Colours = context.TLADM_Colours.Find(CS.TLCutSH_Colour_FK); StyleGrades = context.TLADM_StylesGrades.Where(x => x.TLSG_Style_Fk == CS.TLCutSH_Styles_FK).FirstOrDefault(); var Existing = context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CSR.TLCUTSHR_Pk).ToList(); /* if (Existing != null) * { * Sizes = context.TLADM_Sizes.Find(Existing.FirstOrDefault().TLCUTSHRD_Size_FK); * }*/ foreach (var row in Existing) { var index = dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = row.TLCUTSHRD_BoxNumber; this.dataGridView1.Rows[index].Cells[1].Value = Styles.Sty_Description; this.dataGridView1.Rows[index].Cells[2].Value = Colours.Col_Display; this.dataGridView1.Rows[index].Cells[3].Value = row.TLCUTSHRD_BoxUnits; } txtTPIssued.Text = Existing.Sum(x => x.TLCUTSHRD_BoxUnits).ToString(); // 0 Box No datagridView2 // 1 Code datagridView2 // 2 Size datagridView2 // 3 Grade datagridView2 // 4 Qty datagridView2 // 5 Weight dataGridView2 // 6 FK CutSheetSheet Receipt Detail datagridView2 formloaded = false; foreach (var row in Existing) { var index = dataGridView2.Rows.Add(); this.dataGridView2.Rows[index].Cells[0].Value = row.TLCUTSHRD_BoxNumber; this.dataGridView2.Rows[index].Cells[1].Value = string.Empty; this.dataGridView2.Rows[index].Cells[2].Value = null; // string.Empty; this.dataGridView2.Rows[index].Cells[3].Value = string.Empty; this.dataGridView2.Rows[index].Cells[4].Value = 0; this.dataGridView2.Rows[index].Cells[5].Value = 0.00M; this.dataGridView2.Rows[index].Cells[6].Value = row.TLCUTSHRD_Pk; } formloaded = true; if (this.dataGridView2.Rows.Count != 0) { this.dataGridView2.CurrentCell = this.dataGridView2.Rows[0].Cells[1]; this.dataGridView2.BeginEdit(true); } } } } } } }
private void cmboCutSheet_SelectedIndexChanged(object sender, EventArgs e) { ComboBox oCmbo = sender as ComboBox; IList <TLADM_Sizes> sz = new List <TLADM_Sizes>(); int NoOfUnits = 0; if (oCmbo != null && formloaded) { var selected = (TLCUT_CutSheet)oCmbo.SelectedItem; if (selected != null) { dataGridView1.Rows.Clear(); dataGridView2.Rows.Clear(); cutSheet = selected; txtBundles.Enabled = true; txtBundles.Text = "0"; rtbNotes.Text = selected.TLCutSH_Notes; using (var context = new TTI2Entities()) { var Sizes = core.ExtrapNumber(selected.TLCutSH_Size_PN, context.TLADM_Sizes.Count()); Sizes.Sort(); foreach (var Size in Sizes) { var sze = context.TLADM_Sizes.Where(x => x.SI_PowerN == Size).FirstOrDefault(); if (sze != null) { sz.Add(sze); } } var DB = context.TLDYE_DyeBatch.Find(selected.TLCutSH_DyeBatch_FK); if (DB != null) { txtDyeBatch.Text = DB.DYEB_BatchNo; var DO = context.TLDYE_DyeOrder.Find(DB.DYEB_DyeOrder_FK); if (DO != null) { NoOfUnits = context.TLDYE_DyeOrderDetails.Where(x => x.TLDYOD_DyeOrder_Fk == DO.TLDYO_Pk && x.TLDYOD_BodyOrTrim).FirstOrDefault().TLDYOD_Units; txtCustomer.Text = context.TLADM_CustomerFile.Find(DO.TLDYO_Customer_FK).Cust_Description; txtColour.Text = context.TLADM_Colours.Find(cutSheet.TLCutSH_Colour_FK).Col_Description; txtDateOrdered.Text = DO.TLDYO_OrderDate.ToString("dd/MM/yyyy"); DateTime dt = core.FirstDateOfWeek(DO.TLDYO_OrderDate.Year, DO.TLDYO_CutReqWeek); txtDateRequired.Text = dt.AddDays(5).ToString("dd/MM/yyyy"); var DBDetails = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == DB.DYEB_Pk).ToList(); foreach (var row in DBDetails) { if (row.DYEBD_BodyTrim) { txtBody.Text = context.TLADM_Griege.Find(row.DYEBD_QualityKey).TLGreige_Description; } else { if (String.IsNullOrEmpty(txtTrim1.Text)) { txtTrim1.Text = context.TLADM_Griege.Find(row.DYEBD_QualityKey).TLGreige_Description; } else if (String.IsNullOrEmpty(txtTrim2.Text)) { txtTrim2.Text = context.TLADM_Griege.Find(row.DYEBD_QualityKey).TLGreige_Description; } } } var EUnits = (from EUnitsx in context.TLCUT_ExpectedUnits join xSizes in context.TLADM_Sizes on EUnitsx.TLCUTE_Size_FK equals xSizes.SI_id where EUnitsx.TLCUTE_CutSheet_FK == cutSheet.TLCutSH_Pk orderby xSizes.SI_DisplayOrder select EUnitsx).ToList(); // var EUnits = context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == cutSheet.TLCutSH_Pk).ToList(); foreach (var row in EUnits) { var index = dataGridView2.Rows.Add(); dataGridView2.Rows[index].Cells[0].Value = row.TLCUTE_Size_FK; dataGridView2.Rows[index].Cells[1].Value = context.TLADM_Sizes.Find(row.TLCUTE_Size_FK).SI_Description; dataGridView2.Rows[index].Cells[2].Value = row.TLCUTE_NoofGarments; dataGridView2.Rows[index].Cells[3].Value = 0; dataGridView2.Rows[index].Cells[4].Value = 0.00M; } } } //------------------------------------------------------------ TLCUT_CutSheetReceipt CSR = new TLCUT_CutSheetReceipt(); CSR = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_CutSheet_FK == cutSheet.TLCutSH_Pk).FirstOrDefault(); if (CSR != null) { cmboMachines.SelectedValue = CSR.TLCUTSHR_Machine_FK; dtpTransDate.Value = CSR.TLCUTSHR_Date; txtBundles.Text = CSR.TLCUTSHR_NoOfBundles.ToString(); IList <TLCUT_CutSheetReceiptDetail> CSRD = new List <TLCUT_CutSheetReceiptDetail>(); CSRD = context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CSR.TLCUTSHR_Pk).ToList(); if (CSRD != null) { foreach (var row in CSRD) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = row.TLCUTSHRD_Pk; dataGridView1.Rows[index].Cells[1].Value = row.TLCUTSHRD_Description; dataGridView1.Rows[index].Cells[2].Value = row.TLCUTSHRD_Size_FK; dataGridView1.Rows[index].Cells[3].Value = row.TLCUTSHRD_BundleQty; } DataGridViewCellEventArgs exx = new DataGridViewCellEventArgs(3, 1); try { // dataGridView1_CellLeave(dataGridView1, exx); } catch (Exception ex) { MessageBox.Show(ex.Message); } } TLCUT_CutSheetReceiptBoxes CSRB = new TLCUT_CutSheetReceiptBoxes(); CSRB = context.TLCUT_CutSheetReceiptBoxes.Where(x => x.TLCUTSHB_CutSheet_FK == CSR.TLCUTSHR_Pk).FirstOrDefault(); if (CSRB != null) { txtAdultBoxes.Text = CSRB.TLCUTSHB_AdultBoxes.ToString(); txtBinding.Text = CSRB.TLCUTSHB_Binding.ToString(); txtKidsBoxes.Text = CSRB.TLCUTSHB_KidBoxes.ToString(); txtRibbing.Text = CSRB.TLCUTSHB_Ribbing.ToString(); } } } oCmboA.ValueMember = "SI_Id"; oCmboA.DisplayMember = "SI_Description"; oCmboA.DataSource = sz; } } }
private void btnSearch_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && FormLoaded) { using (var context = new TTI2Entities()) { if (txtCutSheet.Text.Length != 0) { string csNumber = txtCutSheet.Text; TLCUT_CutSheet cs = context.TLCUT_CutSheet.Where(x => x.TLCutSH_No == csNumber).FirstOrDefault(); if (cs == null) { MessageBox.Show("No records pertaining to selection made"); return; } dataGridView1.Rows.Clear(); var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = cs.TLCutSH_Pk; dataGridView1.Rows[index].Cells[1].Value = false; dataGridView1.Rows[index].Cells[2].Value = false; dataGridView1.Rows[index].Cells[3].Value = cs.TLCutSH_No; dataGridView1.Rows[index].Cells[4].Value = context.TLDYE_DyeBatch.Find(cs.TLCutSH_DyeBatch_FK).DYEB_BatchNo; dataGridView1.Rows[index].Cells[5].Value = cs.TLCutSH_Date.ToShortDateString(); dataGridView1.Rows[index].Cells[6].Value = context.TLADM_Griege.Find(cs.TLCutSH_Quality_FK).TLGreige_Description; dataGridView1.Rows[index].Cells[7].Value = context.TLADM_Colours.Find(cs.TLCutSH_Colour_FK).Col_Display; if (cs.TLCutSH_Size_FK != 0) { dataGridView1.Rows[index].Cells[8].Value = context.TLADM_Sizes.Find(cs.TLCutSH_Size_FK).SI_Description; } dataGridView1.Rows[index].Cells[9].Value = context.TLADM_Styles.Find(cs.TLCutSH_Styles_FK).Sty_Description; dataGridView1.Rows[index].Cells[10].Value = context.TLADM_CustomerFile.Find(cs.TLCutSH_Customer_FK).Cust_Description; } else if (txtDyeBatch.Text.Length != 0) { string DbDetail = txtDyeBatch.Text; TLDYE_DyeBatch db = context.TLDYE_DyeBatch.Where(x => x.DYEB_BatchNo == DbDetail).FirstOrDefault(); if (db == null) { MessageBox.Show("No records pertaining to selection made"); return; } var cs = context.TLCUT_CutSheet.Where(x => x.TLCutSH_DyeBatch_FK == db.DYEB_Pk).ToList(); if (cs.Count == 0) { MessageBox.Show("No records pertaining to selection made"); return; } dataGridView1.Rows.Clear(); foreach (var item in cs) { /* * var index = dataGridView1.Rows.Add(); * dataGridView1.Rows[index].Cells[0].Value = cs.TLCutSH_Pk; * dataGridView1.Rows[index].Cells[1].Value = false; * dataGridView1.Rows[index].Cells[2].Value = cs.TLCutSH_No; * dataGridView1.Rows[index].Cells[3].Value = context.TLDYE_DyeBatch.Find(cs.TLCutSH_DyeBatch_FK).DYEB_BatchNo; * dataGridView1.Rows[index].Cells[4].Value = cs.TLCutSH_Date.ToShortDateString(); * dataGridView1.Rows[index].Cells[5].Value = context.TLADM_Griege.Find(cs.TLCutSH_Quality_FK).TLGreige_Description; * dataGridView1.Rows[index].Cells[6].Value = context.TLADM_Colours.Find(cs.TLCutSH_Colour_FK).Col_Display; * if (cs.TLCutSH_Size_FK != 0) * dataGridView1.Rows[index].Cells[7].Value = context.TLADM_Sizes.Find(cs.TLCutSH_Size_FK).SI_Description; * dataGridView1.Rows[index].Cells[8].Value = context.TLADM_Styles.Find(cs.TLCutSH_Styles_FK).Sty_Description; * dataGridView1.Rows[index].Cells[9].Value = context.TLADM_CustomerFile.Find(cs.TLCutSH_Customer_FK).Cust_Description; */ } } } } }