コード例 #1
0
ファイル: Stock.cs プロジェクト: AswinPG/ShopBillingApp
        private void BtnAddStock_Click(object sender, EventArgs e)
        {
            StockBAL sb = new StockBAL();
            StockDAL sd = new StockDAL();

            if (TxtProductName.Text.Trim() != "")
            {
                LoadProductID();
                sb.ProductID = ProductID;
                sb.Quantity  = Convert.ToInt32(TxtQuantity.Text.Trim());
                int Result = sd.AddStockDetails(sb);
                if (Result == 1)
                {
                    MessageBox.Show("Product Added Succesfully");
                    LoadDGVStock();
                }
                else
                {
                    MessageBox.Show("Something Went Wrong");
                }
            }
            else
            {
                MessageBox.Show("Product Name Cannot be empty");
            }
        }
コード例 #2
0
ファイル: Stock.cs プロジェクト: AswinPG/ShopBillingApp
        private void TxtQuantity_KeyPress(object sender, KeyPressEventArgs e)
        {
            const int BACKSPACE = 8;
            const int ZERO      = 48;
            const int NINE      = 57;
            //const int NOT_FOUND = -1;
            int keyvalue = (int)e.KeyChar;

            if ((keyvalue == BACKSPACE) ||
                ((keyvalue >= ZERO) && (keyvalue <= NINE)))
            {
                return;
            }
            //Allow the first (but only the first) decimal point
            //if ((keyvalue == DECIMAL_POINT) &&
            //(TextPostCode.Text.IndexOf(".") == NOT_FOUND)) return;
            //Allow nothing else
            e.Handled = true;

            if (e.KeyChar == 13)
            {
                StockBAL sb = new StockBAL();
                StockDAL sd = new StockDAL();
                if (TxtProductName.Text.Trim() != "")
                {
                    LoadProductID();
                    sb.ProductID = ProductID;
                    sb.Quantity  = Convert.ToInt32(TxtQuantity.Text.Trim());
                    int Result = sd.AddStockDetails(sb);
                    if (Result == 1)
                    {
                        MessageBox.Show("Product Added Succesfully");
                        LoadDGVStock();
                    }
                    else
                    {
                        MessageBox.Show("Something Went Wrong");
                    }
                }
                else
                {
                    MessageBox.Show("Product Name Cannot be empty");
                }
            }
        }