コード例 #1
0
        private void btnadd_Click(object sender, EventArgs e)
        {
            db = new db_MiletecDataContext();

            if (txtQuantityOrder.Text != "Quantity Order" && txtShowSupplier.Text != "Supplier ID" && cmbProductID.Text != "" && txtProductName.Text != "Product Name")
            {
                if (int.Parse(txtQuantityOrder.Text) <= 0)
                {
                    MessageBox.Show("fill up quantity first!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Successfully Added!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    dgvOrderDetails.Rows.Add(cmbProductID.Text, txtProductName.Text, int.Parse(txtQuantityOrder.Text));
                    db.sp_OrderDetails(txtOrderID.Text, cmbProductID.Text, txtProductName.Text, int.Parse(txtQuantityOrder.Text), "To Deliver");
                    db.sp_Products(txtSupplierID.Text, cmbProductID.Text, txtProductName.Text, int.Parse(txtQuantityOrder.Text));
                    db.SubmitChanges();
                    cmbProductID.SelectedItem = null;
                    lblproductid.Text         = "Product ID";
                    txtProductName.Text       = "Product Name";
                    txtQuantityOrder.Text     = "Quantity Order";
                    btnPurchase.Enabled       = true;
                }
            }
            else
            {
                MessageBox.Show("Please fill up everything!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }