private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                var goodsReceipt = (from x in cheese.GoodsReceipts where x.SuppliesTransactionID.Equals(textBox1.Text) select x).First();
                textBox2.Text = goodsReceipt.GoodsReceiptID;
                var goodsReceiptCheck = (from x in cheese.GoodsReceiptChecks where x.GoodsReceiptID.Equals(textBox2.Text) select x).First();
                textBox3.Text = goodsReceiptCheck.GoodsReceiptCheckID;

                textBox5.Text = "IS Description : " + dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString() + ", QM Description : " + goodsReceipt.GoodsReceiptDescription;
                loadDetail();
                ButtonStatus(true);
                if (textBox3.Text != "")
                {
                    var finalGoodsReceipt = from x in cheese.FinalGoodsReceipts select x;
                    if (finalGoodsReceipt.Count() > 0)
                    {
                        FinalGoodsReceipt fGR = (from x in cheese.FinalGoodsReceipts where x.GoodsReceiptCheckID.Equals(textBox3.Text) select x).First();
                        if (fGR != null)
                        {
                            btnDisabled();
                        }
                    }
                }

                var detailSuppliesTransaction = from x in cheese.DetailSuppliesTransactions
                                                where x.SuppliesTransactionID == textBox1.Text
                                                select new { x.MilkID, x.Price, x.Quantity, x.VendorID };
                dataGridView4.DataSource = detailSuppliesTransaction.ToList();
                if (detailSuppliesTransaction != null)
                {
                    dataGridView2.Enabled = true;
                }
                else
                {
                    dataGridView2.Enabled = false;
                }
                textBox7.Text        = "";
                numericUpDown1.Value = 0;
            }
        }
Esempio n. 2
0
        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;
            }
        }
        private void loadDetail()
        {
            var finalGoodsReceipt = from x in cheese.FinalGoodsReceipts
                                    where x.GoodsReceiptCheckID.Equals(textBox3.Text)
                                    select new { x.FinalGoodsReceiptID, x.FinalGoodsReceiptDate };

            dataGridView3.DataSource = finalGoodsReceipt.ToList();
            if (finalGoodsReceipt != null)
            {
                dataGridView3.Enabled = true;
            }
            else
            {
                dataGridView3.Enabled = false;
            }
            if (dataGridView3.RowCount > 0)
            {
                FinalGoodsReceipt fGR       = (from x in cheese.FinalGoodsReceipts where x.GoodsReceiptCheckID.Equals(textBox3.Text) select x).First();
                var detailFinalGoodsReceipt = from x in cheese.DetailFinalGoodsReceipts where x.FinalGoodsReceiptID.Equals(fGR.FinalGoodsReceiptID) select new { x.MilkID, x.Quantity };
                dataGridView4.DataSource = detailFinalGoodsReceipt.ToList();
            }
        }
 private void button3_Click(object sender, EventArgs e)
 {
     if (cartRow > 0)
     {
         if (cartRow == dataGridView3.RowCount - 1)
         {
             string            newID = generateFinalGoodsReceiptID();
             FinalGoodsReceipt fGR   = new FinalGoodsReceipt();
             fGR.FinalGoodsReceiptID   = newID;
             fGR.GoodsReceiptCheckID   = textBox3.Text;
             fGR.FinalGoodsReceiptDate = DateTime.Now;
             fGR.CreatedBy             = _MainForm.userID;
             cheese.FinalGoodsReceipts.Add(fGR);
             foreach (DataRow row in tableCart.Rows)
             {
                 DetailFinalGoodsReceipt dFGR = new DetailFinalGoodsReceipt();
                 dFGR.FinalGoodsReceiptID = newID;
                 dFGR.MilkID   = row.Field <string>(0);
                 dFGR.Quantity = Int32.Parse(row.Field <string>(1));
                 cheese.DetailFinalGoodsReceipts.Add(dFGR);
             }
             cheese.SaveChanges();
             loadData();
             loadDetail();
             clear();
             EnabledStatus(false);
             ButtonStatus(true);
             label10.Visible = false;
             tableCart.Clear();
             flag = 0;
             dataGridView1.Enabled = true;
         }
         else
         {
             label10.Text    = "You Must Insert All Items";
             label10.Visible = true;
         }
     }
 }