protected void Country_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { if (args.Value.Length >= 1) { string country = Convert.ToString(args.Value); //Check if country already exists int result = MappingsCountry.CheckIfCountryExists(country); if (result == 0) { //Does not exist continue args.IsValid = true; } else { //Does exist cancel args.IsValid = false; this.CustomValidatorCountry.Text = Resources.lang.MappingDetailsErrorMessageCountryDuplicate; } } else { //Not valid args.IsValid = false; this.CustomValidatorCountry.Text = Resources.lang.MappingDetailsErrorMessageCountry; } }
protected void LoadData(string sortExpression) { MappingsCountry.SelectCountry(Convert.ToInt32(SessionHandler.MappingCountryPageSize), Convert.ToInt32(SessionHandler.MappingCountryCurrentPageNumber), sortExpression, this.PanelCountries, this.PagerControlCountries.PagerButtonFirst, this.PagerControlCountries.PagerButtonNext, this.PagerControlCountries.PagerButtonPrevious, this.PagerControlCountries.PagerButtonLast, this.PagerControlCountries.PagerLabelTotalPages, this.PagerControlCountries.PagerDropDownListPage, this.GridviewCountries, this.LabelTotalRecordsDisplay, this.EmptyDataTemplateCountries); }
protected void ButtonSave_Click(object sender, System.EventArgs e) { if (Page.IsValid) { string country = null; string countryDW = this.TextBoxCountryDW.Text; string countryDescription = this.TextBoxCountryDescription.Text; bool active = Convert.ToBoolean(this.CheckBoxIsActive.Checked); int result = -1; switch (SessionHandler.MappingCountryDefaultMode) { case (int)App.BLL.Mappings.Mode.Insert: country = this.TextBoxCountry.Text; result = MappingsCountry.InsertCountry(country, countryDW, countryDescription, active); break; case (int)App.BLL.Mappings.Mode.Edit: country = this.TextBoxCountry.Text; result = MappingsCountry.UpdateCountry(country, countryDW, countryDescription, active); break; } if (result == 0) { //Success _errorMessage = Resources.lang.MessageCountrySaved; } else { //Failed _errorMessage = Resources.lang.ErrorMessageAdministrator; } //Raise custom event from parent page if (SaveMappingDetails != null) { SaveMappingDetails(this, EventArgs.Empty); } } else { //Keep the modal popup form show this.ModalPopupExtenderMappingDetails.Show(); } }
protected void GridviewCountries_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { string country = null; switch (e.CommandName) { case "SelectAreaCodes": _country = Convert.ToString(e.CommandArgument); _selection = (int)App.BLL.Mappings.Type.AreaCode; //Raise custom event from parent page if (GridviewCommand != null) { GridviewCommand(this, e); } break; case "SelectCMSPools": _country = Convert.ToString(e.CommandArgument); _selection = (int)App.BLL.Mappings.Type.CMSPools; //Raise custom event from parent page if (GridviewCommand != null) { GridviewCommand(this, e); } break; case "SelectOPSRegions": _country = Convert.ToString(e.CommandArgument); _selection = (int)App.BLL.Mappings.Type.OPSRegions; //Raise custom event from parent page if (GridviewCommand != null) { GridviewCommand(this, e); } break; case "SelectCarSegments": _country = Convert.ToString(e.CommandArgument); _selection = (int)App.BLL.Mappings.Type.CarSegment; //Raise custom event from parent page if (GridviewCommand != null) { GridviewCommand(this, e); } break; case "SelectModelCodes": _country = Convert.ToString(e.CommandArgument); _selection = (int)App.BLL.Mappings.Type.ModelCodes; //Raise custom event from parent page if (GridviewCommand != null) { GridviewCommand(this, e); } break; case "EditCountry": country = Convert.ToString(e.CommandArgument); List <MappingsCountry.CountryList> results = MappingsCountry.SelectCountryByCountry(country); if ((results != null)) { foreach (MappingsCountry.CountryList item in results) { this.MappingCountryDetails.Country = item.Country; this.MappingCountryDetails.Country_Description = item.Country_Description; this.MappingCountryDetails.Country_DW = item.Country_DW; this.MappingCountryDetails.Active = item.Active; } SessionHandler.MappingCountryDefaultMode = (int)App.BLL.Mappings.Mode.Edit; SessionHandler.MappingCountryValidationGroup = "CountryEdit"; this.MappingCountryDetails.LoadDetails(); this.MappingCountryDetails.ModalExtenderMapping.Show(); this.UpdatePanelMappingGridview.Update(); } break; case "DeleteCountry": country = Convert.ToString(e.CommandArgument); int result = MappingsCountry.DeleteCountry(country); if (result == 0) { this.GridviewSortingAndPaging(null); this.LabelMessage.Text = Resources.lang.MessageDeleteCountry; } else if (result == -2) { this.LabelMessage.Text = Resources.lang.DeleteErrorMessageConstraint; } else { this.LabelMessage.Text = Resources.lang.ErrorMessageAdministrator; } this.UpdatePanelMappingGridview.Update(); break; } }