//this is for updating
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvState.RowCount != 0)
         {
             StateDialog dlgState = new StateDialog();
             dlgState.CountryName = (dgvState.SelectedRows[0].Cells[2].Value).ToString();
             dlgState.stateName   = (dgvState.SelectedRows[0].Cells[3].Value).ToString();
             dlgState.IsActive    = (bool)(dgvState.SelectedRows[0].Cells[4].Value);
             int       stateId      = (int)(dgvState.SelectedRows[0].Cells[0].Value);
             StateBO   objStateBO   = new StateBO();
             StateData objStateData = new StateData();
             if (dlgState.ShowDialog() == DialogResult.OK)
             {
                 objStateData.StateId     = stateId;
                 objStateData.FKCountryId = dlgState.countryId;
                 objStateData.StateName   = dlgState.stateName;
                 objStateData.IsActive    = dlgState.IsActive;
                 objStateBO.UpdateInState(objStateData);
             }
         }
     }
     catch
     {
         MessageBox.Show("error at edit form");
     }
     dgvState.DataSource = StateBO.GetStates();
 }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            state = new State();
            StateDialog dialog = new StateDialog();

            state.PKStateId  = Convert.ToInt32(dgvState.SelectedRows[0].Cells[0].Value);
            dialog.CountryId = Convert.ToInt32(dgvState.SelectedRows[0].Cells[1].Value);
            //dialog.CountryName = dgvState.SelectedRows[0].Cells[2].Value.ToString();//for seeing which works .
            dialog.StateName = dgvState.SelectedRows[0].Cells[3].Value.ToString();
            dialog.IsActive  = (bool)(dgvState.SelectedRows[0].Cells[4].Value);
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    state.FKCountryId = dialog.CountryId;
                    state.StateName   = dialog.StateName;
                    state.IsActive    = dialog.IsActive;
                    Interaction.Update(state, 2);
                }
                catch (Exception)
                {
                    MessageBox.Show("you are in the table state in update");
                }
            }
            dgvState.DataSource = Interaction.Getdetails(2);
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         StateDialog dlgState = new StateDialog();
         if (dlgState.ShowDialog() == DialogResult.OK)
         {
             StateBO objstateBO = new StateBO();
             objstateBO.InsertInState(dlgState.countryId, dlgState.stateName, dlgState.IsActive);
             dgvState.DataSource = StateBO.GetStates();
         }
     }
     catch
     {
         MessageBox.Show("Error in state form");
     }
 }
Пример #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            state = new State();
            StateDialog dialog = new StateDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    state.FKCountryId = dialog.CountryId;
                    state.StateName   = dialog.StateName;
                    state.IsActive    = dialog.IsActive;
                    Interaction.AddData(state, 2);
                }
                catch (Exception)
                {
                    MessageBox.Show("you are in the stateform Add");
                }
            }
            dgvState.DataSource = Interaction.Getdetails(2);
        }