コード例 #1
0
        private void btnProceed_Click(object sender, EventArgs e)
        {
            db = new db_MiletecDataContext();
            if (txtOrderID.Text != "Order No.")
            {
                if (dgvProductDetails.CurrentRow.Cells[3].Value.ToString() == "Delivered")
                {
                    MessageBox.Show("Product was already delivered!!");
                    dgvProductDetails.Rows.Remove(dgvProductDetails.CurrentRow);
                }

                else if (txtOrderID.Text != "Order No." && txtDeliveryNo.Text != "Delivery No.")
                {
                    db.sp_DeliveryDetails(txtDeliveryNo.Text, txtOrderID.Text, txtProdID.Text, DateTime.Parse(dtpDate.Text), ProductName, int.Parse(Qty));
                    dgvDeliverditems.Rows.Add(txtProdID.Text, ProductName, DateTime.Now);
                    lblreceivedby.Text = Form1.name.ToString();
                    MessageBox.Show("Successfully delivered!!");
                    db.sp_update_tblOrderDetails(txtOrderID.Text, txtProdID.Text, "Delivered");
                    var query_Price = db.sp_RetrieveStocksQuantity(txtProdID.Text, ProductName);
                    foreach (sp_RetrieveStocksQuantityResult entry in query_Price.ToList())
                    {
                        oldQty = int.Parse(entry.availqty.ToString());
                        newQty = int.Parse(Qty) + oldQty;
                        if (txtProdID.Text == "ProductID-0001")
                        {
                            db.sp_Update_StocksQty(txtProdID.Text, newQty);
                        }
                        else if (txtProdID.Text == "Product-0002")
                        {
                            db.sp_Update_StocksQty(txtProdID.Text, newQty);
                        }
                        else
                        {
                            db.sp_Update_StocksQty(txtProdID.Text, newQty);
                        }
                    }
                    dgvProductDetails.Rows.Remove(dgvProductDetails.CurrentRow);
                }

                else
                {
                    MessageBox.Show("Please Add first the OrderID that you want to be delivered!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //GenDelID(txtDeliveryNo);
        }