Example #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     Shared.Product prod = new Shared.Product();
     prod.productName        = txtName.Text;
     prod.productDescription = txtDesc.Text;
     prod.unit      = cmbUnit.Text;
     prod.catID     = Convert.ToInt32(cmbCategory.SelectedValue);
     prod.companyID = Convert.ToInt32(cmbCompany.SelectedValue);
     res            = db.AddProduct(prod);
     if (res.success)
     {
         MetroSetMessageBox.Show(this, res.message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MetroSetMessageBox.Show(this, res.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private void gv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == gv.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }

            Shared.Product prod = new Shared.Product();
            prod.ID                 = Convert.ToInt32(gv.Rows[e.RowIndex].Cells["ID"].Value);
            prod.unit               = Convert.ToString(gv.Rows[e.RowIndex].Cells["Unit"].Value);
            prod.productName        = Convert.ToString(gv.Rows[e.RowIndex].Cells["Medicine"].Value);
            prod.productDescription = Convert.ToString(gv.Rows[e.RowIndex].Cells["Description"].Value);
            res = db.UpdateProduct(prod);
            if (res.success)
            {
                MetroSetMessageBox.Show(this, res.message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                getCompany();
            }
            else
            {
                MetroSetMessageBox.Show(this, res.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }