protected void LoadData(string sortExpression) { MappingsCarGroup.SelectCarGroups(Convert.ToInt32(SessionHandler.MappingCarGroupPageSize), Convert.ToInt32(SessionHandler.MappingCarGroupCurrentPageNumber), sortExpression, this.PanelCarGroups, this.PagerControlCarGroups.PagerButtonFirst, this.PagerControlCarGroups.PagerButtonNext, this.PagerControlCarGroups.PagerButtonPrevious, this.PagerControlCarGroups.PagerButtonLast, this.PagerControlCarGroups.PagerLabelTotalPages, this.PagerControlCarGroups.PagerDropDownListPage, this.GridviewCarGroups, this.LabelTotalRecordsDisplay, this.EmptyDataTemplateCarGroup, SessionHandler.MappingSelectedCountry, Convert.ToInt32(SessionHandler.MappingSelectedCarClassId)); }
protected void ButtonSave_Click(object sender, System.EventArgs e) { if (Page.IsValid) { int car_group_id = -1; string car_group = this.TextBoxCarGroup.Text; string car_group_gold = this.TextBoxCarGroupGold.Text; string car_group_fiveStar = this.TextBoxCarGroupFiveStar.Text; string car_group_PresidentCircle = this.TextBoxCarGroupPresidentCircle.Text; string car_group_Platinum = this.TextBoxCarGroupPlatinum.Text; int sort_car_group = Convert.ToInt32(TextBoxSortOrder.Text.Trim()); int car_class_id = Convert.ToInt32(this.DropDownListCarClass.SelectedValue); int result = -1; switch (SessionHandler.MappingCarGroupDefaultMode) { case (int)App.BLL.Mappings.Mode.Insert: result = MappingsCarGroup.InsertCarGroup(car_group, car_group_gold , car_group_fiveStar , car_group_PresidentCircle , car_group_Platinum , car_class_id , sort_car_group); break; case (int)App.BLL.Mappings.Mode.Edit: var validCarGroups = ParameterDataAccess.GetCarGroups().Where(d => d.Country == SessionHandler.MappingSelectedCountry).Select(d => d.CarGroup).ToList(); if (!validCarGroups.Contains(TextBoxCarGroup.Text.Trim())) { tbCarGroupError.Text = "Invalid Car Group"; ModalPopupExtenderMappingDetails.Show(); return; } if (!validCarGroups.Contains(TextBoxCarGroupGold.Text.Trim())) { tbCarGroupGoldError.Text = "Invalid Car Group"; ModalPopupExtenderMappingDetails.Show(); return; } if (!validCarGroups.Contains(TextBoxCarGroupFiveStar.Text.Trim())) { tbCarGroupFiveStarError.Text = "Invalid Car Group"; ModalPopupExtenderMappingDetails.Show(); return; } if (!validCarGroups.Contains(TextBoxCarGroupPresidentCircle.Text.Trim())) { tbCarGroupPresidentCircleError.Text = "Invalid Car Group"; ModalPopupExtenderMappingDetails.Show(); return; } if (!validCarGroups.Contains(TextBoxCarGroupPlatinum.Text.Trim())) { tbCarGroupPlatinumError.Text = "Invalid Car Group"; ModalPopupExtenderMappingDetails.Show(); return; } car_group_id = Convert.ToInt32(this.LabelCarGroupId.Text); result = MappingsCarGroup.UpdateCarGroup(car_group_id, car_group, car_group_gold , car_group_fiveStar , car_group_PresidentCircle , car_group_Platinum , car_class_id, sort_car_group); break; } _errorMessage = result == 0 ? Resources.lang.MessageCarGroupSaved : Resources.lang.ErrorMessageAdministrator; //Raise custom event from parent page if (SaveMappingDetails != null) { SaveMappingDetails(this, EventArgs.Empty); } } else { //Keep the modal popup form show ModalPopupExtenderMappingDetails.Show(); } }
protected void GridviewCarGroups_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { int rowIndex = -1; int car_group_id = -1; switch (e.CommandName) { case "EditCarGroup": rowIndex = Convert.ToInt32(e.CommandArgument); car_group_id = Convert.ToInt32(GridviewCarGroups.DataKeys[rowIndex].Values[0]); var results = MappingsCarGroup.SelectCarGroupById(car_group_id); if ((results != null)) { foreach (MappingsCarGroup.CarGroup item in results) { MappingCarGroupDetails.Car_Group_Id = item.Car_Group_Id; MappingCarGroupDetails.Car_Group = item.Car_Group; MappingCarGroupDetails.Car_Group_Gold = item.Car_Group_Gold; MappingCarGroupDetails.Car_Group_FiveStar = item.Car_Group_Fivestar; MappingCarGroupDetails.Car_Group_PresidentCircle = item.Car_Group_PresidentCircle; MappingCarGroupDetails.Car_Group_Platinum = item.Car_Group_Platinum; MappingCarGroupDetails.Car_Class_Id = item.Car_Class_Id; MappingCarGroupDetails.Sort_Car_Group = item.Sort_Car_Group; } SessionHandler.MappingCarGroupDefaultMode = (int)App.BLL.Mappings.Mode.Edit; SessionHandler.MappingCarGroupValidationGroup = "CarGroupEdit"; MappingCarGroupDetails.LoadDetails(); MappingCarGroupDetails.ModalExtenderMapping.Show(); UpdatePanelMappingGridview.Update(); } break; case "DeleteCarGroup": rowIndex = Convert.ToInt32(e.CommandArgument); car_group_id = Convert.ToInt32(this.GridviewCarGroups.DataKeys[rowIndex].Values[0]); int result = MappingsCarGroup.DeleteCarGroup(car_group_id); if (result == 0) { this.GridviewSortingAndPaging(null); this.LabelMessage.Text = Resources.lang.MessageDeleteCarGroup; } else if (result == -2) { this.LabelMessage.Text = Resources.lang.DeleteErrorMessageConstraint; } else { this.LabelMessage.Text = Resources.lang.ErrorMessageAdministrator; } this.UpdatePanelMappingGridview.Update(); break; } }