public frmLocation(int locationID)
 {
     InitializeComponent();
     LoadCountry();
     Location.LocationWebService objWebService = new Location.LocationWebService();
     LocationInfo objInfo = new LocationInfo();
     objInfo.LocationID = locationID;
     objInfo = objWebService.LocationNameGetByID(objInfo.LocationID, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens()));
     cmbCountryName.SelectedValue = objInfo.CountryID;
     cmbStateName.SelectedValue = objInfo.StateID;
     txtLocationName.Text = objInfo.LocationName;
     lblCountryID.Text = objInfo.LocationID.ToString();
     lblStateID.Text = objInfo.StateID.ToString();
     lblLocationID.Text = objInfo.LocationID.ToString();
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateForm())
         {
             Location.LocationWebService objWebService = new Location.LocationWebService();
             LocationInfo objInfo = new LocationInfo();
             objInfo.CountryID = Convert.ToInt32(cmbCountryName.SelectedValue);
             objInfo.StateID = Convert.ToInt32(cmbStateName.SelectedValue);
             objInfo.LocationName = txtLocationName.Text;
             int countryId = objInfo.CountryID;
             int stateId = objInfo.StateID;
             int locationId = Convert.ToInt32(lblLocationID.Text);
             if (countryId != 0 && stateId != 0 && locationId == 0)
             {
                 objInfo.AddedBy = GetLoginUser.UserName;
                 objWebService.LocationNameAdd(objInfo, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens()));
                 MessageBox.Show("Data saved successfully");
             }
             else if (countryId != 0 && stateId != 0 && locationId != 0)
             {
                 objInfo.CountryID = countryId;
                 objInfo.StateID = stateId;
                 objInfo.LocationID = locationId;
                 objInfo.EditedBy = GetLoginUser.UserName;
                 objWebService.LocationNameUpdate(objInfo, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens()));
                 MessageBox.Show("Data updated successfully");
             }
             ClearField();
             this.DialogResult = DialogResult.OK;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }