Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();
            List <Data> data = new List <Data>();

            Date.Text       = DateTime.Now.ToShortDateString();
            Plan.Text       = "График работы " + App_Code.Base.months[DateTime.Now.Month - 1];
            DayPlan.Text    = "План работ на " + DateTime.Now.ToShortDateString();
            Zayavky.Text    = "Заявки ОДС на " + DateTime.Now.ToShortDateString();
            ZayavkyREO.Text = "Заявки ОДС по ПНР/РЭО на " + DateTime.Now.ToShortDateString();
            if (!IsPostBack)
            {
                if (User.Identity.Name == "Sargamonov")
                {
                    using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                    {
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
                                                        "join [Events] e on e.ZayavId=z.Id " +
                                                        "join WorkerLifts wl on wl.LiftId=z.LiftId " +
                                                        "join Users u on u.UserId=wl.UserId " +
                                                        "where u.UserName=@UserName and z.Category=N'ПНР/РЭО' and z.[Finish] is null ", conn);
                        cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
                        SqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            data.Add(new Data()
                            {
                                Title = " №" + " " + dr[3].ToString(),
                                Url   = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
                                Text1 = dr["Text"].ToString(),
                                Idi   = dr["LiftId"].ToString()
                            });
                        }
                        dr.Close();
                        ZvREO.Visible             = true;
                        ZayavkyListREO.DataSource = data;
                        ZayavkyListREO.DataBind();
                    }
                }

                if (User.Identity.Name != "Sargamonov")
                {
                    using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                    {
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
                                                        "join [Events] e on e.ZayavId=z.Id " +
                                                        "join WorkerLifts wl on wl.LiftId=z.LiftId " +
                                                        "join Users u on u.UserId=wl.UserId " +
                                                        "where u.UserName=@UserName and z.Category!=N'ПНР/РЭО' and z.[Finish] is null ", conn);
                        cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
                        SqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            data.Add(new Data()
                            {
                                Title = " №" + " " + dr[3].ToString(),
                                Url   = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
                                Text1 = dr["Text"].ToString(),
                                Idi   = dr["LiftId"].ToString()
                            });
                        }
                        dr.Close();
                        ZvODS.Visible          = true;
                        ZayavkyList.DataSource = data;
                        ZayavkyList.DataBind();
                    }
                }
            }
        }
Пример #2
0
        protected void AllZayavky(object sender, EventArgs e)
        {
            DayZayav.Visible = true;
            //  Zayavky.Text = "События ОДС на " + DateTime.Now.ToShortDateString();
            List <Data> data = new List <Data>();

            if (User.Identity.Name == "Sargamonov")
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
                                                    "join [Events] e on e.ZayavId=z.Id " +
                                                    "join WorkerLifts wl on wl.LiftId=z.LiftId " +
                                                    "join Users u on u.UserId=wl.UserId " +
                                                    "where u.UserName=@UserName and z.Category=N'ПНР/РЭО' and z.[Finish] is null ", conn);
                    cmd.Parameters.AddWithValue("UserName", _user);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[3].ToString(),
                            Url   = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ZayavkyList.DataSource = data;
                    ZayavkyList.DataBind();
                }
            }
            else
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
                                                    "join [Events] e on e.ZayavId=z.Id " +
                                                    "join WorkerLifts wl on wl.LiftId=z.LiftId " +
                                                    "join Users u on u.UserId=wl.UserId " +
                                                    "where u.UserName=@UserName and z.Category!=N'ПНР/РЭО' and z.[Finish] is null ", conn);
                    cmd.Parameters.AddWithValue("UserName", _user);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[3].ToString(),
                            Url   = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ZayavkyList.DataSource = data;
                    ZayavkyList.DataBind();
                }
            }
            List <Data> data1 = new List <Data>(); // неактивные

            if (User.Identity.Name == "Sargamonov")
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
                                                    "join [Events] e on e.ZayavId=z.Id " +
                                                    "join WorkerLifts wl on wl.LiftId=z.LiftId " +
                                                    "join Users u on u.UserId=wl.UserId " +
                                                    "where u.UserName=@UserName and z.Category=N'ПНР/РЭО' and z.[Finish]=1 and z.Status=N'false' ", conn);
                    cmd.Parameters.AddWithValue("UserName", _user);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data1.Add(new Data()
                        {
                            Title = " №" + " " + dr[3].ToString(),
                            Url   = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ZayavkyNA.DataSource = data1;
                    ZayavkyNA.DataBind();
                }
            }
            else
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
                                                    "join [Events] e on e.ZayavId=z.Id " +
                                                    "join WorkerLifts wl on wl.LiftId=z.LiftId " +
                                                    "join Users u on u.UserId=wl.UserId " +
                                                    "where u.UserName=@UserName and z.Category!=N'ПНР/РЭО' and z.[Finish]=1 and z.Status=N'false' ", conn);
                    cmd.Parameters.AddWithValue("UserName", _user);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data1.Add(new Data()
                        {
                            Title = " №" + " " + dr[3].ToString(),
                            Url   = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ZayavkyNA.DataSource = data1;
                    ZayavkyNA.DataBind();
                }
            }
        }