protected void OwnArea_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (args.Value.Length >= 1)
            {
                string ownarea = Convert.ToString(args.Value);
                //Check if areacode already exists

                int result = MappingsAreaCodes.CheckAreaCodeExists(ownarea);

                if (result == 0)
                {
                    //Does not exist continue
                    args.IsValid = true;
                }
                else
                {
                    //Does exist cancel
                    args.IsValid = false;
                    this.CustomValidatorOwnArea.Text = Resources.lang.MappingDetailsErrorMessageOwnAreaDuplicate;
                }
            }
            else
            {
                //Not valid
                args.IsValid = false;
                this.CustomValidatorOwnArea.Text = Resources.lang.MappingDetailsErrorMessageOwnArea;
            }
        }
        protected void ButtonSave_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                string ownArea   = null;
                string country   = Convert.ToString(this.DropDownListCountries.SelectedValue);
                string area_name = this.TexBoxAreaName.Text;
                bool   opco      = Convert.ToBoolean(this.CheckBoxOPCO.Checked);
                bool   fleetco   = Convert.ToBoolean(this.CheckBoxFleetCo.Checked);
                bool   carsales  = Convert.ToBoolean(this.CheckBoxCarSales.Checked);
                bool   licensee  = Convert.ToBoolean(this.CheckBoxLicensee.Checked);

                int result = -1;

                switch (SessionHandler.MappingAreaCodeDefaultMode)
                {
                case (int)App.BLL.Mappings.Mode.Insert:
                    ownArea = this.TextBoxOwnArea.Text;

                    result = MappingsAreaCodes.InsertAreaCode(ownArea, country, area_name, opco, fleetco, carsales, licensee);

                    break;

                case (int)App.BLL.Mappings.Mode.Edit:
                    ownArea = this.TextBoxOwnArea.Text;

                    result = MappingsAreaCodes.UpdateAreaCode(ownArea, country, area_name, opco, fleetco, carsales, licensee);

                    break;
                }

                if (result == 0)
                {
                    //Success
                    _errorMessage = Resources.lang.MessageAreaCodeSaved;
                }
                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();
            }
        }
Esempio n. 3
0
        protected void GridviewAreaCodes_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            int    rowIndex = -1;
            string ownarea  = null;

            switch (e.CommandName)
            {
            case "EditAreaCode":
                rowIndex = Convert.ToInt32(e.CommandArgument);
                ownarea  = Convert.ToString(this.GridviewAreaCodes.DataKeys[rowIndex].Values[0]);

                List <MappingsAreaCodes.AreaCodes> results = MappingsAreaCodes.SelectAreaCodesByOwnArea(ownarea);

                if ((results != null))
                {
                    //There should be only 1 row

                    foreach (MappingsAreaCodes.AreaCodes item in results)
                    {
                        this.MappingAreaCodeDetails.OwnArea   = item.OwnArea;
                        this.MappingAreaCodeDetails.Country   = item.Country;
                        this.MappingAreaCodeDetails.Area_Name = item.Area_Name;
                        this.MappingAreaCodeDetails.OPCO      = item.OPCO;
                        this.MappingAreaCodeDetails.FleetCo   = item.FleetCo;
                        this.MappingAreaCodeDetails.CarSales  = item.CarSales;
                        this.MappingAreaCodeDetails.Licensee  = item.Licensee;
                    }

                    SessionHandler.MappingAreaCodeDefaultMode     = (int)App.BLL.Mappings.Mode.Edit;
                    SessionHandler.MappingAreaCodeValidationGroup = "AreaCodeEdit";
                    this.MappingAreaCodeDetails.LoadDetails();
                    this.MappingAreaCodeDetails.ModalExtenderMapping.Show();
                    this.UpdatePanelMappingGridview.Update();
                }

                break;

            case "DeleteAreaCode":
                rowIndex = Convert.ToInt32(e.CommandArgument);
                ownarea  = Convert.ToString(this.GridviewAreaCodes.DataKeys[rowIndex].Values[0]);

                int result = MappingsAreaCodes.DeleteAreaCode(ownarea);

                if (result == 0)
                {
                    this.GridviewSortingAndPaging(null);
                    this.LabelMessage.Text = Resources.lang.MessageDeleteAreaCode;
                }
                else if (result == -2)
                {
                    this.LabelMessage.Text = Resources.lang.DeleteErrorMessageConstraint;
                }
                else
                {
                    this.LabelMessage.Text = Resources.lang.ErrorMessageAdministrator;
                }

                this.UpdatePanelMappingGridview.Update();

                break;
            }
        }
Esempio n. 4
0
 protected void LoadData(string sortExpression)
 {
     MappingsAreaCodes.SelectAreaCodes(Convert.ToInt32(SessionHandler.MappingAreaCodePageSize), Convert.ToInt32(SessionHandler.MappingAreaCodeCurrentPageNumber),
                                       sortExpression, this.PanelAreaCodes, this.PagerControlAreaCodes.PagerButtonFirst, this.PagerControlAreaCodes.PagerButtonNext, this.PagerControlAreaCodes.PagerButtonPrevious, this.PagerControlAreaCodes.PagerButtonLast, this.PagerControlAreaCodes.PagerLabelTotalPages, this.PagerControlAreaCodes.PagerDropDownListPage,
                                       this.GridviewAreaCodes, this.LabelTotalRecordsDisplay, this.EmptyDataTemplateAreaCodes, SessionHandler.MappingSelectedCountry);
 }