Ejemplo n.º 1
0
 protected void LoadData(string sortExpression)
 {
     MappingsModelCodes.SelectModelCodes(Convert.ToInt32(SessionHandler.MappingModelCodePageSize), Convert.ToInt32(SessionHandler.MappingModelCodeCurrentPageNumber),
                                         sortExpression, this.PanelModelCodes, this.PagerControlModelCodes.PagerButtonFirst, this.PagerControlModelCodes.PagerButtonNext,
                                         this.PagerControlModelCodes.PagerButtonPrevious, this.PagerControlModelCodes.PagerButtonLast, this.PagerControlModelCodes.PagerLabelTotalPages,
                                         this.PagerControlModelCodes.PagerDropDownListPage, this.GridviewModelCodes, this.LabelTotalRecordsDisplay, this.EmptyDataTemplateModelCodes,
                                         SessionHandler.MappingSelectedCountry);
 }
Ejemplo n.º 2
0
        protected void GridviewModelCodes_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            int rowIndex = -1;
            int model_id = -1;

            switch (e.CommandName)
            {
            case "EditModelCode":
                rowIndex = Convert.ToInt32(e.CommandArgument);
                model_id = Convert.ToInt32(this.GridviewModelCodes.DataKeys[rowIndex].Values[0]);

                List <MappingsModelCodes.ModelCodes> results = MappingsModelCodes.SelectModelCodeById(model_id);


                if ((results != null))
                {
                    foreach (MappingsModelCodes.ModelCodes item in results)
                    {
                        this.MappingModelCodeDetails.Model_Id = item.Model_Id;
                        this.MappingModelCodeDetails.Model    = item.Model;
                        this.MappingModelCodeDetails.Country  = item.Country;
                        this.MappingModelCodeDetails.Active   = item.Active;
                    }
                    SessionHandler.MappingModelCodeDefaultMode     = (int)App.BLL.Mappings.Mode.Edit;
                    SessionHandler.MappingModelCodeValidationGroup = "ModelCodeEdit";
                    this.MappingModelCodeDetails.LoadDetails();
                    this.MappingModelCodeDetails.ModalExtenderMapping.Show();
                    this.UpdatePanelMappingGridview.Update();
                }

                break;

            case "DeleteModelCode":
                rowIndex = Convert.ToInt32(e.CommandArgument);
                model_id = Convert.ToInt32(this.GridviewModelCodes.DataKeys[rowIndex].Values[0]);

                int result = MappingsModelCodes.DeleteModelCode(model_id);
                if (result == 0)
                {
                    this.GridviewSortingAndPaging(null);
                    this.LabelMessage.Text = Resources.lang.MessageDeleteModelCode;
                }
                else if (result == -2)
                {
                    this.LabelMessage.Text = Resources.lang.DeleteErrorMessageConstraint;
                }
                else
                {
                    this.LabelMessage.Text = Resources.lang.ErrorMessageAdministrator;
                }

                this.UpdatePanelMappingGridview.Update();
                break;
            }
        }
        protected void ButtonSave_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                int    model_id = -1;
                string model    = this.TextBoxModel.Text;
                string country  = Convert.ToString(this.DropDownListCountries.SelectedValue);
                bool   active   = Convert.ToBoolean(this.CheckBoxIsActive.Checked);

                int result = -1;

                switch (SessionHandler.MappingModelCodeDefaultMode)
                {
                case (int)App.BLL.Mappings.Mode.Insert:
                    result = MappingsModelCodes.InsertModelCode(country, model, active);

                    break;

                case (int)App.BLL.Mappings.Mode.Edit:
                    model_id = Convert.ToInt32(this.LabelModelId.Text);
                    result   = MappingsModelCodes.UpdateModelCode(model_id, country, model, active);
                    break;
                }

                if (result == 0)
                {
                    //Success
                    _errorMessage = Resources.lang.MessageModelCodeSaved;
                }
                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();
            }
        }