void SetUp(bool xSel) { IList <TLKNI_GreigeProduction> Existing = new List <TLKNI_GreigeProduction>(); formloaded = false; CheckFired = false; dataGridView2.Rows.Clear(); using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(3); if (LNU != null) { txtNumber.Text = "DA" + LNU.col6.ToString().PadLeft(6, '0'); } if (xSel) { var Query = from T1 in context.TLDYE_DyeBatch join T2 in context.TLDYE_DyeBatchDetails on T1.DYEB_Pk equals T2.DYEBD_DyeBatch_FK where !T1.DYEB_Closed && !T1.DYEB_CommissinCust && T1.DYEB_Allocated && T1.DYEB_Transfered && !T2.DYEBO_Rejected && !T2.DYEBO_CutSheet && !T2.DYEBO_WriteOff select new { T1.DYEB_Pk, T1.DYEB_BatchNo, T1.DYEB_DyeOrder_FK, T1.DYEB_Colour_FK, T1.DYEB_Allocated, T1.DYEB_Transfered }; var QueryGroup = Query.OrderBy(x => x.DYEB_BatchNo).GroupBy(x => x.DYEB_BatchNo); foreach (var BatchGroup in QueryGroup) { TLDYE_DyeBatch DB = new TLDYE_DyeBatch(); DB.DYEB_Pk = BatchGroup.FirstOrDefault().DYEB_Pk; DB.DYEB_DyeOrder_FK = BatchGroup.FirstOrDefault().DYEB_DyeOrder_FK; DB.DYEB_BatchNo = BatchGroup.FirstOrDefault().DYEB_BatchNo; DB.DYEB_Colour_FK = BatchGroup.FirstOrDefault().DYEB_Colour_FK; DB.DYEB_Allocated = BatchGroup.FirstOrDefault().DYEB_Allocated; DB.DYEB_Transfered = BatchGroup.FirstOrDefault().DYEB_Transfered; cmboDyeBatches.Items.Add(DB); cmboDyeBatches.ValueMember = "DYEB_Pk"; cmboDyeBatches.DisplayMember = "DYEB_BatchNo"; } cmboDyeBatches.SelectedValue = -1; } } MandSelected = core.PopulateArray(MandatoryFields.Length, false); formloaded = true; }
private void frmFabricReversal_Load(object sender, EventArgs e) { FormLoaded = false; dataGridView1.Rows.Clear(); using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(3); if (LNU != null) { txtGrnNumber.Text = "RFREV" + LNU.col7.ToString().PadLeft(6, '0'); } var Query = from T1 in context.TLDYE_DyeBatch join T2 in context.TLDYE_DyeBatchDetails on T1.DYEB_Pk equals T2.DYEBD_DyeBatch_FK where T2.DYEBO_Rejected select new { T1.DYEB_Pk, T1.DYEB_BatchNo, T1.DYEB_DyeOrder_FK, T1.DYEB_Colour_FK }; var QueryGroup = Query.OrderBy(x => x.DYEB_BatchNo).GroupBy(x => x.DYEB_BatchNo); foreach (var BatchGroup in QueryGroup) { TLDYE_DyeBatch DB = new TLDYE_DyeBatch(); DB.DYEB_Pk = BatchGroup.FirstOrDefault().DYEB_Pk; DB.DYEB_DyeOrder_FK = BatchGroup.FirstOrDefault().DYEB_DyeOrder_FK; DB.DYEB_BatchNo = BatchGroup.FirstOrDefault().DYEB_BatchNo; DB.DYEB_Colour_FK = BatchGroup.FirstOrDefault().DYEB_Colour_FK; cmboBatchNumber.Items.Add(DB); } cmboBatchNumber.ValueMember = "DYEB_Pk"; cmboBatchNumber.DisplayMember = "DYEB_BatchNo"; cmboBatchNumber.SelectedValue = -1; txtBatchFabricKg.Text = "0.0"; txtBatchGreigeKg.Text = "0.0"; txtColour.Text = string.Empty; txtCustomerDetails.Text = string.Empty; txtDyeOrder.Text = string.Empty; } FormLoaded = true; }
void SetUp() { formloaded = false; dataGridView1.Rows.Clear(); dataGridView1.AllowUserToAddRows = false; dataGridView1.AutoGenerateColumns = false; using (var context = new TTI2Entities()) { var LNU = context.TLADM_LastNumberUsed.Find(3); if (LNU != null) { txtGrnNumber.Text = "RF" + LNU.col7.ToString().PadLeft(6, '0'); } var Query = (from T1 in context.TLDYE_DyeBatch join T2 in context.TLDYE_DyeBatchDetails on T1.DYEB_Pk equals T2.DYEBD_DyeBatch_FK join T3 in context.TLKNI_GreigeProduction on T2.DYEBD_GreigeProduction_FK equals T3.GreigeP_Pk where !T2.DYEBO_Sold && !T2.DYEBO_Rejected && !T2.DYEBO_CutSheet && !T2.DYEBO_QAApproved && T1.DYEB_OutProcess && T1.DYEB_Allocated && !T1.DYEB_CommissinCust && T3.GreigeP_Dye select T1).OrderBy(x => x.DYEB_BatchNo).GroupBy(x => x.DYEB_BatchNo); foreach (var BatchGroup in Query) { TLDYE_DyeBatch DB = new TLDYE_DyeBatch(); DB.DYEB_Pk = BatchGroup.FirstOrDefault().DYEB_Pk; DB.DYEB_BatchNo = BatchGroup.FirstOrDefault().DYEB_BatchNo; DB.DYEB_DyeOrder_FK = BatchGroup.FirstOrDefault().DYEB_DyeOrder_FK; DB.DYEB_Colour_FK = BatchGroup.FirstOrDefault().DYEB_Colour_FK; cmboBatchNumber.Items.Add(DB); } cmboBatchNumber.ValueMember = "DYEB_Pk"; cmboBatchNumber.DisplayMember = "DYEB_BatchNo"; } txtBatchFabricKg.Text = "0.0"; txtBatchGreigeKg.Text = "0.0"; txtColour.Text = string.Empty; txtCustomerDetails.Text = string.Empty; txtDyeOrder.Text = string.Empty; formloaded = true; }
void Setup() { formloaded = false; dataGridView1.Rows.Clear(); using (var context = new TTI2Entities()) { var Query = from T1 in context.TLDYE_DyeBatch join T2 in context.TLDYE_DyeBatchDetails on T1.DYEB_Pk equals T2.DYEBD_DyeBatch_FK where !T2.DYEBO_QAApproved && !T1.DYEB_OnHold select new { T1.DYEB_Pk, T1.DYEB_BatchNo, T1.DYEB_DyeOrder_FK, T1.DYEB_Colour_FK }; var QueryGroup = Query.OrderBy(x => x.DYEB_BatchNo).GroupBy(x => x.DYEB_BatchNo); foreach (var BatchGroup in QueryGroup) { TLDYE_DyeBatch DB = new TLDYE_DyeBatch(); DB.DYEB_Pk = BatchGroup.FirstOrDefault().DYEB_Pk; DB.DYEB_DyeOrder_FK = BatchGroup.FirstOrDefault().DYEB_DyeOrder_FK; DB.DYEB_BatchNo = BatchGroup.FirstOrDefault().DYEB_BatchNo; DB.DYEB_Colour_FK = BatchGroup.FirstOrDefault().DYEB_Colour_FK; cmboBatchNumber.Items.Add(DB); } cmboBatchNumber.ValueMember = "DYEB_Pk"; cmboBatchNumber.DisplayMember = "DYEB_BatchNo"; cmboBatchNumber.SelectedValue = -1; } txtBatchFabricKg.Text = "0.0"; txtBatchGreigeKg.Text = "0.0"; txtColour.Text = string.Empty; txtCustomerDetails.Text = string.Empty; txtDyeOrder.Text = string.Empty; formloaded = true; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView oDgv = sender as DataGridView; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewCheckBoxCell) { TLDYE_DyeBatch db = new TLDYE_DyeBatch(); using (var context = new TTI2Entities()) { int DyeBatchKey = (int)oDgv.CurrentRow.Cells[0].Value; db = context.TLDYE_DyeBatch.Find(DyeBatchKey); if (db != null) { db.DYEB_Transfered = true; db.DYEB_TransferDate = dtpTransferDate.Value; var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("DYE")).FirstOrDefault(); if (Dept != null) { var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 300).FirstOrDefault(); if (TranType != null) { db.DYEB_TransactionType_FK = TranType.TrxT_Pk; } } TLDYE_DyeTransactions dt = new TLDYE_DyeTransactions(); dt.TLDYET_BatchNo = db.DYEB_BatchNo; dt.TLDYET_BatchWeight = db.DYEB_BatchKG; dt.TLDYET_Date = dtpTransferDate.Value; dt.TLDYET_SequenceNo = db.DYEB_SequenceNo; dt.TLDYET_TransactionType = db.DYEB_TransactionType_FK; dt.TLDYET_Batch_FK = db.DYEB_Pk; dt.TLDYET_Stage = 2; dt.TLDYET_CurrentStore_FK = (int)context.TLADM_TranactionType.Find(db.DYEB_TransactionType_FK).TrxT_ToWhse_FK; context.TLDYE_DyeTransactions.Add(dt); var DBD = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == db.DYEB_Pk).ToList(); foreach (var rowx in DBD) { rowx.DYEBO_CurrentStore_FK = dt.TLDYET_CurrentStore_FK; } try { context.SaveChanges(); frmDyeViewReport vRep = new frmDyeViewReport(8, DyeBatchKey); int h = Screen.PrimaryScreen.WorkingArea.Height; int w = Screen.PrimaryScreen.WorkingArea.Width; vRep.ClientSize = new Size(w, h); vRep.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } oDgv.Rows.RemoveAt(oDgv.CurrentRow.Index); } }
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; */ } } } } }