Exemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     Shared.Company com = new Shared.Company();
     com.companyName = txtName.Text;
     com.address     = txtAddress.Text;
     com.contact     = txtContact.Text;
     res             = db.AddCompany(com);
     if (res.success)
     {
         MetroSetMessageBox.Show(this, res.message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MetroSetMessageBox.Show(this, res.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        private void gv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == gv.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }

            Shared.Company company = new Shared.Company();
            company.ID          = Convert.ToInt32(gv.Rows[e.RowIndex].Cells["ID"].Value);
            company.companyName = Convert.ToString(gv.Rows[e.RowIndex].Cells["companyName"].Value);
            company.address     = Convert.ToString(gv.Rows[e.RowIndex].Cells["address"].Value);
            company.contact     = Convert.ToString(gv.Rows[e.RowIndex].Cells["contact"].Value);
            res = db.UpdateCompany(company);
            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);
            }
        }