//----------------------------------------------------------------------------------------------------- void SetUp() { formloaded = false; core = new Util(); txtGreigeQual.Text = string.Empty; InspectionBegin = false; using (var context = new TTI2Entities()) { _Grieg = context.TLADM_Griege.Where(x => !(bool)x.TLGriege_Discontinued).ToList(); cmbKnitOrder.DataSource = context.TLKNI_Order.Where(x => !x.KnitO_Closed).OrderBy(x => x.KnitO_OrderNumber).ToList(); cmbKnitOrder.ValueMember = "KnitO_Pk"; cmbKnitOrder.DisplayMember = "KnitO_OrderNumber"; cmbKnitOrder.SelectedValue = 0; var Depts = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Depts != null) { cmbInspector.DataSource = context.TLADM_MachineOperators.Where(X => X.MachOp_Department_FK == Depts.Dep_Id && X.MachOp_Inspector && !X.MachOp_Discontinued).ToList(); cmbInspector.ValueMember = "MachOp_Pk"; cmbInspector.DisplayMember = "MachOp_Description"; cmbInspector.SelectedValue = 0; var h2 = (DataGridViewTextBoxColumn)ColumnHeadings[0]; h2.HeaderText = "Key"; h2.Visible = false; h2.ValueType = typeof(int); dataGridView1.Columns.Add(h2); h2 = (DataGridViewTextBoxColumn)ColumnHeadings[1]; h2.HeaderText = "Piece No"; h2.ValueType = typeof(string); h2.ReadOnly = true; dataGridView1.Columns.Add(h2); h2 = (DataGridViewTextBoxColumn)ColumnHeadings[2]; h2.HeaderText = "Grade"; h2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; h2.ValueType = typeof(string); dataGridView1.Columns.Add(h2); h2 = (DataGridViewTextBoxColumn)ColumnHeadings[3]; h2.HeaderText = "Remarks"; h2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; h2.ValueType = typeof(string); dataGridView1.Columns.Add(h2); __QualityDefinitions = context.TLADM_QualityDefinition.Where(x => x.QD_ReportingDept_FK == Depts.Dep_Id).OrderBy(x => x.QD_ShortCode).ToList(); ColumnKeys = core.PopulateNumArray(__QualityDefinitions.Count, 0); ColumnGrades = core.PopulateArray(__QualityDefinitions.Count, false); ProductionSplit = core.PopulateArray(__QualityDefinitions.Count, false); foreach (var Definition in __QualityDefinitions) { foreach (var elementH in ColumnHeadings) { var ch = (DataGridViewTextBoxColumn)elementH; if (String.IsNullOrEmpty(ch.HeaderText)) { StringBuilder sb = new StringBuilder(); sb.Append(Definition.QD_ShortCode); sb.Append(Environment.NewLine); sb.Append(Definition.QD_Description); ch.HeaderText = sb.ToString(); ch.ValueType = typeof(int); ch.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns.Add(ch); ColumnKeys[-4 + ch.Index] = Definition.QD_Pk; ColumnGrades[-4 + ch.Index] = Definition.QD_GradeCol; ProductionSplit[-4 + ch.Index] = Definition.QD_SplitCol; break; } } } DataGridViewCheckBoxColumn h3 = (DataGridViewCheckBoxColumn)ColumnHeadings[-1 + ColumnHeadings.Length]; h3.HeaderText = "Inspected"; h3.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; h3.ValueType = typeof(Boolean); dataGridView1.Columns.Add(h3); h3 = (DataGridViewCheckBoxColumn)ColumnHeadings[-2 + ColumnHeadings.Length]; h3.HeaderText = "K / R"; h3.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; h3.ValueType = typeof(Boolean); dataGridView1.Columns.Add(h3); h3 = (DataGridViewCheckBoxColumn)ColumnHeadings[-3 + ColumnHeadings.Length]; h3.HeaderText = "White Only"; h3.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; h3.ValueType = typeof(Boolean); h3.Visible = false; dataGridView1.Columns.Add(h3); } } MandatorySelected = core.PopulateArray(MandatoryFields.Length, false); formloaded = true; }
private void button1_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var selected = (TLCSV_BoxSelected)cmboWareHouse.SelectedItem; if (selected == null) { MessageBox.Show("Please select a Delivery Note from the drop down box"); return; } var RecCount = dataGridView1.Rows.Cast <DataGridViewRow>().Where(x => (bool)x.Cells[1].Value == true).Count(); if (RecCount == 0) { MessageBox.Show("Please select a least one record to process"); return; } using (var context = new TTI2Entities()) { TLCSV_Movement move = new TLCSV_Movement(); move.TLMV_FromCMT_Fk = selected.TLCSV_From_FK; move.TLMV_ToWhse_FK = selected.TLCSV_To_FK; move.TLMV_TransactionNumber = 1; move.TLMV_TransDate = dtpTransDate.Value; move.TLMV_BoxSelected_FK = selected.TLCSV_Pk; move.TLMV_NoOfBoxes = 0; move.TLMV_BoxedQty = 0; move.TLMV_OriginalNumber = selected.TLCSV_DNDeails; var moveDetails = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_DepatchedList_FK == selected.TLCSV_Pk).ToList(); if (moveDetails != null) { move.TLMV_NoOfBoxes = moveDetails.Count; move.TLMV_BoxedQty = moveDetails.Sum(x => x.TLCMTWC_Qty); } context.TLCSV_Movement.Add(move); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow row in dataGridView1.Rows) { bool isChecked = (bool)row.Cells[1].Value; if (isChecked) { TLCSV_StockOnHand OnHand = new TLCSV_StockOnHand(); OnHand.TLSOH_WareHouse_FK = selected.TLCSV_To_FK; OnHand.TLSOH_CMT_FK = (int)row.Cells[0].Value; OnHand.TLSOH_BoxSelected_FK = selected.TLCSV_Pk; OnHand.TLSOH_Movement_FK = move.TLMV_Pk; OnHand.TLSOH_DateIntoStock = dtpTransDate.Value; TLCMT_CompletedWork comWork = context.TLCMT_CompletedWork.Find((int)row.Cells[0].Value); if (comWork != null) { comWork.TLCMTWC_BoxReceiptedWhse = true; var Already = context.TLCSV_StockOnHand.Where(x => x.TLSOH_BoxNumber == comWork.TLCMTWC_BoxNumber).FirstOrDefault(); if (Already != null) { continue; } OnHand.TLSOH_BoxedQty = comWork.TLCMTWC_Qty; OnHand.TLSOH_Style_FK = comWork.TLCMTWC_Style_FK; OnHand.TLSOH_Colour_FK = comWork.TLCMTWC_Colour_FK; OnHand.TLSOH_Size_FK = comWork.TLCMTWC_Size_FK; OnHand.TLSOH_BoxNumber = comWork.TLCMTWC_BoxNumber; OnHand.TLSOH_Weight = comWork.TLCMTWC_Weight; OnHand.TLSOH_PastelNumber = comWork.TLCMTWC_PastelNumber; OnHand.TLSOH_CutSheet_FK = comWork.TLCMTWC_CutSheet_FK; if (comWork.TLCMTWC_PastelNumber.Length == 0) { OnHand.TLSOH_PastelNumber = context.TLADM_Styles.Find(comWork.TLCMTWC_Style_FK).Sty_PastelNo.ToString(); OnHand.TLSOH_PastelNumber += context.TLADM_Colours.Find(comWork.TLCMTWC_Colour_FK).Col_FinishedCode; OnHand.TLSOH_PastelNumber += "NG"; OnHand.TLSOH_PastelNumber += context.TLADM_Sizes.Find(comWork.TLCMTWC_Size_FK).SI_PastelNo; } OnHand.TLSOH_BoxType = comWork.TLCMTWC_BoxType_FK; OnHand.TLSOH_Grade = comWork.TLCMTWC_Grade; if (!comWork.TLCMTWC_Grade.Contains("A")) { var Assoc = context.TLADM_WareHouseAssociation.Where(X => X.TLWA_PrimaryWareHouse == selected.TLCSV_To_FK).FirstOrDefault(); if (Assoc != null) { OnHand.TLSOH_WareHouse_FK = (int)Assoc.TLWA_SecondaryWareHouse; } } else { OnHand.TLSOH_Is_A = true; } } context.TLCSV_StockOnHand.Add(OnHand); } } var Existing = context.TLCSV_BoxSelected.Where(x => x.TLCSV_DNTransNumber == selected.TLCSV_DNTransNumber).ToList(); foreach (var row in Existing) { TLCSV_BoxSelected Box = new TLCSV_BoxSelected(); Box = context.TLCSV_BoxSelected.Find(row.TLCSV_Pk); if (Box != null) { Box.TLCSV_Receipted = true; Box.TLCSV_DateReceipted = dtpTransDate.Value; } } try { context.SaveChanges(); MessageBox.Show("Data saved successfully to database"); dataGridView1.Rows.Clear(); cmboWareHouse.DataSource = null; cmboWareHouse.DataSource = context.TLCSV_BoxSelected.Where(x => !x.TLCSV_Receipted).GroupBy(g => new { g.TLCSV_DNTransNumber }).Select(s => s.FirstOrDefault()).ToList(); cmboWareHouse.ValueMember = "TLCSV_Pk"; cmboWareHouse.DisplayMember = "TLCSV_DNDeails"; cmboWareHouse.SelectedValue = -1; frmCSViewRep vRep = new frmCSViewRep(3, selected.TLCSV_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } } }
private void cmboBatchNumber_SelectedIndexChanged(object sender, EventArgs e) { ComboBox oCmbo = sender as ComboBox; if (oCmbo != null && FormLoaded) { var selected = (TLDYE_DyeBatch)cmboBatchNumber.SelectedItem; if (selected != null) { fieldSelected = new List <DATA>(); dataGridView1.Rows.Clear(); using (var context = new TTI2Entities()) { var DO = context.TLDYE_DyeOrder.Find(selected.DYEB_DyeOrder_FK); if (DO != null) { txtDyeOrder.Text = DO.TLDYO_DyeOrderNum; var Cust = context.TLADM_CustomerFile.Find(DO.TLDYO_Customer_FK); if (Cust != null) { txtCustomerDetails.Text = Cust.Cust_Description; } } var Colour = context.TLADM_Colours.Find(selected.DYEB_Colour_FK); if (Colour != null) { txtColour.Text = Colour.Col_Display; } var Existing = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == selected.DYEB_Pk && x.DYEBO_Rejected).ToList(); foreach (var row in Existing) { if (row.DYEBO_QAApproved) { continue; } var index = dataGridView1.Rows.Add(); var GP = context.TLKNI_GreigeProduction.Find(row.DYEBD_GreigeProduction_FK); if (GP != null) { dataGridView1.Rows[index].Cells[0].Value = row.DYEBD_Pk; dataGridView1.Rows[index].Cells[1].Value = GP.GreigeP_PieceNo; var Qual = context.TLADM_Griege.Find(GP.GreigeP_Greige_Fk); if (Qual != null) { dataGridView1.Rows[index].Cells[2].Value = Qual.TLGreige_Description; } dataGridView1.Rows[index].Cells[4].Value = row.DYEBD_GreigeProduction_Weight; dataGridView1.Rows[index].Cells[5].Value = row.DYEBO_Nett; dataGridView1.Rows[index].Cells[6].Value = row.DYEBO_QAApproved; } } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; int RecCount = 0; int LastNumberUsed = 0; TLADM_Suppliers CommissionCust; TLKNI_YarnTransaction yarnT; TLKNI_YarnTransactionDetails yarnTD; TLADM_TranactionType TranType = null; TLKNI_YarnOrderPallets PalletStore; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandFieldsSelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } if (dataGridView1.RowCount == 0) { MessageBox.Show("Please enter a least one row in the datagrid"); return; } foreach (DataGridViewRow dr in dataGridView1.Rows) { var tst = fieldEntered.Find(x => x.rownumber == dr.Index); if (tst.fieldComplete == null) { continue; } var cnt = tst.fieldComplete.Where(x => x == false).Count(); if (cnt == MandatoryRows.Length) { continue; } cnt = tst.fieldComplete.Where(x => x == true).Count(); if (cnt != MandatoryRows.Length) { MessageBox.Show("Line " + (1 + dr.Index).ToString() + " Has not been completed correctly"); return; } } CommissionCust = (TLADM_Suppliers)cmbCommissionCustomers.SelectedItem; using (var context = new TTI2Entities()) { yarnT = new TLKNI_YarnTransaction(); yarnT.KnitY_TransactionDate = dtpDateReceived.Value; yarnT.KnitY_Customer_FK = CommissionCust.Sup_Pk; yarnT.KnitY_Notes = rtbComments.Text; yarnT.KnitY_TransactionDoc = txtCustomerDoc.Text; yarnT.KnitY_ThirdParty = true; var LastNumber = context.TLADM_LastNumberUsed.Find(2); if (LastNumber != null) { LastNumberUsed = LastNumber.col2; yarnT.KnitY_GRNNumber = LastNumberUsed; LastNumber.col2 += 1; } var YarnLastNumber = context.TLADM_LastNumberUsed.Find(1); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); if (Dept != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 200).FirstOrDefault(); } try { context.TLKNI_YarnTransaction.Add(yarnT); context.SaveChanges(); StringBuilder sb = null; int Counter = 0; foreach (DataGridViewRow dr in dataGridView1.Rows) { var tst = fieldEntered.Find(x => x.rownumber == dr.Index); if (tst.fieldComplete == null) { continue; } var cnt = tst.fieldComplete.Where(x => x == false).Count(); if (cnt == MandatoryRows.Count()) { continue; } var PalletNo = (int)dr.Cells[0].Value; PalletStore = new TLKNI_YarnOrderPallets(); PalletStore.TLKNIOP_CommisionCust = false; sb = new StringBuilder(); sb.Append(YarnLastNumber.col6.ToString()); sb.Append(" - "); sb.Append((++Counter).ToString()); PalletStore.TLKNIOP_TLPalletNo = sb.ToString(); PalletStore.TLKNIOP_Cones = (int)dr.Cells[7].Value; PalletStore.TLKNIOP_DatePacked = dtpDateReceived.Value; PalletStore.TLKNIOP_Grade = string.Empty; PalletStore.TLKNIOP_GrossWeight = (decimal)dr.Cells[5].Value; PalletStore.TLKNIOP_TareWeight = 0.00M; PalletStore.TLKNIOP_NettWeight = (decimal)dr.Cells[6].Value; PalletStore.TLKNIOP_YarnType_FK = (int)dr.Cells[1].Value; PalletStore.TLKNIOP_PalletNo = PalletNo; PalletStore.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; PalletStore.TLKNIOP_NettWeightReserved = 0.00M; PalletStore.TLKNIOP_HeaderRecord_FK = yarnT.KnitY_Pk; PalletStore.TLKNIOP_ConesReserved = 0; context.TLKNI_YarnOrderPallets.Add(PalletStore); context.SaveChanges(); yarnTD = new TLKNI_YarnTransactionDetails(); yarnTD.KnitYD_KnitY_FK = yarnT.KnitY_Pk; yarnTD.KnitYD_YarnType_FK = (int)dr.Cells[1].Value; yarnTD.KnitYD_PalletNo_FK = PalletStore.TLKNIOP_Pk; yarnTD.KnitYD_GrossWeight = (decimal)dr.Cells[5].Value; yarnTD.KnitYD_NettWeight = (decimal)dr.Cells[6].Value; yarnTD.KnitYD_NoOfCones = (int)dr.Cells[7].Value; yarnTD.KnitYD_TransactionDate = dtpDateReceived.Value; yarnTD.KnitYD_RTS = false; yarnTD.KnitYD_TransactionNumber = LastNumberUsed; if (TranType != null) { yarnTD.KnitYD_TransactionType = TranType.TrxT_Pk; } yarnTD.KnitYD_RTS = false; context.TLKNI_YarnTransactionDetails.Add(yarnTD); RecCount += 1; } YarnLastNumber = context.TLADM_LastNumberUsed.Find(1); if (YarnLastNumber != null) { YarnLastNumber.col6 += 1; } context.SaveChanges(); formloaded = false; dataGridView1.Rows.Clear(); formloaded = true; MessageBox.Show("Records stored successfully to database"); frmKnitViewRep vRep = new frmKnitViewRep(3, yarnT.KnitY_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); SetUp(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
public DyeRepository() { _context = new TTI2Entities(); }
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 btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { int TotBGradeFaults = dataGridView3.Rows.Cast <DataGridViewRow>() .Sum(x => Convert.ToInt32(x.Cells[2].Value.ToString())); if (TotBGradeFaults != Convert.ToInt32(txtTotBGrade.Text)) { MessageBox.Show("Please enter the total number of B Grade faults"); return; } var BoxType = (TLADM_BoxTypes)cmboBoxType.SelectedItem; if (BoxType == null) { MessageBox.Show("Please select a box type from the facilities"); return; } var PanelIssue = (int)cmboCMTIssue.SelectedValue; if (PanelIssue == 0) { MessageBox.Show("Please select a panel issue document"); return; } int LineIssue = (int)cmboCMTLine.SelectedValue; if (LineIssue == 0) { MessageBox.Show("Please select a production line"); return; } using (var context = new TTI2Entities()) { var LI = context.TLCMT_LineIssue.Find(LineIssue); if (LI != null) { LI.TLCMTLI_WorkCompletedDate = dtpTransDate.Value; } foreach (DataGridViewRow row in dataGridView2.Rows) { TLCMT_CompletedWork comWork = new TLCMT_CompletedWork(); if (row.ErrorText.Length != 0) { continue; } if (row.Cells[0].Value == null) { continue; } if ((int)row.Cells[4].Value == 0) { continue; } comWork.TLCMTWC_LineIssue_FK = LineIssue; if (LI != null) { comWork.TLCMTWC_CMTFacility_FK = LI.TLCMTLI_CmtFacility_FK; LI.TLCMTLI_WorkCompleted = true; } comWork.TLCMTWC_PanelIssue_FK = PanelIssue; comWork.TLCMTWC_TransactionDate = dtpTransDate.Value; comWork.TLCMTWC_BoxNumber = row.Cells[0].Value.ToString(); comWork.TLCMTWC_PastelNumber = row.Cells[3].Value.ToString(); var Pk = (int)row.Cells[6].Value; if (Pk != 0) { var CSRD = context.TLCUT_CutSheetReceiptDetail.Find(Pk); if (CSRD != null) { if (CSRD.TLCUTSHRD_BoxType_FK != null) { comWork.TLCMTWC_BoxType_FK = (int)CSRD.TLCUTSHRD_BoxType_FK; } } } else { if (CS != null) { var CSRD = context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CS.TLCutSH_Pk).FirstOrDefault(); if (CSRD != null) { if (CSRD.TLCUTSHRD_BoxType_FK != null) { comWork.TLCMTWC_BoxType_FK = (int)CSRD.TLCUTSHRD_BoxType_FK; } } } } comWork.TLCMTWC_Grade = row.Cells[1].Value.ToString(); comWork.TLCMTWC_Qty = (int)row.Cells[4].Value; if (row.Cells[2].Value == null) { MessageBox.Show("Please select a size from the combo box in the grid"); return; } comWork.TLCMTWC_Size_FK = (int)row.Cells[2].Value; if (row.Cells[5].Value != null) { comWork.TLCMTWC_Weight = (decimal)row.Cells[5].Value; } else { comWork.TLCMTWC_Weight = 0; } if (CS != null) { comWork.TLCMTWC_CutSheet_FK = CS.TLCutSH_Pk; comWork.TLCMTWC_Colour_FK = CS.TLCutSH_Colour_FK; comWork.TLCMTWC_Style_FK = CS.TLCutSH_Styles_FK; } //BoxType Stored comWork.TLCMTWC_BoxType_FK = BoxType.TLADMBT_Pk; context.TLCMT_CompletedWork.Add(comWork); } foreach (DataGridViewRow rw in dataGridView3.Rows) { if ((int)rw.Cells[2].Value == 0) { continue; } TLCMT_ProductionFaults pf = new TLCMT_ProductionFaults(); pf.TLCMTPF_Fault_FK = (int)rw.Cells[0].Value; pf.TLCMTPF_PanelIssue_FK = PanelIssue; if (LI != null) { pf.TLCMTPF_LineIssue_FK = LI.TLCMTLI_LineNo_FK; } pf.TLCMTPF_Qty = (int)rw.Cells[2].Value; context.TLCMT_ProductionFaults.Add(pf); } //=============================================================== // Need to save statistics //================================================================== TLCMT_Statistics stats = new TLCMT_Statistics(); bool Add = true; stats = context.TLCMT_Statistics.Where(x => x.CMTS_PanelIssue_FK == PanelIssue).FirstOrDefault(); if (stats == null) { stats = new TLCMT_Statistics(); } else { Add = !Add; } stats.CMTS_PanelIssue_FK = PanelIssue; stats.CMTS_Total_A_Grades = Convert.ToInt32(txtTotAGrade.Text); stats.CMTS_Total_B_Grades = Convert.ToInt32(txtTotBGrade.Text); stats.CMTS_TotalPanelIssued = Convert.ToInt32(txtTPIssued.Text); stats.CMTS_Panels = Convert.ToInt32(txtTPPanels.Text); stats.CMTS_Transdate = dtpTransDate.Value; stats.CMTS_Total_Difference = Convert.ToInt32(txtDifference.Text); if (Add) { context.TLCMT_Statistics.Add(stats); } //===================================================================== try { context.SaveChanges(); MessageBox.Show("Records successfully saved to database"); formloaded = false; cmboCMTIssue.SelectedValue = -1; cmboCMTLine.SelectedValue = -1; formloaded = true; frmCompleted_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } } }
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; */ } } } } }
private void frmStockOnHand_Load(object sender, EventArgs e) { IList <TLADM_WhseStore> Whses = null; formloaded = false; repo = new Repository(); QueryParms = new CustomerServicesParameters(); if (_OptionNo == 1) { this.Text = "Stock quantities on hand"; } else { this.Text = "Boxes in stock"; } rbGradeA.Checked = true; using (var context = new TTI2Entities()) { if (_Ud == null || !_Ud._External) { Whses = context.TLADM_WhseStore.Where(x => x.WhStore_WhseOrStore && x.WhStore_GradeA).ToList(); } else { Whses = context.TLADM_WhseStore.Where(x => x.WhStore_WhseOrStore && x.WhStore_GradeA && !x.WhStore_RePack).ToList(); } foreach (var Whse in Whses) { comboWhses.Items.Add(new CustomerServices.CheckComboBoxItem(Whse.WhStore_Id, Whse.WhStore_Description, false)); } var Styles = context.TLADM_Styles.OrderBy(x => x.Sty_Description).ToList(); foreach (var Style in Styles) { comboStyles.Items.Add(new CustomerServices.CheckComboBoxItem(Style.Sty_Id, Style.Sty_Description, false)); } var Colours = context.TLADM_Colours.OrderBy(x => x.Col_Display).ToList(); foreach (var Colour in Colours) { comboColours.Items.Add(new CustomerServices.CheckComboBoxItem(Colour.Col_Id, Colour.Col_Display, false)); } var Sizes = context.TLADM_Sizes.Where(x => (bool)!x.SI_Discontinued).OrderBy(x => x.SI_DisplayOrder).ToList(); foreach (var Size in Sizes) { comboSizes.Items.Add(new CustomerServices.CheckComboBoxItem(Size.SI_id, Size.SI_Description, false)); } //-------------------------------------------------------- // wire up the check state changed event //-------------------------------------------------------------------------------------------------------- this.comboWhses.CheckStateChanged += new System.EventHandler(this.cmboWhses_CheckStateChanged); this.comboStyles.CheckStateChanged += new System.EventHandler(this.cmboStyles_CheckStateChanged); this.comboColours.CheckStateChanged += new System.EventHandler(this.cmboColours_CheckStateChanged); this.comboSizes.CheckStateChanged += new System.EventHandler(this.cmboSizes_CheckStateChanged); } formloaded = true; }
private void btnColour_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLDYE_RecipeDefinition rd; if (oBtn != null && formloaded) { if (txtProductCode.Text.Length <= 0) { MessageBox.Show("Please enter a code prior to selecting this option"); return; } var ComboQual = (TLADM_GreigeQuality)cmboGreigeQuality.SelectedItem; if (ComboQual == null) { MessageBox.Show("Please select a Greige quality group prior to selecting this option"); return; } if (txtProgramLoad.Text.Length <= 0) { MessageBox.Show("Please enter a program load prior to selecting this option"); return; } if (txtProgramVolume.Text.Length <= 0) { MessageBox.Show("please enter a program volume prior to selecting this option"); return; } if (lNew) { using (var context = new TTI2Entities()) { rd = new TLDYE_RecipeDefinition(); rd.TLDYE_DefineCode = txtProductCode.Text; rd.TLDYE_DefineDescription = txtProductCode.Text + " " + ComboQual.GQ_Description; rd.TLDYE_ProgramLoad = Convert.ToInt32(txtProgramLoad.Text); rd.TLDYE_LiquidLoad = Convert.ToInt32(txtProgramVolume.Text); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.InnerException.ToString()); } } } else { rd = (TLDYE_RecipeDefinition)cmboProductCodes.SelectedItem; } using (frmDyeColourDefinition YOAssigned = new frmDyeColourDefinition(rd.TLDYE_DefinePk)) { DialogResult dr = YOAssigned.ShowDialog(this); if (dr == DialogResult.OK) { } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { using (var context = new TTI2Entities()) { foreach (DataGridViewRow Row in dataGridView1.Rows) { if (radWorkComplete.Checked) { if (!(bool)Row.Cells[1].Value) { continue; } int Pk = (int)Row.Cells[0].Value; var CompletedWork = context.TLCMT_CompletedWork.Find(Pk); if (CompletedWork != null) { var Size = (int)Row.Cells[3].Value; if (Size != CompletedWork.TLCMTWC_Size_FK) { CompletedWork.TLCMTWC_Size_FK = (int)Row.Cells[3].Value; } var BoxedQty = (int)Row.Cells[4].Value; if (BoxedQty != CompletedWork.TLCMTWC_Qty) { CompletedWork.TLCMTWC_Qty = (int)Row.Cells[4].Value; } } } else { if (!(bool)Row.Cells[1].Value) { continue; } int Pk = (int)Row.Cells[0].Value; var ExpectedUnits = context.TLCUT_ExpectedUnits.Find(Pk); if (ExpectedUnits != null) { ExpectedUnits.TLCUTE_Size_FK = (int)Row.Cells[3].Value; } } } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); frmCutSheetDownSize_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLADM_Colours SelectedColour = null; bool lAdd = false; if (lNew) { lAdd = true; } if (rbStandard.Checked) { SelectedColour = (TLADM_Colours)cmboColours.SelectedItem; if (SelectedColour == null) { MessageBox.Show("Please select a colour from the drop down box provided"); return; } if (QueryParms.FabricQualities.Count == 0) { MessageBox.Show("Please add a Quality"); return; } } if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandSelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } foreach (DataGridViewRow dr in dataGridView1.Rows) { if (rbStandard.Checked) { var tst = fieldEntered.Find(x => x.rownumber == dr.Index); if (tst.fieldComplete == null) { continue; } tst.fieldComplete[1] = true; var cnt = tst.fieldComplete.Where(x => x == false).Count(); if (cnt == MandatoryRows.Length) { continue; } cnt = tst.fieldComplete.Where(x => x == true).Count(); } } // 0 index of the main record // 1 ConsumablesDC // 2 Grams Per Litre // 3 Ratios // 4 Liquid Ratios using (var context = new TTI2Entities()) { TLDYE_RecipeDefinition rd = new TLDYE_RecipeDefinition(); if (!lAdd) { var selected = (TLDYE_RecipeDefinition)cmboProductCodes.SelectedItem; if (selected != null) { rd = context.TLDYE_RecipeDefinition.Find(selected.TLDYE_DefinePk); } } rd.TLDYE_DefineCode = txtProductCode.Text; if (rbStandard.Checked) { rd.TLDYE_DefineDescription = txtProductCode.Text + " " + SelectedColour.Col_Display; } else { rd.TLDYE_DefineDescription = txtProductCode.Text; } if (rbStandard.Checked) { rd.TLDYE_ProgramLoad = Convert.ToInt32(txtProgramLoad.Text); rd.TLDYE_LiquidLoad = Convert.ToInt32(txtProgramVolume.Text); rd.TLDYE_ColorChart_FK = SelectedColour.Col_Id; rd.TLDYE_StandardReceipe = true; } else { rd.TLDYE_LiquidLoad = 0; rd.TLDYE_ProgramLoad = 0; rd.TLDYE_ColorChart_FK = null; rd.TLDYE_StandardReceipe = false; } if (lAdd) { context.TLDYE_RecipeDefinition.Add(rd); } try { context.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { MessageBox.Show("Property: " + validationError.PropertyName + " Error " + validationError.ErrorMessage); } return; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } // 0 index of the main record // 1 ConsumablesDC // 2 Grams Per Litre // 3 Ratios // 4 Liquid Ratios foreach (DataGridViewRow dr in dataGridView1.Rows) { if (dr.Cells[1].Value == null) { continue; } var tst = fieldEntered.Find(x => x.rownumber == dr.Index); if (tst.fieldComplete == null) { continue; } tst.fieldComplete[1] = true; var cnt = tst.fieldComplete.Where(x => x == false).Count(); if (cnt == MandatoryRows.Length) { continue; } lAdd = false; if (dr.Cells[0].Value == null) { lAdd = true; } cnt = tst.fieldComplete.Where(x => x == true).Count(); if (cnt == MandatoryRows.Length) { TLDYE_DefinitionDetails defdet = new TLDYE_DefinitionDetails(); if (!lAdd) { var index = Convert.ToInt32(dr.Cells[0].Value.ToString()); defdet = context.TLDYE_DefinitionDetails.Find(index); } defdet.TLDYED_Cosumables_FK = (int)dr.Cells[1].Value; if (dr.Cells[2].Value != null) { if ((bool)dr.Cells[2].Value == true) { defdet.TLDYED_LiqCalc = true; } else { defdet.TLDYED_LiqCalc = false; } } else { defdet.TLDYED_LiqCalc = false; } defdet.TLDYED_MELFC = (decimal)dr.Cells[3].Value; defdet.TLDYED_LiqRatio = (int)dr.Cells[4].Value; defdet.TLDYED_Receipe_FK = rd.TLDYE_DefinePk; if (lAdd) { context.TLDYE_DefinitionDetails.Add(defdet); } } } //--------------------------------------------------------- // //---------------------------------------------------------------- if (rbStandard.Checked) { //------------------------------------------------------------------------------------ // First we must ensure that any previous records that may exist are deleted and that we start with a clean slate //--------------------------------------------------------------------------- context.TLDYE_ReceipeGreigeQual.RemoveRange(context.TLDYE_ReceipeGreigeQual.Where(x => x.TLGQ_ReceipeDef_FK == rd.TLDYE_DefinePk)); //------------------------------------------------------ // new development //---------------------------------------------------------- foreach (var Qual in QueryParms.FabricQualities) { TLDYE_ReceipeGreigeQual repQual = new TLDYE_ReceipeGreigeQual(); repQual.TLGQ_GreigeQuality_FK = Qual.GQ_Pk; repQual.TLGQ_ReceipeDef_FK = rd.TLDYE_DefinePk; context.TLDYE_ReceipeGreigeQual.Add(repQual); } } try { context.SaveChanges(); MessageBox.Show("Data saved to database successfully"); } catch (Exception ex) { // MessageBox.Show(ex.Message); MessageBox.Show(ex.InnerException.ToString()); } finally { this.cmboGreigeQuality.Items.Clear(); dataGridView1.Rows.Clear(); SetUp(); } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; bool success = true; TLADM_TranactionType TranType = null; TLADM_MachineOperators Operators = null; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandatorySelected, false, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } var Inspector = (TLADM_MachineOperators)cmbInspector.SelectedItem; var KO = (TLKNI_Order)cmbKnitOrder.SelectedItem; using (var context = new TTI2Entities()) { Operators = (TLADM_MachineOperators)cmbInspector.SelectedItem; var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); foreach (DataGridViewRow row in dataGridView1.Rows) { TLKNI_GreigeProduction record = new TLKNI_GreigeProduction(); record = context.TLKNI_GreigeProduction.Find(row.Cells[0].Value); if (row.Cells[2].Value != null) { record.GreigeP_Grade = row.Cells[2].Value.ToString(); } else { record.GreigeP_Grade = "A"; } if (row.Cells[3].Value != null) { record.GreigeP_Remarks = row.Cells[3].Value.ToString(); } else { record.GreigeP_Remarks = string.Empty; } record.GreigeP_Meas1 = (int)row.Cells[4].Value; record.GreigeP_Meas2 = (int)row.Cells[5].Value; record.GreigeP_Meas3 = (int)row.Cells[6].Value; record.GreigeP_Meas4 = (int)row.Cells[7].Value; record.GreigeP_Meas5 = (int)row.Cells[8].Value; record.GreigeP_Meas6 = (int)row.Cells[9].Value; record.GreigeP_Meas7 = (int)row.Cells[10].Value; record.GreigeP_Meas8 = (int)row.Cells[11].Value; record.GreigeP_Inspected = (bool)row.Cells[12].Value; record.GreigeP_InspDate = dateTimePicker1.Value; record.GreigeP_Inspector_FK = Inspector.MachOp_Pk; record.GreigeP_WarningMessage = (bool)row.Cells[14].Value; if (row.Cells[2].Value != null) { if (row.Cells[2].Value.ToString().Contains("C")) { // We need to record a transaction //----------------------------------------------- TLKNI_GreigeTransactions GreigeT = new TLKNI_GreigeTransactions(); GreigeT.GreigeT_AdjustedWeight = record.GreigeP_weight; GreigeT.GreigeT_TransactionDate = dateTimePicker1.Value; GreigeT.GreigeT_TransactionNumber = 9999; GreigeT.GreigeT_Grade = row.Cells[2].Value.ToString(); GreigeT.GreigeT_KOrder_FK = KO.KnitO_Pk; GreigeT.GreigeT_Piece_FK = record.GreigeP_Pk; if (KO.KnitO_YarnO_FK != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1500).FirstOrDefault(); if (TranType != null) { record.GreigeP_Store_FK = TranType.TrxT_ToWhse_FK; } } else { if (KO.KnitO_CommisionCust) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1700).FirstOrDefault(); if (TranType != null) { record.GreigeP_Store_FK = TranType.TrxT_ToWhse_FK; } } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1600).FirstOrDefault(); if (TranType != null) { record.GreigeP_Store_FK = TranType.TrxT_ToWhse_FK; } } } GreigeT.GreigeT_TransactionType_FK = TranType.TrxT_Pk; context.TLKNI_GreigeTransactions.Add(GreigeT); } else { if (KO.KnitO_YarnO_FK != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1400).FirstOrDefault(); if (TranType != null) { record.GreigeP_Store_FK = TranType.TrxT_ToWhse_FK; } } else { if (KO.KnitO_CommisionCust) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1300).FirstOrDefault(); if (TranType != null) { record.GreigeP_Store_FK = TranType.TrxT_ToWhse_FK; } } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1200).FirstOrDefault(); if (TranType != null) { record.GreigeP_Store_FK = TranType.TrxT_ToWhse_FK; } } } } } } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.InnerException.ToString()); success = false; } } if (success) { MessageBox.Show("Records stored successfully to the database"); dataGridView1.Rows.Clear(); } } }
//--------------------------------------------------------------------------- private void cmbKnitOrder_SelectedIndexChanged(object sender, EventArgs e) { ComboBox oCmbo = sender as ComboBox; DataGridView oDgv = dataGridView1; if (oCmbo != null && formloaded) { var KO = (TLKNI_Order)cmbKnitOrder.SelectedItem; if (KO != null) { oDgv.Rows.Clear(); using (var context = new TTI2Entities()) { txtGreigeQual.Text = context.TLADM_Griege.Find(KO.KnitO_Product_FK).TLGreige_Description; formloaded = false; var Existing = context.TLKNI_GreigeProduction.Where(x => x.GreigeP_KnitO_Fk == KO.KnitO_Pk && x.GreigeP_Captured).OrderBy(x => x.GreigeP_PieceNo).ToList(); foreach (var row in Existing) { var index = oDgv.Rows.Add(); oDgv.Rows[index].Cells[0].Value = row.GreigeP_Pk; oDgv.Rows[index].Cells[1].Value = row.GreigeP_PieceNo; oDgv.Rows[index].Cells[2].Value = row.GreigeP_Grade; oDgv.Rows[index].Cells[3].Value = row.GreigeP_Remarks; oDgv.Rows[index].Cells[4].Value = row.GreigeP_Meas1; oDgv.Rows[index].Cells[5].Value = row.GreigeP_Meas2; oDgv.Rows[index].Cells[6].Value = row.GreigeP_Meas3; oDgv.Rows[index].Cells[7].Value = row.GreigeP_Meas4; oDgv.Rows[index].Cells[8].Value = row.GreigeP_Meas5; oDgv.Rows[index].Cells[9].Value = row.GreigeP_Meas6; oDgv.Rows[index].Cells[10].Value = row.GreigeP_Meas7; oDgv.Rows[index].Cells[11].Value = row.GreigeP_Meas8; oDgv.Rows[index].Cells[12].Value = row.GreigeP_Inspected; oDgv.Rows[index].Cells[13].Value = false; oDgv.Rows[index].Cells[14].Value = row.GreigeP_WarningMessage; } if (this.dataGridView1.Rows.Count != 0) { this.dataGridView1.CurrentCell = this.dataGridView1.Rows[0].Cells[2]; this.dataGridView1.BeginEdit(true); } formloaded = true; } var result = (from u in MandatoryFields where u[0] == oCmbo.Name select u).FirstOrDefault(); if (result != null) { int nbr = Convert.ToInt32(result[2].ToString()); MandatorySelected[nbr] = true; } cmbInspector.Focus(); } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandatorySelected, true, MandatoryFields); if (!String.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } var selected = (TLSPN_YarnOrderPallets)cmbPalettNo.SelectedItem; if (selected != null) { if (cmbOperator.SelectedValue == null) { MessageBox.Show("Please select an operator from the drop down box"); return; } int NoOfCones = int.Parse(txtNoOfCones.Text); if (NoOfCones <= 0) { MessageBox.Show("Please enter the number of cones spun"); return; } using (var context = new TTI2Entities()) { var yo = (TLSPN_YarnOrder)cmbYarnOrder.SelectedItem; if (yo != null) { var YarnInfo = context.TLADM_Yarn.Where(x => x.YA_Id == yo.Yarno_YarnType_FK).FirstOrDefault(); if (YarnInfo != null) { selected.YarnOP_YarnType_FK = YarnInfo.YA_Id; } } selected = context.TLSPN_YarnOrderPallets.Find(selected.YarnOP_Pk); selected.YarnOP_DatePacked = dtpDateProduced.Value; selected.YarnOP_GrossWeight = Convert.ToDecimal(txtGrossWeight.Text); selected.YarnOP_TareWeight = Convert.ToDecimal(txtTareWeight.Text); selected.YarnOP_NettWeight = Convert.ToDecimal(txtGrossWeight.Text) - Convert.ToDecimal(txtTareWeight.Text); selected.YarnOP_NoOfCones = NoOfCones; selected.YarnOP_NoOfConesSpun = Convert.ToInt32(txtNoOfConesSpun.Text); selected.YarnOP_Grade = txtYarnGrade.Text; if (cmbOperator.SelectedValue != null) { selected.YarnOP_Operator_FK = (int)cmbOperator.SelectedValue; } if (selected.YarnOP_NoOfConesSpun == selected.YarnOP_NoOfCones) { selected.YarnOP_Complete = true; } else { selected.YarnOP_Complete = false; } var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("SPIN")).FirstOrDefault(); if (Dept != null) { var Trantype = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 500).FirstOrDefault(); if (Trantype != null) { selected.YarnOP_Store_FK = (int)Trantype.TrxT_ToWhse_FK; } } TLSPN_YarnTransactions YarnT = new TLSPN_YarnTransactions(); var Trx = context.TLSPN_YarnTransactions.Where(x => x.YarnTrx_YarnOrder_FK == selected.YarnOP_YarnOrder_FK && x.YarnTrx_PalletNo_Fk == selected.YarnOP_Pk).FirstOrDefault(); if (Trx != null) { YarnT = context.TLSPN_YarnTransactions.Find(Trx.YarnTrx_Pk); YarnT.YarnTrx_Date = dtpDateProduced.Value; YarnT.YarnTrx_NettWeight = selected.YarnOP_NettWeight; YarnT.YarnTrx_Cones = selected.YarnOP_NoOfCones; } else { var deptDetail = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); if (deptDetail != null) { var tranDetail = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == deptDetail.Dep_Id && x.TrxT_Number == 700).FirstOrDefault(); if (tranDetail != null) { YarnT.YarnTrx_TranType_FK = tranDetail.TrxT_Pk; } } YarnT.YarnTrx_PalletNo_Fk = selected.YarnOP_Pk; YarnT.YarnTrx_YarnOrder_FK = (int)selected.YarnOP_YarnOrder_FK; YarnT.YarnTrx_SequenceNo = 0; YarnT.YarnTrx_Cones = selected.YarnOP_NoOfCones; YarnT.YarnTrx_WriteOff = false; YarnT.YarnTrx_NettWeight = selected.YarnOP_NettWeight; YarnT.YarnTrx_Date = dtpDateProduced.Value; context.TLSPN_YarnTransactions.Add(YarnT); } try { context.SaveChanges(); formloaded = false; yo = (TLSPN_YarnOrder)cmbYarnOrder.SelectedItem; if (yo != null) { var Existing = context.TLSPN_YarnOrderPallets.Where(x => x.YarnOP_YarnOrder_FK == yo.YarnO_Pk && !x.YarnOP_Complete).ToList(); formloaded = false; cmbPalettNo.DataSource = Existing; formloaded = true; } MessageBox.Show("Records successfully updated to DataBase"); SetUp(false); MandatorySelected[0] = true; MandatorySelected[2] = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; Repository repo = new Repository(); TLCSV_BoxSelected boxSelected; if (oBtn != null && Submit) { var Depts = (TLADM_Departments)cmboFrom.SelectedItem; if (Depts == null) { MessageBox.Show("Please select a CMT from from the drop down box"); return; } QueryParms.Depts.Add(repo.LoadDepart(Depts.Dep_Id)); var BoxesAvailable = repo.Query(QueryParms); if (BoxesAvailable.Count() == 0) { MessageBox.Show("There are no Boxes available"); return; } DGVResults.Rows.Clear(); using (var context = new TTI2Entities()) { foreach (var Box in BoxesAvailable) { var index = DGVResults.Rows.Add(); DGVResults.Rows[index].Cells[0].Value = Box.TLCMTWC_Pk; DGVResults.Rows[index].Cells[1].Value = false; DGVResults.Rows[index].Cells[2].Value = Box.TLCMTWC_BoxNumber; DGVResults.Rows[index].Cells[3].Value = Box.TLCMTWC_Qty; DGVResults.Rows[index].Cells[4].Value = Box.TLCMTWC_Weight; var Styles = context.TLADM_Styles.Find(Box.TLCMTWC_Style_FK); if (Styles != null) { DGVResults.Rows[index].Cells[5].Value = context.TLADM_CustomerFile.Find(Styles.Sty_Label_FK).Cust_Description; DGVResults.Rows[index].Cells[6].Value = Styles.Sty_Description; } DGVResults.Rows[index].Cells[7].Value = context.TLADM_Colours.Find(Box.TLCMTWC_Colour_FK).Col_Display; DGVResults.Rows[index].Cells[8].Value = context.TLADM_Sizes.Find(Box.TLCMTWC_Size_FK).SI_Description; } } DGVResults.Visible = true; label4.Visible = false; label5.Visible = false; label6.Visible = false; Submit = !Submit; btnSubmit.Text = "Process"; groupBox1.Text = "Results"; } else { //------------------------------------------------------------------- // 1st Has a to destination been selected // If No return //------------------------------------------------------------------------ var Dept = (TLADM_Departments)cmboFrom.SelectedItem; if (Dept == null) { MessageBox.Show("Error encountered" + Environment.NewLine + "Process aborted"); return; } var Whse = (TLADM_WhseStore)cmboTo.SelectedItem; if (Whse == null) { MessageBox.Show("Please select a TO Destination from the drop down box provided"); return; } var RecCount = DGVResults.Rows.Cast <DataGridViewRow>().Where(x => (bool)x.Cells[1].Value == true).Count(); if (RecCount == 0) { MessageBox.Show("Please select a least one record to process"); return; } using (var context = new TTI2Entities()) { //------------------------------------------------ // 1st Things first create a header record //------------------------------------------------------------------------- var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); boxSelected = new TLCSV_BoxSelected(); boxSelected.TLCSV_TransDate = dateTimePicker1.Value; boxSelected.TLCSV_From_FK = Dept.Dep_Id; boxSelected.TLCSV_To_FK = Whse.WhStore_Id; if (LNU != null) { boxSelected.TLCSV_TransNumber = LNU.col6; LNU.col6 += 1; } boxSelected.TLCSV_PLDetails = "CP" + boxSelected.TLCSV_TransNumber.ToString().PadLeft(5, '0'); try { context.TLCSV_BoxSelected.Add(boxSelected); context.SaveChanges(); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); return; } foreach (DataGridViewRow row in DGVResults.Rows) { if ((bool)row.Cells[1].Value == false) { continue; } TLCMT_CompletedWork comWork = new TLCMT_CompletedWork(); var index = (int)row.Cells[0].Value; comWork = context.TLCMT_CompletedWork.Find(index); if (comWork != null) { comWork.TLCMTWC_PickList_FK = boxSelected.TLCSV_Pk; comWork.TLCMTWC_Picked = true; comWork.TLCMTWC_ToWhse_FK = Whse.WhStore_Id; } } try { context.SaveChanges(); using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show("Data successfully saved to the database"); } } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); return; } //---------------------------------------------------------------------- frmCSViewRep vRep = new frmCSViewRep(1, boxSelected.TLCSV_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); //----------------------------------------------------------------------- try { DialogResult res = MessageBox.Show(" Do you wish to send a confirmation email ", "Confirmation email", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //------------------------------------------------------------------- // We need to build up a data table of // boxes( stock ) transfered //------------------------------------------------------------------- DataTable dt = new DataTable(); dt.Columns.Add("BoxNumber", typeof(String)); dt.Columns["BoxNumber"].DefaultValue = string.Empty; dt.Columns.Add("Style", typeof(String)); dt.Columns["Style"].DefaultValue = string.Empty; dt.Columns.Add("Colour", typeof(String)); dt.Columns["Colour"].DefaultValue = string.Empty; dt.Columns.Add("Size", typeof(String)); dt.Columns["Size"].DefaultValue = string.Empty; dt.Columns.Add("Grade", typeof(String)); dt.Columns["Grade"].DefaultValue = string.Empty; dt.Columns.Add("Qty", typeof(int)); dt.Columns["Qty"].DefaultValue = 0; dt.Columns.Add("Weight", typeof(decimal)); dt.Columns["Weight"].DefaultValue = 0.0M; var BoxesTransfered = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_PickList_FK == boxSelected.TLCSV_Pk).ToList(); foreach (var Box in BoxesTransfered) { DataRow dr = dt.NewRow(); dr[0] = Box.TLCMTWC_BoxNumber; dr[1] = context.TLADM_Styles.Find(Box.TLCMTWC_Style_FK).Sty_Description; dr[2] = context.TLADM_Colours.Find(Box.TLCMTWC_Colour_FK).Col_Description; dr[3] = context.TLADM_Sizes.Find(Box.TLCMTWC_Size_FK).SI_Description; dr[4] = Box.TLCMTWC_Grade; dr[5] = Box.TLCMTWC_Qty; dr[6] = Box.TLCMTWC_Weight; dt.Rows.Add(dr); } StringBuilder EMailAdd = new StringBuilder(); frmSeleEMailAddress EMailAddress = new frmSeleEMailAddress(); EMailAddress.ShowDialog(this); var Email = EMailAddress.EMailSelected; if (Email.ToString().Length > 0) { try { string ToWhse = context.TLADM_WhseStore.Find(boxSelected.TLCSV_To_FK).WhStore_Description; core.SendEmailtoContacts(Email.ToString(), dt, 2, dateTimePicker1.Value, ToWhse, boxSelected.TLCSV_PLDetails); MessageBox.Show("Email successfully despatched"); } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } else { MessageBox.Show("No Email address's selected or Email address's do not exist"); } } } catch (Exception ex) { var exceptionMessages = new StringBuilder(); do { exceptionMessages.Append(ex.Message); ex = ex.InnerException; }while (ex != null); MessageBox.Show(exceptionMessages.ToString()); } } DGVResults.Visible = false; groupBox1.Text = "Selection"; label4.Visible = true; label5.Visible = true; label6.Visible = true; Submit = !Submit; btnSubmit.Text = "Submit"; cmboStyles.Items.Clear(); cmboColours.Items.Clear(); cmboSizes.Items.Clear(); frmWareHouseTransfers_Load(this, null); } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; TLDYE_BIFInTransit BIFTransit = new TLDYE_BIFInTransit(); if (oBtn != null && FormLoaded) { var CurrWhse = (TLADM_WhseStore)cmboWareHouses.SelectedItem; if (CurrWhse == null) { MessageBox.Show("Please select a from Warehouse"); return; } var ToWhse = (TLADM_WhseStore)cmboToWareHouse.SelectedItem; if (ToWhse == null) { MessageBox.Show("Please select a to Warehouse"); return; } var SingleRow = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).FirstOrDefault(); if (SingleRow == null) { MessageBox.Show("Please select at least one record"); return; } using (var context = new TTI2Entities()) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "CUT").FirstOrDefault(); if (Dept != null) { var LstNumberUsed = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault(); if (LstNumberUsed != null) { BIFTransit = new TLDYE_BIFInTransit(); BIFTransit.BIFT_PickingList = true; BIFTransit.BIFT_PickingList_Date = DateTime.Now; BIFTransit.BIFT_PickingList_Number = LstNumberUsed.col3; BIFTransit.BIFT_FromFabric_FK = CurrWhse.WhStore_Id; BIFTransit.BIFT_ToFabric_FK = ToWhse.WhStore_Id; context.TLDYE_BIFInTransit.Add(BIFTransit); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (DataGridViewRow Row in dataGridView1.Rows) { var IsChecked = (bool)Row.Cells[1].Value; if (!IsChecked) { continue; } TLDYE_BIFInTransitDetails TransDetails = new TLDYE_BIFInTransitDetails(); TransDetails.BIFD_Intransit_FK = BIFTransit.BIFT_Pk; var Greige_Pk = (int)Row.Cells[0].Value; TransDetails.BIFD_Greige_FK = Greige_Pk; if (Row.Cells[5].Value != null) { var Col = (string)Row.Cells[5].Value; var Colour_Pk = context.TLADM_Colours.Where(x => x.Col_Display == Col).FirstOrDefault().Col_Id; TransDetails.BIFD_Colour_FK = Colour_Pk; } var DyeBatchDetail = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_GreigeProduction_FK == Greige_Pk).FirstOrDefault(); if (DyeBatchDetail != null) { DyeBatchDetail.DYEBO_BIFInTransit = true; TransDetails.BIFD_DyeBatchDetail_FK = DyeBatchDetail.DYEBD_Pk; } context.TLDYE_BIFInTransitDetails.Add(TransDetails); } try { LstNumberUsed.col3 += 1; context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); dataGridView1.Rows.Clear(); FrmSelectBIF_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } Cutting.frmCutViewRep vRep = new Cutting.frmCutViewRep(16, BIFTransit.BIFT_Pk); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(); } }
private void frmWareHouseTransfers_Load(object sender, EventArgs e) { formloaded = false; Submit = true; core = new Util(); using (var context = new TTI2Entities()) { QueryParms = new CustomerServicesParameters(); cmboFrom.DataSource = context.TLADM_Departments.Where(x => x.Dep_IsCMT).ToList(); cmboFrom.ValueMember = "Dep_Id"; cmboFrom.DisplayMember = "Dep_Description"; cmboFrom.SelectedValue = -1; cmboTo.DataSource = context.TLADM_WhseStore.Where(x => x.WhStore_WhseOrStore).ToList(); cmboTo.ValueMember = "WhStore_Id"; cmboTo.DisplayMember = "WhStore_Description"; cmboTo.SelectedValue = -1; var Styles = context.TLADM_Styles.OrderBy(x => x.Sty_Description).ToList(); foreach (var Style in Styles) { cmboStyles.Items.Add(new CustomerServices.CheckComboBoxItem(Style.Sty_Id, Style.Sty_Description, false)); } var Colours = context.TLADM_Colours.Where(x => !(bool)x.Col_Discontinued).OrderBy(x => x.Col_Display).ToList(); foreach (var Colour in Colours) { cmboColours.Items.Add(new CustomerServices.CheckComboBoxItem(Colour.Col_Id, Colour.Col_Display, false)); } var Sizes = context.TLADM_Sizes.Where(x => !(bool)x.SI_Discontinued).OrderBy(x => x.SI_DisplayOrder).ToList(); foreach (var Size in Sizes) { cmboSizes.Items.Add(new CustomerServices.CheckComboBoxItem(Size.SI_id, Size.SI_Description, false)); } DGVResults.Visible = false; oTxtA = new DataGridViewTextBoxColumn(); oTxtA.Visible = false; oTxtA.ValueType = typeof(int); oTxtA.ReadOnly = true; DGVResults.Columns.Add(oTxtA); oChkA = new DataGridViewCheckBoxColumn(); oChkA.Visible = true; oChkA.ValueType = typeof(Boolean); oChkA.HeaderText = "Select"; DGVResults.Columns.Add(oChkA); oTxtB = new DataGridViewTextBoxColumn(); oTxtB.Visible = true; oTxtB.HeaderText = "Box Detail"; oTxtB.ReadOnly = true; oTxtB.ValueType = typeof(string); DGVResults.Columns.Add(oTxtB); oTxtC = new DataGridViewTextBoxColumn(); oTxtC.Visible = true; oTxtC.HeaderText = "Box Qty"; oTxtC.ReadOnly = true; oTxtC.ValueType = typeof(int); DGVResults.Columns.Add(oTxtC); oTxtD = new DataGridViewTextBoxColumn(); oTxtD.Visible = true; oTxtD.HeaderText = "Box Weight"; oTxtD.ReadOnly = true; oTxtD.ValueType = typeof(decimal); DGVResults.Columns.Add(oTxtD); oTxtE = new DataGridViewTextBoxColumn(); oTxtE.Visible = true; oTxtE.HeaderText = "Customer"; oTxtE.ReadOnly = true; oTxtE.ValueType = typeof(string); DGVResults.Columns.Add(oTxtE); oTxtF = new DataGridViewTextBoxColumn(); oTxtF.Visible = true; oTxtF.HeaderText = "Style"; oTxtF.ReadOnly = true; oTxtF.ValueType = typeof(string); DGVResults.Columns.Add(oTxtF); oTxtG = new DataGridViewTextBoxColumn(); oTxtG.Visible = true; oTxtG.HeaderText = "Colour"; oTxtG.ReadOnly = true; oTxtG.ValueType = typeof(string); DGVResults.Columns.Add(oTxtG); oTxtH = new DataGridViewTextBoxColumn(); oTxtH.Visible = true; oTxtH.HeaderText = "Size"; oTxtH.ReadOnly = true; oTxtH.ValueType = typeof(string); DGVResults.Columns.Add(oTxtH); DGVResults.AutoGenerateColumns = false; DGVResults.AllowUserToAddRows = false; formloaded = true; } }
private void dataGridView2_CellEnter(object sender, DataGridViewCellEventArgs e) { DataGridView oDgv = sender as DataGridView; var CurrentCell = oDgv.CurrentCell; string headerText = dataGridView2.Columns[e.ColumnIndex].HeaderText; if (!headerText.Equals("Pastel Number")) { return; } var CurrentRow = oDgv.CurrentRow; var PastelCode = Styles.Sty_PastelNo.ToString(); PastelCode += Colours.Col_FinishedCode; if (CurrentRow.Cells[1].Value != null) { var Grade = CurrentRow.Cells[1].Value.ToString().ToUpper(); if (Grade.Contains("A")) { if (StyleGrades != null) { PastelCode += StyleGrades.TLSG_Grade_A; } else { PastelCode += Styles.Sty_PastelCode; } txtNoBoxes.Text = (1 + Convert.ToInt32(txtNoBoxes.Text)).ToString(); } else { if (StyleGrades != null) { PastelCode += StyleGrades.TLSG_Grade_B; } else { PastelCode += Styles.Sty_PastelCode; } txtNoBoxes.Text = (1 + Convert.ToInt32(txtNoBoxes.Text)).ToString(); } } else { var Grade = CurrentRow.Cells[1].EditedFormattedValue.ToString().ToUpper(); if (Grade.Contains("A")) { if (StyleGrades != null) { PastelCode += StyleGrades.TLSG_Grade_A; } else { PastelCode += Styles.Sty_PastelCode; } txtNoBoxes.Text = (1 + Convert.ToInt32(txtNoBoxes.Text)).ToString(); } else { if (StyleGrades != null) { PastelCode += StyleGrades.TLSG_Grade_B; } else { PastelCode += Styles.Sty_PastelCode; } txtNoBoxes.Text = (1 + Convert.ToInt32(txtNoBoxes.Text)).ToString(); } } using (var context = new TTI2Entities()) { if (CurrentRow.Cells[6].Value != null) { // int index = (int)CurrentRow.Cells[6].Value; try { int index = (int)CurrentRow.Cells[2].Value; if (index != 0) { PastelCode += context.TLADM_Sizes.Find(index).SI_PastelNo.ToString(); dataGridView2.Rows[CurrentRow.Index].Cells[3].Value = PastelCode; // dataGridView2.Rows[CurrentRow.Index].Cells[2].Value = context.TLADM_Sizes.Find(CSRD.TLCUTSHRD_Size_FK).SI_Description; } } catch (Exception Ex) { } } } }
private void frmCottonLayDownSelection_Load(object sender, EventArgs e) { oTxtA.HeaderText = "Primary Key"; oTxtA.ValueType = typeof(Int32); oTxtA.Visible = false; oTxtB.HeaderText = "Lay down number"; oTxtB.ValueType = typeof(Int32); oTxtB.Visible = true; oTxtB.ReadOnly = true; oTxtC.HeaderText = "Lay down Weight"; oTxtC.ValueType = typeof(decimal); oTxtC.Visible = true; oTxtC.ReadOnly = true; oTxtD.HeaderText = "Lot No"; oTxtD.ValueType = typeof(decimal); oTxtD.Visible = true; oTxtD.ReadOnly = true; oChk.HeaderText = "select"; oChk.ValueType = typeof(Boolean); dataGridView1.AllowUserToAddRows = false; dataGridView1.Columns.Add(oTxtA); dataGridView1.Columns.Add(oChk); dataGridView1.Columns.Add(oTxtB); dataGridView1.Columns.Add(oTxtC); dataGridView1.Columns.Add(oTxtD); using (var context = new TTI2Entities()) { if (!_mode) { var cotreceived = context.TLSPN_CottonTransactions.Where(x => x.cotrx_TranType == 5 && !x.cotrx_Selected4Yarn).ToList(); foreach (var record in cotreceived) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = record.cotrx_pk; dataGridView1.Rows[index].Cells[1].Value = false; dataGridView1.Rows[index].Cells[2].Value = record.cotrx_Return_No; dataGridView1.Rows[index].Cells[3].Value = Math.Round(record.cotrx_NetWeight, 2); dataGridView1.Rows[index].Cells[4].Value = record.cotrx_LotNo; } } else { var cotreceived = context.TLSPN_CottonTransactions.Where(x => x.cotrx_TranType == 5).ToList(); foreach (var record in cotreceived) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = record.cotrx_pk; if (record.cotrx_YarnOrder_FK == _pk) { dataGridView1.Rows[index].Cells[1].Value = true; } else { dataGridView1.Rows[index].Cells[1].Value = false; } dataGridView1.Rows[index].Cells[2].Value = record.cotrx_Return_No; dataGridView1.Rows[index].Cells[3].Value = Math.Round(record.cotrx_NetWeight, 2); dataGridView1.Rows[index].Cells[4].Value = record.cotrx_LotNo; } } } }
DataGridViewComboBoxColumn oCmbA; // Yarn Type public frmYarnPurchased3rdParty() { using (var context = new TTI2Entities()) { } MandatoryFields = new string[][] { new string[] { "cmbCommissionCustomers", "Please select a commision customer", "0", "10" }, new string[] { "txtCustomerDoc", "Please enter document no details", "1", "" } }; MandatoryRows = new string[][] { new string[] { "0", "Please enter a pallet number", "0" }, new string[] { "5", "Please enter the gross weight", "1" }, new string[] { "6", "Please enter the nett weight", "2" }, new string[] { "7", "Please enter the number of cones", "3" } }; core = new Util(); InitializeComponent(); dataGridView1.AutoGenerateColumns = false; oTxtA = new DataGridViewTextBoxColumn(); oTxtA.HeaderText = "Pallet No"; oTxtA.ValueType = typeof(int); oTxtA.Visible = true; oTxtB = new DataGridViewTextBoxColumn(); oTxtB.HeaderText = "Text Count"; oTxtB.ValueType = typeof(string); oTxtB.Visible = true; oTxtB.ReadOnly = true; oTxtC = new DataGridViewTextBoxColumn(); oTxtC.HeaderText = "Twist"; oTxtC.ValueType = typeof(string); oTxtC.Visible = true; oTxtC.ReadOnly = true; oTxtD = new DataGridViewTextBoxColumn(); oTxtD.HeaderText = "Identification"; oTxtD.ValueType = typeof(string); oTxtD.Visible = true; oTxtD.ReadOnly = true; oTxtE = new DataGridViewTextBoxColumn(); oTxtE.HeaderText = "Gross Weight"; oTxtE.ValueType = typeof(decimal); oTxtE.Visible = true; oTxtF = new DataGridViewTextBoxColumn(); oTxtF.HeaderText = "Nett Weight"; oTxtF.ValueType = typeof(decimal); oTxtF.Visible = true; oTxtG = new DataGridViewTextBoxColumn(); oTxtG.HeaderText = "No Of Cones"; oTxtG.ValueType = typeof(int); oTxtG.Visible = true; oCmbA = new DataGridViewComboBoxColumn(); oCmbA.HeaderText = "Yarn Type"; oCmbA.ValueMember = "YA_Id"; oCmbA.DisplayMember = "YA_Description"; dataGridView1.Columns.Add(oTxtA); dataGridView1.Columns.Add(oCmbA); dataGridView1.Columns.Add(oTxtB); dataGridView1.Columns.Add(oTxtC); dataGridView1.Columns.Add(oTxtD); dataGridView1.Columns.Add(oTxtE); dataGridView1.Columns.Add(oTxtF); dataGridView1.Columns.Add(oTxtG); this.dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing); this.dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded); this.dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating); this.dataGridView1.CellLeave += new DataGridViewCellEventHandler(dataGridView1_CellLeave); SetUp(); }
private void cmbKnitOrder_SelectedIndexChanged(object sender, EventArgs e) { bool First = true; ComboBox oCmbo = sender as ComboBox; IList <TLKNI_YarnOrderPallets> Pallets = new List <TLKNI_YarnOrderPallets>(); if (oCmbo != null && formloaded) { using (var context = new TTI2Entities()) { var selected = (TLKNI_Order)oCmbo.SelectedItem; if (selected != null) { if (selected.KnitO_YarnO_FK != null) { var YO = context.TLSPN_YarnOrder.Find(selected.KnitO_YarnO_FK); if (YO != null) { txtYarnOrder.Text = YO.YarnO_OrderNumber.ToString(); var MAC = context.TLADM_MachineDefinitions.Find(YO.Yarno_MachNo_FK); if (MAC != null) { txtMachine.Text = MAC.MD_MachineCode; } } } var Transactions = context.TLKNI_YarnAllocTransctions.Where(x => x.TLKYT_KnitOrder_FK == selected.KnitO_Pk).ToList(); foreach (var Transaction in Transactions) { var Pallet = context.TLKNI_YarnOrderPallets.Find(Transaction.TLKYT_YOP_FK); if (Pallet != null) { if (First) { var YarnDet = context.TLADM_Yarn.Find(Pallet.TLKNIOP_YarnType_FK); if (YarnDet != null) { txtYarnType.Text = YarnDet.YA_Description; txtTwist.Text = YarnDet.YA_Twist.ToString(); txtTexCount.Text = YarnDet.YA_TexCount.ToString(); txtIdentification.Text = YarnDet.YA_ConeColour; var Origin = context.TLADM_CottonOrigin.Find(YarnDet.YA_CottonOrigin_FK); if (Origin != null) { txtCottonOrigin.Text = Origin.CottonOrigin_Description; } } First = false; } } Pallets.Add(Pallet); } oCmbA.DataSource = Pallets; oCmbA.DisplayMember = "TLKNIOP_PalletNo"; oCmbA.ValueMember = "TLKNIOP_Pk"; oCmbB.DataSource = context.TLKNI_Order.Where(x => !x.KnitO_Closed && x.KnitO_Pk != selected.KnitO_Pk).ToList(); oCmbB.DisplayMember = "KnitO_OrderNumber"; oCmbB.ValueMember = "KnitO_Pk"; } } } }
public AdminRepository() { _context = new TTI2Entities(); }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; TLADM_TranactionType TranType = null; if (oBtn != null && formloaded) { var KO = (TLKNI_Order)cmbKnitOrder.SelectedItem; if (KO != null) { using (var context = new TTI2Entities()) { KO = context.TLKNI_Order.Find(KO.KnitO_Pk); KO.KnitO_Closed = true; KO.KnitO_ClosedDate = dtpKnitOrderClosed.Value; var LNU = context.TLADM_LastNumberUsed.Find(2); var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault(); foreach (DataGridViewRow dr in dataGridView1.Rows) { if (dr.Cells[0].Value == null) { continue; } if (dr.Cells[3].Value != null && (bool)dr.Cells[3].Value == true) { if (dr.Cells[4].Value == null) { MessageBox.Show("When using the select button please select an alternative Knit Order to allocate against", "Line " + (dr.Index + 1).ToString()); return; } } TLKNI_YarnTransactionDetails trnsDet = new TLKNI_YarnTransactionDetails(); trnsDet.KnitYD_Notes = txtNotes.Text; trnsDet.KnitYD_OriginalOrderNo = KO.KnitO_OrderNumber; trnsDet.KnitYD_PalletNo_FK = (int)dr.Cells[0].Value; trnsDet.KnitYD_RTS = false; trnsDet.KnitYD_TransactionDate = dtpKnitOrderClosed.Value; trnsDet.KnitYD_WriteOff = false; if (LNU != null) { trnsDet.KnitYD_TransactionNumber = LNU.col7; } trnsDet.KnitYD_ApprovedBy = string.Empty; trnsDet.KnitYD_NoOfCones = (int)dr.Cells[1].Value; trnsDet.KnitYD_NettWeight = (decimal)dr.Cells[2].Value; trnsDet.KnitYD_GrossWeight = 0.00M; trnsDet.KnitYD_KnitY_FK = KO.KnitO_Pk; trnsDet.KnitYD_YarnReturned = true; Decimal WeightRecorded = (decimal)dr.Cells[2].Value; var Pallet = context.TLKNI_YarnOrderPallets.Find(trnsDet.KnitYD_PalletNo_FK); if (Pallet != null) { trnsDet.KnitYD_YarnType_FK = Pallet.TLKNIOP_YarnType_FK; if (dr.Cells[3].Value != null && (bool)dr.Cells[3].Value == true) { //====================================================================== // has to be a negative number to facilitate the calculations //================================================================= TLKNI_YarnAllocTransctions TransAlloc = new TLKNI_YarnAllocTransctions(); TransAlloc.TLKYT_KnitOrder_FK = KO.KnitO_Pk; TransAlloc.TLKYT_NettWeight = -1 * WeightRecorded; TransAlloc.TLKYT_NoOfCones = -1 * (int)dr.Cells[1].Value;; TransAlloc.TLKYT_TransDate = dtpKnitOrderClosed.Value; TransAlloc.TLKYT_TranType = 3; TransAlloc.TLKYT_YOP_FK = Pallet.TLKNIOP_Pk; context.TLKNI_YarnAllocTransctions.Add(TransAlloc); //================================================================= // Now find the pallet to which the balance is going to be added //======================================================== var ReservedBy = (int)dr.Cells[4].Value; var Trans = context.TLKNI_YarnAllocTransctions.Where(x => x.TLKYT_KnitOrder_FK == ReservedBy && x.TLKYT_TranType == 1).FirstOrDefault(); if (Trans != null) { var PalletTo = context.TLKNI_YarnOrderPallets.Find(Trans.TLKYT_YOP_FK); if (PalletTo != null) { PalletTo.TLKNIOP_AdditionalYarn += WeightRecorded; //============================================= // we need a record of this transaction //======================================== TransAlloc = new TLKNI_YarnAllocTransctions(); TransAlloc.TLKYT_KnitOrder_FK = ReservedBy; TransAlloc.TLKYT_NoOfCones += (int)dr.Cells[1].Value; TransAlloc.TLKYT_NettWeight = WeightRecorded; TransAlloc.TLKYT_TransDate = dtpKnitOrderClosed.Value; TransAlloc.TLKYT_TranType = 3; TransAlloc.TLKYT_YOP_FK = PalletTo.TLKNIOP_Pk; context.TLKNI_YarnAllocTransctions.Add(TransAlloc); if (core.CalculatePalletNett(PalletTo) <= 0.00m) { PalletTo.TLKNIOP_PalletAllocated = true; } else { PalletTo.TLKNIOP_PalletAllocated = false; } } } trnsDet.KnitYD_TransactionType = 2005; } else { var Cones = (int)dr.Cells[1].Value; WeightRecorded = (decimal)dr.Cells[2].Value; trnsDet.KnitYD_YarnReturned = true; Pallet.TLKNIOP_NettWeightReturned += WeightRecorded; //============================================= //we need a record of this transaction //======================================== var TransAlloc = new TLKNI_YarnAllocTransctions(); TransAlloc.TLKYT_KnitOrder_FK = KO.KnitO_Pk; TransAlloc.TLKYT_NettWeight = WeightRecorded; TransAlloc.TLKYT_NoOfCones = -Cones; TransAlloc.TLKYT_TransDate = dtpKnitOrderClosed.Value; TransAlloc.TLKYT_TranType = 2; TransAlloc.TLKYT_YOP_FK = Pallet.TLKNIOP_Pk; context.TLKNI_YarnAllocTransctions.Add(TransAlloc); //========================================= // This should make the pallet available //====================================================== if (core.CalculatePalletNett(Pallet) <= 0.00M) { Pallet.TLKNIOP_PalletAllocated = true; } else { Pallet.TLKNIOP_PalletAllocated = false; } //============================== // Now do the the swop between stores // dont have to do this for the above has it stays in WIP spinning //=================================================== if (Pallet.TLKNIOP_OwnYarn) { frmSelectStore selectStore = new frmSelectStore(); selectStore.ShowDialog(); Pallet.TLKNIOP_Store_FK = selectStore.WhseId; /* * TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 1400).FirstOrDefault(); * if (TranType != null) * Pallet.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; */ trnsDet.KnitYD_TransactionType = 1400; } else { if (Pallet.TLKNIOP_CommisionCust) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 1300).FirstOrDefault(); if (TranType != null) { Pallet.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; } trnsDet.KnitYD_TransactionType = 1300; } else { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 1200).FirstOrDefault(); if (TranType != null) { Pallet.TLKNIOP_Store_FK = (int)TranType.TrxT_ToWhse_FK; } trnsDet.KnitYD_TransactionType = 1200; } } } } context.TLKNI_YarnTransactionDetails.Add(trnsDet); } if (LNU != null) { LNU.col7 += 1; } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to database"); dataGridView1.Rows.Clear(); frmKnitViewRep vRep = new frmKnitViewRep(11, LNU.col7 - 1); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); frmCloseKnitOrder_Load(this, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
private void btnSave_Click(object sender, EventArgs e) { bool success = true; Button oBtn = sender as Button; if (oBtn != null && formloaded) { var ErrorM = core.returnMessage(MandSelected, true, MandatoryFields); if (!string.IsNullOrEmpty(ErrorM)) { MessageBox.Show(ErrorM); return; } using (var context = new TTI2Entities()) { TLSPN_CottonReceived cotrec = new TLSPN_CottonReceived(); var Contract = (TLADM_CottonContracts)cmbCottonContracts.SelectedItem; var Supplier = (TLADM_Cotton)cmbCottonSuppliers.SelectedItem; var Haulier = (TLADM_CottonHauliers)cmbHaulier.SelectedItem; var NoOfBales = Convert.ToInt32(txtNoOfBales.Text); //--------------------------------------------------------------------------------------------------- //Unfortunately hard coded at the moment //-------------------------------------------------------------------------------------------------- var DeptDetail = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "SPIN").FirstOrDefault(); var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Number == 100 && x.TrxT_Department_FK == DeptDetail.Dep_Id).FirstOrDefault(); if (TranType != null) { cotrec.CotReC_TranType_FK = TranType.TrxT_Pk; var CountTrx = context.TLSPN_CottonTransactions.Count(); if (CountTrx == 0) { //-------------------------------------------- //this means that this transaction is being run for the first time ie add a record of zeros to the Opening Balance table // This table will cater for future yearend //-------------------------------------------------------------------------------- TLSPN_OpenBalance openBal = new TLSPN_OpenBalance(); openBal.OpenBal_Store_FK = (int)TranType.TrxT_FromWhse_FK; openBal.OpenBal_GrossBaleWeight = 0M; openBal.OpenBal_NettBaleWeight = 0M; openBal.OpenBal_NoOfBales = 0; context.TLSPN_OpenBalance.Add(openBal); } } //---------------------------------------------------------------- // Now onto the main transaction //------------------------------------------------------------------- TLSPN_CottonTransactions CTS = new TLSPN_CottonTransactions(); CTS.cotrx_ContractNo_Fk = Contract.CottonCon_Pk; CTS.cotrx_Customer_FK = null; CTS.cotrx_GrossWeight = Convert.ToDecimal(txtSuppplierGrossWeight.Text); CTS.cotrx_LotNo = Convert.ToInt32(txtLotNo.Text); CTS.cotrx_NettPerWB = Convert.ToDecimal(txtCottonNettWeight.Text); CTS.cotrx_NetWeight = Convert.ToDecimal(txtSupplierNettWeight.Text); CTS.cotrx_NoBales = NoOfBales; CTS.cotrx_Notes = string.Empty; CTS.cotrx_Return_No = Convert.ToInt32(txtGrnNumber.Text); CTS.cotrx_Supplier_FK = Supplier.Cotton_Pk; CTS.cotrx_TransDate = dtpDateReceived.Value; CTS.cotrx_TranType = TranType.TrxT_Pk; CTS.cotrx_VehReg = txtVehReg.Text; CTS.cotrx_Haulier_FK = Haulier.Haul_Pk; CTS.cotrx_WeighBridgeEmpty = Convert.ToDecimal(txtWeighBridgeNett.Text); CTS.cotrx_WeighBridgeFull = Convert.ToDecimal(txtWeighBridgeGross.Text); CTS.cotrx_WriteOff = false; CTS.cottrx_NettAveBaleWeight = Convert.ToDecimal(txtNetAvgBaleWeight.Text); CTS.cotrx_GrossAveBaleWeight = Convert.ToDecimal(txtGrossAvgBaleWeight.Text); context.TLSPN_CottonTransactions.Add(CTS); //-------------------------------------------------------------------------------- var lastNumber = context.TLADM_LastNumberUsed.Find(1); if (lastNumber != null) { lastNumber.col1 += 1; lastNumber.col12 += 1; } try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (microAvailNo.Checked) { decimal micraFrom = 0.00M; decimal micraTo = 0.00M; decimal micraAvg = 0.00M; decimal staplefrom = 0.00M; decimal stapleto = 0.00M; decimal stapleAvg = 0.00M; var CottonContract = (TLADM_CottonContracts)cmbCottonContracts.SelectedItem; if (CottonContract != null) { micraFrom = CottonContract.CottonCon_MicraFrom; micraTo = CottonContract.CottonCon_MicraTo; staplefrom = CottonContract.CottonCon_StapleFrom; stapleto = CottonContract.CottonCon_StapleTo; if (micraFrom > 0 && micraTo > 0) { micraAvg = (micraFrom + micraTo) / 2; } else { micraAvg = 1; } if (staplefrom != 0 && stapleto != 0) { stapleAvg = (staplefrom + stapleto) / 2; } else { stapleAvg = 1; } } var n = 0; while (++n <= CTS.cotrx_NoBales) { TLSPN_CottonReceivedBales recBales = new TLSPN_CottonReceivedBales(); recBales.CotBales_BaleNo = n; recBales.CotBales_CotReceived_FK = cotrec.CotRec_Pk; recBales.CotBales_LotNo = Convert.ToInt32(txtLotNo.Text); recBales.CotBales_Mic = micraAvg; recBales.CotBales_Staple = stapleAvg; recBales.CotBales_Weight_Gross = Convert.ToDecimal(txtGrossAvgBaleWeight.Text); recBales.CotBales_Weight_Nett = Convert.ToDecimal(txtNetAvgBaleWeight.Text); recBales.CoBales_CottonSequence = Convert.ToInt32(txtGrnNumber.Text); context.TLSPN_CottonReceivedBales.Add(recBales); try { context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } if (success) { MessageBox.Show("Data stored to the database successfully"); int returnno = Convert.ToInt32(txtGrnNumber.Text); frmViewReport vRep = new frmViewReport(2, returnno); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); MandSelected = core.PopulateArray(MandatoryFields.Length, false); Setup(); } } }
private void btnAccess_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null & formloaded) { using (var context = new TTI2Entities()) { if (ConfirmPassword) { String Password = txtUserPassword.Text.Replace('*', ' '); if (Password.Length == 0) { using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show("Please enter a valid password"); } return; } String Confirm = txtConfirmPassword.Text.Replace('*', ' '); if (Confirm.Length == 0) { using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show("Please enter a validation password"); } return; } IsAuthorised = String.Equals(Password.Trim(), Confirm.Trim(), StringComparison.CurrentCulture); if (IsAuthorised) { var SelectedUser = (TLSEC_UserAccess)cmboUserDetails.SelectedItem; if (SelectedUser != null) { var User = context.TLSEC_UserAccess.Where(x => x.TLSECUA_UserName == SelectedUser.TLSECUA_UserName).FirstOrDefault(); if (User != null) { User.TLSECUA_ConfirmedPassword = true; User.TLSECUA_UserPassword = Password; UserName = User.TLSECUA_UserName; IsSuperUser = User.TLSECUA_SuperUser; UserPk = User.TLSECUA_Pk; IsExternal = User.TLSECUA_External; QAFunction = User.TLSECUA_QAFunction; try { context.SaveChanges(); } catch (Exception ex) { using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show(ex.Message); } } } } this.Close(); } else { using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show("Password not confirmed. Please reconfirm"); } return; } } else { var SelectedUser = (TLSEC_UserAccess)cmboUserDetails.SelectedItem; if (SelectedUser != null) { var User = context.TLSEC_UserAccess.Where(x => x.TLSECUA_UserName == SelectedUser.TLSECUA_UserName).FirstOrDefault(); if (User != null) { String Password = txtUserPassword.Text.Replace('*', ' '); String Confirm = User.TLSECUA_UserPassword; IsAuthorised = String.Equals(Password.Trim(), Confirm.Trim(), StringComparison.CurrentCulture); if (IsAuthorised) { UserName = User.TLSECUA_UserName; IsSuperUser = User.TLSECUA_SuperUser; UserPk = User.TLSECUA_Pk; IsExternal = User.TLSECUA_External; this.Close(); } else { using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box { MessageBox.Show("Please re-enter password", "Invalid Password for " + User.TLSECUA_UserName); } return; } } } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = sender as Button; Decimal weight = 0.00M; bool AddRec = false; TLADM_TranactionType TranType = null; if (oBtn != null && FormLoaded) { var Select = (TLDYE_DyeBatch)cmboBatchNumber.SelectedItem; if (Select == null) { MessageBox.Show("Please select a batch number from the drop down box "); return; } using (var context = new TTI2Entities()) { var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode == "DYE").FirstOrDefault(); if (Dept != null) { TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 1400).FirstOrDefault(); } foreach (DataGridViewRow row in dataGridView1.Rows) { TLDYE_DyeBatchDetails bd = new TLDYE_DyeBatchDetails(); int index = (int)row.Cells[0].Value; bd = context.TLDYE_DyeBatchDetails.Find(index); if (bd != null) { if ((bool)row.Cells[6].Value == true) { bd.DYEBO_Rejected = false; bd.DYEBO_RejectedDate = null; bd.DYEBO_QAApproved = true; bd.DYEBO_ApprovalDate = dtpTransDate.Value; bd.DYEBO_WasRejected = true; weight += (decimal)row.Cells[5].Value; bd.DYEBO_CurrentStore_FK = (int)TranType.TrxT_ToWhse_FK; AddRec = true; } } } if (AddRec) { var LNU = context.TLADM_LastNumberUsed.Find(3); TLDYE_DyeTransactions tt = new TLDYE_DyeTransactions(); tt.TLDYET_BatchNo = Select.DYEB_BatchNo; tt.TLDYET_BatchWeight = Select.DYEB_BatchKG; tt.TLDYET_SequenceNo = Select.DYEB_SequenceNo; tt.TLDYET_Batch_FK = Select.DYEB_Pk; tt.TLDYET_TransactionNumber = "RFREV" + LNU.col7.ToString().PadLeft(6, '0'); tt.TLDYET_Date = dtpTransDate.Value; tt.TLDYET_TransactionWeight = weight; tt.TLDYET_TransactionType = (int)TranType.TrxT_Pk; tt.TLDYET_CurrentStore_FK = (int)TranType.TrxT_ToWhse_FK; context.TLDYE_DyeTransactions.Add(tt); try { LNU.col7 += 1; context.SaveChanges(); MessageBox.Show("Data successfully saved to the database"); frmDyeViewReport vRep = new frmDyeViewReport(11, tt.TLDYET_Pk, true); vRep.ShowDialog(this); frmFabricReversal_Load(this, null); } catch (System.Data.Entity.Validation.DbEntityValidationException en) { foreach (var eve in en.EntityValidationErrors) { MessageBox.Show("following validation errors: Type" + eve.Entry.Entity.GetType().Name.ToString() + "State " + eve.Entry.State.ToString()); foreach (var ve in eve.ValidationErrors) { MessageBox.Show("- Property" + ve.PropertyName + " Message " + ve.ErrorMessage); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
private void btnSave_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; if (oBtn != null && FormLoaded) { var SingleRow = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>() where (bool)Rows.Cells[1].Value == true select Rows).FirstOrDefault(); if (SingleRow == null) { MessageBox.Show("Please select at least one CutSheet"); return; } if (rbPlaceOnHold.Checked) { if (txtAuthorisedBy.Text.Length == 0) { MessageBox.Show("Please complete the Authorised By field"); return; } if (txtReasons.Text.Length == 0) { MessageBox.Show("Please complete the Reasons"); return; } } using (var context = new TTI2Entities()) { foreach (DataGridViewRow Row in dataGridView1.Rows) { if (!(bool)Row.Cells[1].Value) { continue; } var PK = (int)Row.Cells[0].Value; var LineIssue = context.TLCMT_LineIssue.Find(PK); if (LineIssue != null) { if (rbPlaceOffHold.Checked) { LineIssue.TLCMTLI_OnHold = false; LineIssue.TLCMTLI_Reason = String.Empty; LineIssue.TLCMTLI_TransferApproved = String.Empty; } else { LineIssue.TLCMTLI_OnHold = true; LineIssue.TLCMTLI_Reason = txtReasons.Text;; LineIssue.TLCMTLI_TransferApproved = txtAuthorisedBy.Text; LineIssue.TLCMTLI_TransferDate = dtpTransDate.Value; } } } try { context.SaveChanges(); MessageBox.Show("Data successfully saved to the database"); if (RememberSave) { RememberSave = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { dataGridView1.Rows.Clear(); cmboDepartments.SelectedValue = -1; if (rbPlaceOnHold.Checked) { txtAuthorisedBy.Text = string.Empty; txtReasons.Text = string.Empty; } } } } }
private void btnSubmit_Click(object sender, EventArgs e) { Button oBtn = sender as Button; if (oBtn != null && FormLoaded) { DyeParameters.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()); DyeParameters.ToDate = Convert.ToDateTime(dtpToDate.Value.ToShortDateString()); DyeParameters.ToDate = DyeParameters.ToDate.AddHours(23); if (ViewData) { dataGridView1.Rows.Clear(); var DyeBatches = repo.SelectViewDyeBatches(DyeParameters); using (var context = new TTI2Entities()) { foreach (var DyeBatch in DyeBatches) { var index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = DyeBatch.DYEB_Pk; dataGridView1.Rows[index].Cells[1].Value = false; dataGridView1.Rows[index].Cells[2].Value = DyeBatch.DYEB_BatchNo; dataGridView1.Rows[index].Cells[3].Value = DyeBatch.DYEB_BatchDate; dataGridView1.Rows[index].Cells[4].Value = DyeBatch.DYEB_RequiredDate; dataGridView1.Rows[index].Cells[5].Value = Math.Round(DyeBatch.DYEB_BatchKG, 2); dataGridView1.Rows[index].Cells[6].Value = DyeBatch.DYEB_Notes; var Status = "No"; if (DyeBatch.DYEB_Closed) { Status = "Yes"; } dataGridView1.Rows[index].Cells[7].Value = Status; Status = "No"; if (DyeBatch.DYEB_Transfered) { Status = "Yes"; } dataGridView1.Rows[index].Cells[8].Value = Status; Status = "No"; if (DyeBatch.DYEB_Allocated) { Status = "Yes"; } dataGridView1.Rows[index].Cells[9].Value = Status; Status = "No"; if (DyeBatch.DYEB_Stage1) { Status = "Yes"; } dataGridView1.Rows[index].Cells[10].Value = Status; Status = "No"; if (DyeBatch.DYEB_Stage2) { Status = "Yes"; } dataGridView1.Rows[index].Cells[11].Value = Status; Status = "No"; if (DyeBatch.DYEB_Stage3) { Status = "Yes"; } dataGridView1.Rows[index].Cells[12].Value = Status; Status = "No"; if (DyeBatch.DYEB_OutProcess) { Status = "Yes"; } dataGridView1.Rows[index].Cells[13].Value = Status; var Pk = DyeBatch.DYEB_Greige_FK; dataGridView1.Rows[index].Cells[14].Value = context.TLADM_Griege.Find(Pk).TLGreige_Description; Pk = DyeBatch.DYEB_Colour_FK; dataGridView1.Rows[index].Cells[15].Value = context.TLADM_Colours.Find(Pk).Col_Display; } } comboColour.Items.Clear(); comboCustomers.Items.Clear(); comboQuality.Items.Clear(); } else { frmDyeViewReport vRep = new frmDyeViewReport(39, DyeParameters); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } } frmViewDyeBatches_Load(this, null); }
private void frmTransferConfirm_Load(object sender, EventArgs e) { formloaded = false; using (var context = new TTI2Entities()) { cmboWareHouse.DataSource = context.TLADM_WhseStore.Where(x => x.WhStore_WhseOrStore).ToList(); cmboWareHouse.ValueMember = "WhStore_Id"; cmboWareHouse.DisplayMember = "WhStore_Description"; cmboWareHouse.SelectedValue = -1; cmboDepartment.DataSource = context.TLADM_Departments.Where(x => x.Dep_IsCMT).ToList(); cmboDepartment.ValueMember = "Dep_Id"; cmboDepartment.DisplayMember = "Dep_Description"; cmboDepartment.SelectedValue = -1; oTxtA = new DataGridViewTextBoxColumn(); oTxtA.Visible = false; oTxtA.ValueType = typeof(int); dataGridView1.Columns.Add(oTxtA); oChkA = new DataGridViewCheckBoxColumn(); oChkA.HeaderText = "Select"; oChkA.Visible = true; oChkA.ValueType = typeof(bool); dataGridView1.Columns.Add(oChkA); oTxtB = new DataGridViewTextBoxColumn(); oTxtB.HeaderText = "Picking List"; oTxtB.ReadOnly = true; oTxtB.ValueType = typeof(string); dataGridView1.Columns.Add(oTxtB); oTxtC = new DataGridViewTextBoxColumn(); oTxtC.HeaderText = "From"; oTxtC.ReadOnly = true; oTxtC.ValueType = typeof(string); dataGridView1.Columns.Add(oTxtC); oTxtD = new DataGridViewTextBoxColumn(); oTxtD.HeaderText = "To"; oTxtD.ReadOnly = true; oTxtD.ValueType = typeof(string); dataGridView1.Columns.Add(oTxtD); oTxtE = new DataGridViewTextBoxColumn(); oTxtE.HeaderText = "Date"; oTxtE.ReadOnly = true; oTxtE.ValueType = typeof(DateTime); dataGridView1.Columns.Add(oTxtE); dataGridView1.AllowUserToAddRows = false; dataGridView1.AutoGenerateColumns = false; oTxtBA = new DataGridViewTextBoxColumn(); oTxtBA.Visible = false; oTxtBA.ValueType = typeof(int); dataGridView2.Columns.Add(oTxtBA); oChkBA = new DataGridViewCheckBoxColumn(); oChkBA.HeaderText = "Confirm"; oChkBA.Visible = true; oChkBA.ValueType = typeof(bool); dataGridView2.Columns.Add(oChkBA); oTxtBB = new DataGridViewTextBoxColumn(); oTxtBB.HeaderText = "Picking List"; oTxtBB.ReadOnly = true; oTxtBB.ValueType = typeof(string); dataGridView2.Columns.Add(oTxtBB); oTxtBC = new DataGridViewTextBoxColumn(); oTxtBC.HeaderText = "Box Number"; oTxtBC.ReadOnly = true; oTxtBC.ValueType = typeof(string); dataGridView2.Columns.Add(oTxtBC); oTxtBD = new DataGridViewTextBoxColumn(); oTxtBD.HeaderText = "Style"; oTxtBD.ReadOnly = true; oTxtBD.ValueType = typeof(string); dataGridView2.Columns.Add(oTxtBD); oTxtBE = new DataGridViewTextBoxColumn(); oTxtBE.HeaderText = "Colour"; oTxtBE.ReadOnly = true; oTxtBE.ValueType = typeof(string); dataGridView2.Columns.Add(oTxtBE); oTxtBF = new DataGridViewTextBoxColumn(); oTxtBF.HeaderText = "Size"; oTxtBF.ReadOnly = true; oTxtBF.ValueType = typeof(string); dataGridView2.Columns.Add(oTxtBF); oTxtBG = new DataGridViewTextBoxColumn(); oTxtBG.HeaderText = "Boxed Qty"; oTxtBG.ReadOnly = true; oTxtBG.ValueType = typeof(int); dataGridView2.Columns.Add(oTxtBG); oTxtBH = new DataGridViewTextBoxColumn(); oTxtBH.HeaderText = "Grade"; oTxtBH.ReadOnly = true; oTxtBH.ValueType = typeof(String); dataGridView2.Columns.Add(oTxtBH); dataGridView2.AllowUserToAddRows = false; dataGridView2.AutoGenerateColumns = false; } formloaded = true; }