Exemplo n.º 1
0
        public void lbDelete_Click(Object sender, EventArgs e)
        {
            DeleteAccess();
            var userInSession = (Users)Session["userinsession"];

            BackLink = DriversHelper.BackDriverLinkBuilder(stbDID.Text, stbPhone.Text, sddlStatus.SelectedValue, stbFirstName.Text);
            var lb      = (LinkButton)sender;
            var drivers = new Drivers();

            drivers.Delete(Convert.ToInt32(lb.CommandArgument), userInSession.ID, OtherMethods.GetIPAddress(), "DriversView");
            Page.Response.Redirect("~/ManagerUI/Menu/Souls/DriversView.aspx?" + BackLink);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OtherMethods.ActiveRightMenuStyleChanche("hlDrivers", this.Page);
            OtherMethods.ActiveRightMenuStyleChanche("hlSouls", this.Page);
            Page.Title = Page.Request.Params["id"] != null ? PagesTitles.ManagerDriversEdit + BackendHelper.TagToValue("page_title_part") : PagesTitles.ManagerDriversCreate + BackendHelper.TagToValue("page_title_part");

            #region Блок доступа к странице
            var userInSession = (Users)Session["userinsession"];
            var rolesList     = Application["RolesList"] as List <Roles>;
            var currentRole   = (Roles)rolesList.SingleOrDefault(u => u.Name.ToLower() == userInSession.Role.ToLower());
            if (currentRole.PageDriversEdit != 1)
            {
                Response.Redirect("~/Error.aspx?id=1");
            }
            #endregion

            BackLink = DriversHelper.BackDriverLinkBuilder(Page.Request.Params["did"], Page.Request.Params["phone"], Page.Request.Params["statusid"], Page.Request.Params["firstname"]);

            if (!IsPostBack)
            {
                ddlStatus.DataSource     = Drivers.DriverStatuses;
                ddlStatus.DataTextField  = "Value";
                ddlStatus.DataValueField = "Key";
                ddlStatus.DataBind();

                var cars = new Cars();
                var ds   = cars.GetAllItems("Model", "ASC", null);
                ds.Tables[0].Columns.Add("ModelAndNumber", typeof(string), "Model + ' ' + Number");
                ddlCar.DataSource     = ds;
                ddlCar.DataTextField  = "ModelAndNumber";
                ddlCar.DataValueField = "ID";
                ddlCar.DataBind();
                ddlCar.Items.Add(new ListItem("Не назначена", "0"));
            }

            if (Page.Request.Params["id"] != null)
            {
                var driver = new Drivers {
                    ID = Convert.ToInt32(Page.Request.Params["id"])
                };
                driver.GetById();
                if (String.IsNullOrEmpty(driver.FirstName))
                {
                    Page.Response.Redirect("~/ManagerUI/Menu/Souls/DriversView.aspx?" + BackLink);
                }
                if (!IsPostBack)
                {
                    ddlCar.SelectedValue    = driver.CarID.ToString();
                    ddlStatus.SelectedValue = driver.StatusID.ToString();

                    tbFirstName.Text          = driver.FirstName;
                    tbLastName.Text           = driver.LastName;
                    tbThirdName.Text          = driver.ThirdName;
                    tbPhoneOne.Text           = driver.PhoneOne;
                    tbPhoneTwo.Text           = driver.PhoneTwo;
                    tbPhoneHome.Text          = driver.HomePhone;
                    tbHomeAddress.Text        = driver.HomeAddress;
                    tbBirthDay.Text           = Convert.ToDateTime(driver.BirthDay).ToString("dd-MM-yyyy");
                    tbContactPersonFIO.Text   = driver.ContactPersonFIO;
                    tbContactPersonPhone.Text = driver.ContactPersonPhone;

                    tbPassportSeria.Text       = driver.PassportSeria;
                    tbPassportNumber.Text      = driver.PassportNumber;
                    tbPersonalNumber.Text      = driver.PersonalNumber;
                    tbROVD.Text                = driver.ROVD;
                    tbDateOfIssue.Text         = Convert.ToDateTime(driver.DateOfIssue).ToString("dd-MM-yyyy");
                    tbValidity.Text            = Convert.ToDateTime(driver.Validity).ToString("dd-MM-yyyy");
                    tbRegistrationAddress.Text = driver.RegistrationAddress;


                    tbDriverPassport.Text            = hfDriverPassport.Value = driver.DriverPassport;
                    tbDriverPassportDateOfIssue.Text = Convert.ToDateTime(driver.DriverPassportDateOfIssue).ToString("dd-MM-yyyy");
                    tbDriverPassportValidity.Text    = Convert.ToDateTime(driver.DriverPassportValidity).ToString("dd-MM-yyyy");
                    tbMedPolisDateOfIssue.Text       = Convert.ToDateTime(driver.MedPolisDateOfIssue).ToString("dd-MM-yyyy");
                    tbMedPolisValidity.Text          = Convert.ToDateTime(driver.MedPolisValidity).ToString("dd-MM-yyyy");
                }
            }
        }