Esempio n. 1
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dgvState.RowCount != 0)
     {
         int         stateId    = (int)(dgvState.SelectedRows[0].Cells[0].Value);
         StateDialog dlgState   = new StateDialog();
         StateBO     objStateBO = new StateBO();
         //update the records
         State objState = objStateBO.GetState(stateId);
         dlgState.CountryId = objState.CountryId;
         dlgState.StateName = objState.StateName;
         dlgState.IsActive  = objState.IsActive;
         if (dlgState.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 if (!(objState.StateName == dlgState.StateName))
                 {
                     objStateBo.IsStateExist(dlgState.CountryName, dlgState.StateName);
                 }
                 objStateBO.UpdateState(objState.StateId, objState.CountryId, dlgState.StateName, dlgState.IsActive);
             }
             catch (Exception EX)
             {
                 MessageBox.Show(EX.Message);
             }
             BindGridView();
         }
     }
 }
Esempio n. 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            StateDialog dlgState = new StateDialog();

            if (dlgState.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    StateBO objStateBO = new StateBO();
                    State   objState   = new State();
                    objStateBo.IsStateExist(dlgState.CountryName, dlgState.StateName);
                    objStateBO.InsertState(Convert.ToInt32(dlgState.CountryId), dlgState.StateName, dlgState.IsActive);
                    BindGridView();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }