Exemple #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         CurrenContractObject = new ContractObject();
         frmUpdateContract frm = new frmUpdateContract(ctx, UpdataType.Add, CurrenContractObject);
         frm.ShowDialog();
         LoadDta();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }
Exemple #2
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         int id    = -1;
         int count = 0;
         for (int i = 0; i < dgvMain.Rows.Count; i++)
         {
             if (dgvMain.Rows[i].Cells[0].Value != null && (bool)dgvMain.Rows[i].Cells[0].Value == true)
             {
                 count++;
                 id = (int)dgvMain.Rows[i].Cells["Id"].Value;
                 if (count > 1)
                 {
                     MessageBox.Show("Please choise only one record!");
                     return;
                 }
             }
         }
         if (id == -1)
         {
             MessageBox.Show("Please must choise one record!");
             return;
         }
         CurrenContractObject = ctx.ContractObjects.Where(s => s.Id == id).First();
         if (CurrenContractObject == null)
         {
             MessageBox.Show("Eror: recode is null");
             return;
         }
         frmUpdateContract frm = new frmUpdateContract(ctx, UpdataType.Edit, CurrenContractObject);
         frm.ShowDialog();
         LoadDta();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }
Exemple #3
0
 private void dgvMain_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     try
     {
         if (dgvMain.Rows.Count > 0)
         {
             int id = (int)dgvMain.CurrentRow.Cells["Id"].Value;
             CurrenContractObject = ctx.ContractObjects.Where(s => s.Id == id).First();
             if (CurrenContractObject == null)
             {
                 MessageBox.Show("Eror: recode is null");
                 return;
             }
             frmUpdateContract frm = new frmUpdateContract(ctx, UpdataType.View, CurrenContractObject);
             frm.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }