private void button3_Click(object sender, EventArgs e) { if (textBox1.Text != "") { SuppliesTransaction sT = (from x in cheese.SuppliesTransactions where x.SuppliesTransactionID.Equals(textBox1.Text) select x).First(); var dST = from x in cheese.DetailSuppliesTransactions where x.SuppliesTransactionID.Equals(textBox1.Text) select x; if (sT != null) { sT.SuppliesTransactionDescription = textBox2.Text; sT.SuppliesTransactionStatus = "Checked"; sT.UpdatedBy = _MainForm.userID; cheese.SaveChanges(); loadData(); clear(); EnabledStatus(false); ButtonStatus(true); label10.Visible = false; GoodsReceipt gR = new GoodsReceipt(); string newID = generateGoodsReceiptID(); gR.GoodsReceiptID = newID; gR.SuppliesTransactionID = textBox1.Text; gR.CreatedBy = _MainForm.userID; gR.GoodsReceiptDate = DateTime.Now; gR.GoodsReceiptDescription = "No Description"; //gR.GoodsReceiptStatus = "Unchecked"; //gR.UpdatedBy = ""; cheese.GoodsReceipts.Add(gR); //cheese.SaveChanges(); foreach (DetailSuppliesTransaction detail in dST) { DetailGoodsReceipt dGR = new DetailGoodsReceipt(); dGR.GoodsReceiptID = newID; dGR.MilkID = detail.MilkID.ToString(); dGR.Quantity = (Int32)detail.Quantity; //dGR.Price = (Int32)detail.Price; //dGR.VendorID = detail.VendorID; cheese.DetailGoodsReceipts.Add(dGR); //cheese.SaveChanges(); } cheese.SaveChanges(); loadData(); clear(); textBox1.Text = ""; MessageBox.Show("Data Updated"); } } }
private void button3_Click(object sender, EventArgs e) { if (textBox1.Text != "") { GoodsReceipt gR = (from x in cheese.GoodsReceipts where x.GoodsReceiptID.Equals(textBox1.Text) select x).First(); if (gR != null) { var dGR = from x in cheese.DetailGoodsReceipts where x.GoodsReceiptID.Equals(textBox1.Text) select x; gR.GoodsReceiptDescription = textBox2.Text; cheese.SaveChanges(); GoodsReceiptCheck gRC = new GoodsReceiptCheck(); string newID = generateGoodsReceiptCheckID(); gRC.GoodsReceiptID = textBox1.Text; gRC.GoodsReceiptCheckID = newID; gRC.CreatedBy = _MainForm.userID; gRC.GoodsReceiptCheckDate = DateTime.Now; cheese.GoodsReceiptChecks.Add(gRC); //cheese.SaveChanges(); foreach (DetailGoodsReceipt detail in dGR) { DetailGoodsReceiptCheck dGRC = new DetailGoodsReceiptCheck(); dGRC.GoodsReceiptCheckID = newID; dGRC.MilkID = detail.MilkID.ToString(); dGRC.Quantity = (Int32)detail.Quantity; cheese.DetailGoodsReceiptChecks.Add(dGRC); //cheese.SaveChanges(); } cheese.SaveChanges(); textBox1.Text = ""; MessageBox.Show("Data Updated"); loadData(); clear(); EnabledStatus(false); ButtonStatus(true); label10.Visible = false; } } }
private void dataGridView5_CellContentClick(object sender, DataGridViewCellEventArgs e) { clear(); if (e.RowIndex >= 0) { textBox5.Text = dataGridView5.Rows[e.RowIndex].Cells[0].Value.ToString(); textBox1.Text = dataGridView5.Rows[e.RowIndex].Cells[1].Value.ToString(); textBox4.Text = dataGridView5.Rows[e.RowIndex].Cells[2].Value.ToString(); FinalGoodsReceipt finalGoodsReceipt = (from x in cheese.FinalGoodsReceipts where x.FinalGoodsReceiptID.Equals(textBox4.Text) select x).First(); GoodsReceipt goodsReceipt = (from x in cheese.GoodsReceipts where x.SuppliesTransactionID.Equals(textBox1.Text) select x).First(); textBox2.Text = goodsReceipt.GoodsReceiptID; GoodsReceiptCheck goodsReceiptCheck = (from x in cheese.GoodsReceiptChecks where x.GoodsReceiptID.Equals(textBox2.Text) select x).First(); textBox3.Text = goodsReceiptCheck.GoodsReceiptCheckID; var suppliesTransaction = (from x in cheese.SuppliesTransactions where x.SuppliesTransactionID.Equals(textBox1.Text) select new { x.SuppliesTransactionID, x.SuppliesTransactionStatus, x.SuppliesTransactionDescription }); var detailSuppliesTransaction = (from x in cheese.DetailSuppliesTransactions where x.SuppliesTransactionID.Equals(textBox1.Text) select new { x.MilkID, x.VendorID, x.Price }); var finalGoodsReceiptTemp = (from x in cheese.FinalGoodsReceipts where x.FinalGoodsReceiptID.Equals(textBox4.Text) select new { x.FinalGoodsReceiptID, x.FinalGoodsReceiptDate }); var detailFinalGoodsReceipt = (from x in cheese.DetailFinalGoodsReceipts where x.FinalGoodsReceiptID.Equals(textBox4.Text) select new { x.MilkID, x.Quantity }); dataGridView1.DataSource = finalGoodsReceiptTemp.ToList(); dataGridView2.DataSource = detailFinalGoodsReceipt.ToList(); dataGridView3.DataSource = suppliesTransaction.ToList(); dataGridView4.DataSource = detailSuppliesTransaction.ToList(); if (textBox5.Text == "") { enableStatus(false); } else { VerifiedInvoice verifiedInvoice = (from x in cheese.VerifiedInvoices where x.VerifiedInvoiceID.Equals(textBox5.Text) select x).First(); if (verifiedInvoice.VerifiedInvoiceStatus == "Created") { enableStatus(true); } else { enableStatus(false); } } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); GoodsReceipt goodsReceipt = (from x in cheese.GoodsReceipts where x.SuppliesTransactionID.Equals(textBox1.Text) select x).First(); textBox2.Text = goodsReceipt.GoodsReceiptID; GoodsReceiptCheck goodsReceiptCheck = (from x in cheese.GoodsReceiptChecks where x.GoodsReceiptID.Equals(textBox2.Text) select x).First(); textBox3.Text = goodsReceiptCheck.GoodsReceiptCheckID; FinalGoodsReceipt finalGoodsReceipt = (from x in cheese.FinalGoodsReceipts where x.GoodsReceiptCheckID.Equals(textBox3.Text) select x).First(); textBox4.Text = finalGoodsReceipt.FinalGoodsReceiptID; loadDetail(); /* if (textBox4.Text != "") * { * var finalGoodsReceiptTemp = from x in cheese.FinalGoodsReceipts select x; * if (finalGoodsReceiptTemp.Count() > 0) * { * FinalGoodsReceipt fGR = (from x in cheese.FinalGoodsReceipts where x.GoodsReceiptCheckID.Equals(textBox3.Text) select x).First(); * if (fGR != null) * { * enableStatus(false); * } * } * }*/ var detailSuppliesTransaction = from x in cheese.DetailSuppliesTransactions where x.SuppliesTransactionID == textBox1.Text select new { x.MilkID, x.Price, x.Quantity, x.VendorID }; dataGridView2.DataSource = detailSuppliesTransaction.ToList(); if (detailSuppliesTransaction != null) { dataGridView2.Enabled = true; } else { dataGridView2.Enabled = false; } numericUpDown1.Value = 0; } }