//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();
 }
Exemplo n.º 2
0
 //filling the combe box in the form
 public void FillInCombo()
 {
     cmbStateName.DisplayMember = "StateName";
     cmbUserName.DisplayMember  = "UserName";
     cmbStateName.ValueMember   = "PKStateId";
     cmbUserName.ValueMember    = "PKUserId";
     cmbUserName.DataSource     = UserBO.GetUser();
     cmbStateName.DataSource    = StateBO.GetStates();
 }
 private void StateForm_Load(object sender, EventArgs e)
 {
     dgvState.SelectionMode           = DataGridViewSelectionMode.FullRowSelect;
     dgvState.AutoGenerateColumns     = false;
     dgvState.ReadOnly                = true;
     dgvState.AllowUserToAddRows      = false;
     dgvState.AllowUserToDeleteRows   = false;
     dgvState.AllowUserToOrderColumns = false;
     dgvState.MultiSelect             = false;
     dgvState.DataSource              = StateBO.GetStates();
 }
 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");
     }
 }
Exemplo n.º 5
0
 public void BindGridView()
 {
     try
     {
         DataSet ds;
         StateBO objStateBO = new StateBO();
         ds = objStateBO.GetStates(-1);
         dgvState.DataSource = ds.Tables[0];
     }
     catch (System.Data.SqlClient.SqlException)
     {
         MessageBox.Show("1.Check the Connection Connection string ", "Unable to connect database ");
     }
     catch (Exception)
     {
         MessageBox.Show("connection string is invalid");
     }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgvState.RowCount != 0)
     {
         DialogResult dr;
         dr = MessageBox.Show("Are you sure?", "Delete", MessageBoxButtons.YesNo);
         if (dr == DialogResult.No)
         {
             return;
         }
         else
         {
             int     stateId    = (int)(dgvState.SelectedRows[0].Cells[0].Value);
             StateBO objStateBO = new StateBO();
             objStateBO.DeleteInState(stateId);
         }
     }
     dgvState.DataSource = StateBO.GetStates();
 }
Exemplo n.º 7
0
        //AddressBookEntities context = new AddressBookEntities();


        public object Getdetails(int a)
        {
            if (a == 1)
            {
                qry = null;
                qry = CountryBO.GetCountries();
            }
            else if (a == 2)
            {
                qry = null;
                qry = StateBO.GetStates();
            }
            else if (a == 3)
            {
                qry = null;
                qry = UserDB.GetUserDetails();
            }
            //if (a == 4)
            //{
            //    qry = null;
            //    qry = AddressBookDB.GetAddressbook();
            //}
            return(qry);
        }
 private void btnReset_Click(object sender, EventArgs e)
 {
     dgvState.DataSource = StateBO.GetStates();
 }