//for update only
 public void UpdateInCountry(Countrydata objCountryData)
 {
     try
     {
         objCountryData.Validate();
         CountryDB.UpdateCountry(objCountryData);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        //for inserting
        public static void InsertNewCountry(Countrydata objcountryData)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Country country = new Country();

            country.CountryName  = objcountryData.CountryName;
            country.ZipCodeStart = objcountryData.ZipCodeStart;
            country.ZipCodeEnd   = objcountryData.ZipCodeEnd;
            country.IsActive     = objcountryData.IsActive;
            dc.Countries.InsertOnSubmit(country);
            dc.SubmitChanges();
        }
 //for new insert only
 public void InsertInCountry(string countryName, long zipCodeStart, long zipCodeEnd, bool isActive)
 {
     try
     {
         Countrydata objCountry = new Countrydata(countryName, zipCodeStart, zipCodeEnd, isActive);
         objCountry.Validate();
         CountryDB.InsertNewCountry(objCountry);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        //for updating
        public static void UpdateCountry(Countrydata objCountryData)
        {
            int countryId = objCountryData.PKCountry;
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Country country = dc.Countries.First(e1 => e1.PKCountryId == countryId);

            country.CountryName  = objCountryData.CountryName;
            country.ZipCodeStart = objCountryData.ZipCodeStart;
            country.ZipCodeEnd   = objCountryData.ZipCodeEnd;
            country.IsActive     = objCountryData.IsActive;
            //dc.Countries.InsertOnSubmit(country);
            dc.SubmitChanges();
        }
Exemplo n.º 5
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dgvCountry.RowCount != 0)
     {
         int           countryId      = (int)(dgvCountry.SelectedRows[0].Cells[0].Value);
         CountryDialog dlgCountry     = new CountryDialog();
         CountryBO     objCountryBO   = new CountryBO();
         Countrydata   objCountryData = new Countrydata();
         dlgCountry.CountryName  = (dgvCountry.SelectedRows[0].Cells[1].Value).ToString();
         dlgCountry.ZipCodeStart = (long)(dgvCountry.SelectedRows[0].Cells[2].Value);
         dlgCountry.ZipCodeEnd   = (long)(dgvCountry.SelectedRows[0].Cells[3].Value);
         dlgCountry.IsActive     = (bool)(dgvCountry.SelectedRows[0].Cells[4].Value);
         if (dlgCountry.ShowDialog() == DialogResult.OK)
         {
             objCountryData.PKCountry    = countryId;
             objCountryData.CountryName  = dlgCountry.CountryName;
             objCountryData.ZipCodeStart = dlgCountry.ZipCodeStart;
             objCountryData.ZipCodeEnd   = dlgCountry.ZipCodeEnd;
             objCountryData.IsActive     = dlgCountry.IsActive;
             objCountryBO.UpdateInCountry(objCountryData);
         }
         dgvCountry.DataSource = CountryBO.GetCountries();
     }
 }