示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            stock = new StockClass();
            //i = dataGridView1.SelectedCells[0].RowIndex;

            if (txtName.Text == "" || cbxCategory.Text == "" || txtUnitPrice.Text == "")
            {
                XtraMessageBox.Show("Please fill in MANDATORY FIELDS marked with Asterics", "iBallInventory", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                ShowAsterics();
                //txtName.Text.Trim().ToString()==""|| cbxCategory.Text.Trim().ToString()==""||txtManufac.Text.Trim().ToString()==""||txtSellingPrice.Text.Trim().ToString()==""||txtStockQty.Text.Trim().ToString()==""||txtDateBought.Text.Trim().ToString()==""||txtExpiryDate.Text.Trim().ToString()==""||txtUnitPrice.Text.Trim().ToString()==""
            }
            else
            {
                try
                {
                    stock.itemName      = txtName.Text.Trim().ToString();
                    stock.category      = cbxCategory.Text.Trim().ToString();
                    stock.manufacturer  = txtManufac.Text.Trim().ToString();
                    stock.grossPrice    = txtGrossPrice.Text.Trim().ToString();
                    stock.stockQuantity = txtStockQty.Text.Trim().ToString();
                    stock.dateBought    = txtDateBought.Text.Trim().ToString();
                    stock.expiryDate    = txtExpiryDate.Text.Trim().ToString();
                    //stock.quantitySold = dataGridView1.Rows[i].Cells[7].Value.ToString();
                    stock.unitPrice = txtUnitPrice.Text.Trim().ToString();
                    //stock.badProduct = dataGridView1.Rows[i].Cells[9].Value.ToString();

                    //Validate inputs provided
                    ValidateInputs(stock.itemName, stock.category, stock.manufacturer, stock.grossPrice, stock.stockQuantity, stock.dateBought, stock.expiryDate, stock.unitPrice);
                }
                catch (MySqlException ex)
                {
                    XtraMessageBox.Show("Oops!!\n" + ex.Message);
                }
            }
        }
示例#2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            stock = new StockClass();
            i     = dataGridView1.SelectedCells[0].RowIndex;

            //XtraMessageBox.Show(dataGridView1.Rows[i].Cells[0].Value.ToString());
            try
            {
                stock.itemName      = dataGridView1.Rows[i].Cells[0].Value.ToString();
                currentName         = dataGridView1.Rows[i].Cells[0].Value.ToString();
                stock.category      = dataGridView1.Rows[i].Cells[1].Value.ToString();
                stock.manufacturer  = dataGridView1.Rows[i].Cells[2].Value.ToString();
                stock.grossPrice    = dataGridView1.Rows[i].Cells[3].Value.ToString();
                stock.stockQuantity = dataGridView1.Rows[i].Cells[4].Value.ToString();
                stock.dateBought    = dataGridView1.Rows[i].Cells[5].Value.ToString();
                stock.expiryDate    = dataGridView1.Rows[i].Cells[6].Value.ToString();
                stock.quantitySold  = dataGridView1.Rows[i].Cells[7].Value.ToString();
                stock.unitPrice     = dataGridView1.Rows[i].Cells[8].Value.ToString();
                stock.badProduct    = dataGridView1.Rows[i].Cells[9].Value.ToString();

                //XtraMessageBox.Show(dataGridView1.Rows[i].Cells[8].Value.ToString());
            }
            catch (Exception ex)
            {
                //XtraMessageBox.Show(ex.Message);
                return;
            }

            setControlsData(stock.itemName, stock.category, stock.manufacturer, stock.grossPrice, stock.stockQuantity, stock.dateBought, stock.expiryDate, stock.quantitySold, stock.unitPrice, stock.badProduct);
        }