Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();
            if (!string.IsNullOrEmpty(Request["lift"]))
            {
                _liftId = HttpUtility.HtmlDecode(Request["lift"]);
            }
            if (!string.IsNullOrEmpty(Request["ReturnUrl"]))
            {
                _url = HttpUtility.HtmlDecode(Request["ReturnUrl"]);
            }

            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select ui.Family, ui.IO from UserInfo ui " +
                                                "join Users u on u.UserId=ui.UserId where u.UserName=@userName", conn);
                cmd.Parameters.AddWithValue("userName", User.Identity.Name);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    fam = dr[0].ToString();
                }
                io = dr[1].ToString();
                dr.Close();
            }

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            _workers = db.GetWorkers();
            if (!IsPostBack)
            {
                List <string> ls = db.GetIdU();
                IdU.DataSource = ls;
                IdU.DataBind();
                if (ls.Count > 0)
                {
                    IdU.SelectedIndex = 0;
                }
                IdU_SelectedIndexChanged(sender, e);

                string[] ss = { "1", "2" };
                Category.DataSource = ss;
                Category.DataBind();
                Category.SelectedIndex = 0;
                db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> types = db.GetWZTypes();
                Type.DataSource = types;
                Type.DataBind();
                Type.SelectedIndex = 0;
                PrimLift_TextChanged(this, EventArgs.Empty);
                LiftId_SelectedIndexChanged(this, EventArgs.Empty);

                To.DataSource = _workers;
                To.DataBind();
                To.SelectedIndex = 0;
            }
            List <string> typeakt = new List <string>()
            {
                "Акт дефектовки", "Акт повреждения оборудования"
            };
            List <string> chel = new List <string>()
            {
                "", "Да", "Нет"
            };
            List <string> chas = new List <string>()
            {
                "", "да", "Нет"
            };

            if (!IsPostBack)
            {
                TypeAkt.DataSource = typeakt;
                TypeAkt.DataBind();
                TypeAkt.SelectedIndex = 0;

                Chel.DataSource = chel;
                Chel.DataBind();
                Chel.SelectedIndex = 0;

                Chas.DataSource = chas;
                Chas.DataBind();
                Chas.SelectedIndex = 0;
            }
        }