//public event GridViewCommandEventHandler GridviewCommand;

        protected void GridviewVehiclesLease_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            string serial = null;

            switch (e.CommandName)
            {
            case "EditSerial":
                serial = Convert.ToString(e.CommandArgument);

                List <MappingsVehiclesLease.VehiclesLeaseList> results = MappingsVehiclesLease.SelectVehiclesLeaseBySerial(serial);


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

                    foreach (MappingsVehiclesLease.VehiclesLeaseList item in results)
                    {
                        this.MappingVehiclesLeaseDetails.Serial        = item.Serial;
                        this.MappingVehiclesLeaseDetails.Country_Owner = item.Country_Owner;
                        this.MappingVehiclesLeaseDetails.Country_Rent  = item.Country_Rent;
                        this.MappingVehiclesLeaseDetails.StartDate     = item.StartDate;
                    }

                    SessionHandler.MappingVehiclesLeaseDefaultMode     = (int)App.BLL.Mappings.Mode.Edit;
                    SessionHandler.MappingVehiclesLeaseValidationGroup = "VehiclesLeaseEdit";
                    this.MappingVehiclesLeaseDetails.LoadDetails();
                    this.MappingVehiclesLeaseDetails.ModalExtenderMapping.Show();
                    this.UpdatePanelMappingGridview.Update();
                }

                break;

            case "DeleteSerial":

                serial = Convert.ToString(e.CommandArgument);

                int result = MappingsVehiclesLease.DeleteVehicleLease(serial);

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

                this.UpdatePanelMappingGridview.Update();

                break;
            }
        }
Ejemplo n.º 2
0
 protected void LoadData(string sortExpression)
 {
     MappingsVehiclesLease.SelectVehiclesLease(Convert.ToInt32(SessionHandler.MappingVehiclesLeasePageSize)
                                               , Convert.ToInt32(SessionHandler.MappingVehiclesLeaseCurrentPageNumber)
                                               , sortExpression
                                               , this.PanelVehiclesLease
                                               , null, null, null, null, null, null,
                                               //, this.PagerControlVehiclesLease.PagerButtonFirst
                                               //, this.PagerControlVehiclesLease.PagerButtonNext
                                               //, this.PagerControlVehiclesLease.PagerButtonPrevious
                                               //, this.PagerControlVehiclesLease.PagerButtonLast
                                               //, this.PagerControlVehiclesLease.PagerLabelTotalPages
                                               //, this.PagerControlVehiclesLease.PagerDropDownListPage,
                                               this.GridviewVehiclesLease, this.LabelTotalRecordsDisplay, this.EmptyDataTemplateVehiclesLease
                                               , SessionHandler.MappingSelectedCountryOwner, SessionHandler.MappingSelectedCountryRent
                                               , SessionHandler.MappingSelectedStartDate, SessionHandler.MappingSelectedModelDescription);
 }
Ejemplo n.º 3
0
        protected void RebindModelDescriptions()
        {
            string country_owner = SessionHandler.MappingSelectedCountryOwner;
            string country_rent  = SessionHandler.MappingSelectedCountryRent;
            string start_date    = SessionHandler.MappingSelectedStartDate;

            System.Web.UI.WebControls.CheckBoxList checkBoxListModelDesc = (System.Web.UI.WebControls.CheckBoxList) this.ModelDescription.FindControl("CheckBoxListPopUp");
            checkBoxListModelDesc.DataTextField  = "ModelDescription";
            checkBoxListModelDesc.DataValueField = "ModelDescription";
            checkBoxListModelDesc.Items.Clear();
            checkBoxListModelDesc.DataSource = MappingsVehiclesLease.SelectModelsDescription(country_owner, country_rent, start_date);
            checkBoxListModelDesc.DataBind();
            foreach (ListItem item in checkBoxListModelDesc.Items)
            {
                item.Selected = false;
            }
            //Load the check box list settings
            this.ModelDescription.LoadCheckBoxList();
        }
Ejemplo n.º 4
0
        protected void ButtonSave_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    string country_owner = this.DropDownListCountriesOwner.SelectedValue.ToString();

                    string countr_rent = this.DropDownListCountriesRent.SelectedValue.ToString();

                    string start_date = this.dptbStartDate.getDate().ToString();

                    string textbox_content = TextBoxSerials.Text;

                    textbox_content = textbox_content.Replace(";", String.Empty);

                    textbox_content = textbox_content.Replace(" -Invalid", String.Empty);

                    textbox_content = textbox_content.Replace(System.Environment.NewLine, ";");

                    string[] content;

                    int counter = textbox_content.Split(';').Length - 1;

                    int lenght = textbox_content.Length;

                    string message = String.Empty;

                    if (lenght > 0)
                    {
                        if (counter > 0)
                        {
                            content = textbox_content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                            for (int i = 0; i < content.Length; i++)
                            {
                                Validation(content[i], country_owner);
                            }

                            valids = valids.Distinct().ToList();

                            invalids = invalids.Distinct().ToList();
                        }
                        else
                        {
                            Validation(textbox_content, country_owner);
                        }

                        message = "Valids = " + valids.Count.ToString() + " - " + "Invalids = " + invalids.Count.ToString();
                    }
                    else
                    {
                        message = "There is no text in the Text Box";
                    }

                    this.LabelMessage.Text = message;

                    TextBoxSerials.Text = String.Empty;

                    TextBoxSerials.Text = TextBox_List();

                    if (invalids.Count == 0)
                    {
                        int result = -1;

                        switch (SessionHandler.MappingVehiclesLeaseDefaultMode)
                        {
                        case (int)App.BLL.Mappings.Mode.Insert:

                            for (int i = 0; i < valids.Count; i++)
                            {
                                MappingsVehiclesLease.InsertVehicleLease(valids[i], country_owner, countr_rent, start_date);
                            }

                            result = 0;

                            break;

                        case (int)App.BLL.Mappings.Mode.Edit:
                            for (int i = 0; i < valids.Count; i++)
                            {
                                MappingsVehiclesLease.UpdateVehicleLease(valids[i], country_owner, countr_rent, start_date);
                            }

                            result = 0;

                            break;

                        case (int)App.BLL.Mappings.Mode.Delete:

                            for (int i = 0; i < valids.Count; i++)
                            {
                                MappingsVehiclesLease.DeleteVehicleLease(valids[i]);
                            }

                            result = 0;

                            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
                    {
                        this.ModalPopupExtenderMappingDetails.Show();
                    }
                }
                catch (Exception ex)
                {
                    this.LabelMessage.Text = ex.Message;
                }
            }
            else
            {
                //Keep the modal popup form show
                this.ModalPopupExtenderMappingDetails.Show();
            }
        }
Ejemplo n.º 5
0
        private void Validation(string value, string parameter)
        {
            bool invalid = true;

            switch (SessionHandler.MappingVehiclesLeaseDefaultMode)
            {
            case (int)App.BLL.Mappings.Mode.Insert:

                default_values = MappingsVehiclesLease.SelectFleetSerialsByCountry(parameter);

                for (int i = 0; i < default_values.Count; i++)
                {
                    if (value == default_values[i].Serial)
                    {
                        invalid = false;

                        valids.Add(value);

                        break;
                    }
                }

                if (invalid == true)
                {
                    invalids.Add(value);
                }

                break;

            case (int)App.BLL.Mappings.Mode.Edit:

                default_values = MappingsVehiclesLease.SelectFleetSerialsByCountry(parameter);

                for (int i = 0; i < default_values.Count; i++)
                {
                    if (value == default_values[i].Serial)
                    {
                        invalid = false;

                        valids.Add(value);

                        break;
                    }
                }

                if (invalid == true)
                {
                    invalids.Add(value);
                }

                break;

            case (int)App.BLL.Mappings.Mode.Delete:

                invalid = false;

                valids.Add(value);

                break;
            }
        }