Example #1
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Journal.aspx");
            }

            App_Code.Base db    = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };

            if (!db.CheckAccount(User.Identity.Name, roles))
            {
                Delete.Visible = false;
            }
            roles = new List <string>()
            {
                "Administrator", "Manager", "Worker", "Electronick", "Worker", "Cadry", "ODS", "ODS_tsg", "ManagerTSG"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return;
            }
            Response.Redirect("~/About.aspx");
        }
Example #2
0
        string CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Manager");
            }
            roles = new List <string>()
            {
                "ODS"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                if (_type < 7 || _type == 12) //_type == 11,12 добавлено для плановых работ и внеплановые ремонты ОДС
                {
                    return("ODS");
                }
            }
            Response.Redirect("~/About.aspx");
            return(string.Empty);
        }
Example #3
0
        string CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/WZReport.aspx");
            }

            App_Code.Base db    = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            List <string> roles = new List <string>()
            {
                "Worker", "Manager"
            };

            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Worker");
            }
            roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Manager");
            }
            Response.Redirect("~/About.aspx");
            return(string.Empty);
        }
Example #4
0
        string CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            List <string> roles = new List <string>()
            {
                "ODS_tsg"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("ODS_tsg");
            }
            roles = new List <string>()
            {
                "Administrator"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Administrator");
            }
            roles = new List <string>()
            {
                "ManagerTSG"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("ManagerTSG");
            }
            roles = new List <string>()
            {
                "Manager"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Manager");
            }
            roles = new List <string>()
            {
                "Cadry"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Cadry");
            }
            Response.Redirect("~/About.aspx");
            return("");
        }
Example #5
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Plans.aspx");
            }

            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                Planning.Visible = true;
                Worker.Visible   = true;
                return;
            }

            /*     List<string> _roles = new List<string>() { "ODS" };
             *   App_Code.Base _db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
             *   if (db.CheckAccount(User.Identity.Name, _roles))
             *   {
             *       Planning.Visible = false;
             *       Worker.Visible = false;
             *       return;
             *   } */
            Response.Redirect("~/About.aspx");
        }
Example #6
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Reports.aspx");
            }

            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                WZReport.Visible   = true;
                Lifts.Visible      = true;
                AdminUM.Visible    = true;
                DocViewUM.Visible  = true;
                DocumView.Visible  = true;
                ReportsTSG.Visible = true;
                PartsList.Visible  = true;

                return;
            }
            roles = new List <string>()
            {
                "Worker"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                WZReport.Visible = true;
                return;
            }
            roles = new List <string>()
            {
                "ODS", "Electronick"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return;
            }
            Response.Redirect("~/About.aspx");
        }
Example #7
0
        void BindWorker(SqlConnection conn)
        {
            List <string> roles = new List <string>()
            {
                "Administrator", "ODS", "Manager"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                SqlCommand cmd = new SqlCommand("select ui.Family, ui.[IO], ui.UserId from UserInfo ui " +
                                                "join Zayavky z on ui.UserId=z.Worker " +
                                                "group by ui.Family, ui.[IO], ui.UserId", conn);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (!(reader[0] is DBNull))
                    {
                        workerData.Add(new PersonData()
                        {
                            Title = reader[0].ToString() + " " + reader[1].ToString(),
                            Id    = reader[2].ToString()
                        });
                    }
                }
                reader.Close();
            }
            else
            {
                SqlCommand cmd = new SqlCommand("select ui.Family, ui.IO, ui.UserId from UserInfo ui " +
                                                "join Users u on u.UserId=ui.UserId where u.UserName=@UserName " +
                                                "group by Family, IO, ui.UserId", conn);
                cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (!(reader[0] is DBNull))
                    {
                        workerData.Add(new PersonData()
                        {
                            Title = reader[0].ToString() + " " + reader[1].ToString(),
                            Id    = reader[2].ToString()
                        });
                    }
                }
                reader.Close();
            }
            if (!IsPostBack)
            {
                Worker.DataSource = workerData;
                Worker.DataBind();
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Date.Text = DateTime.Now.Date.ToLongDateString();

            List <string> roles = new List <string>()
            {
                "ODS", "ODS_tsg", "ManagerTSG"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(Page.User.Identity.Name, roles))
            {
                Reports.Visible = false;
                Plans.Visible   = false;
                Lik.Visible     = true;
            }
        }
Example #9
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=" + HttpUtility.HtmlEncode(Request.Url.ToString()));
            }
            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Worker", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return;
            }
            Response.Redirect("~/About.aspx");
        }
Example #10
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            List <string> roles = new List <string>()
            {
                "Worker", "ODS", "Cadry", "ODS_tsg"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return;
            }
            Response.Redirect("~/About.aspx");
        }
Example #11
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Enviroment.aspx");
            }

            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Electronick", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return;
            }
            Response.Redirect("~/About.aspx");
        }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            if (!string.IsNullOrEmpty(Request["id"]))
            {
                _id = Int32.Parse(Request["id"]);
                phAddRecord.Visible  = false;
                phEditRecord.Visible = true;
            }
            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            _data = db.GetUsers();
            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };

            if (!db.CheckAccount(User.Identity.Name, roles))
            {
                Select.SelectCommand = "select j.*, uf.Family+' '+uf.IO as FromFIO, ut.Family+' '+ut.IO as ToFIO, '~/Journal.aspx?id='+CAST(j.Id as nvarchar) as Url " +
                                       "from [Journal] j left join UserInfo uf on uf.UserId=j.[From] left join UserInfo ut on ut.UserId=j.[To] " +
                                       "join Users u1 on u1.UserId=j.[From] or j.[From] is null " +
                                       "join Users u2 on u2.UserId=j.[To] or j.[To] is null " +
                                       "where (j.[From] is not null and u1.UserName=N'" + User.Identity.Name + "') " +
                                       "or (j.[To] is not null and u2.UserName=N'" + User.Identity.Name + "') " +
                                       "order by j.[Begin] desc";
            }
            if (!IsPostBack)
            {
                AddTo.DataSource = _data;
                AddTo.DataBind();
                AddTo.SelectedIndex = 0;
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();

                    /*
                     * SqlCommand cmd = new SqlCommand("select * from [Journal] order by [Begin] desc", conn);
                     * SqlDataReader dr = cmd.ExecuteReader();
                     * List<Data> data = new List<Data>();
                     * while (dr.Read())
                     * {
                     *  data.Add(new Data()
                     *  {
                     *      Id = dr["Id"].ToString(),
                     *      Url = "~/Journal.aspx?id=" + dr["Id"].ToString(),
                     *      Role = dr["Role"].ToString(),
                     *      Page = dr["Page"].ToString(),
                     *      Description = dr["Description"].ToString(),
                     *      Begin = ((DateTime)dr["Begin"]).Date.ToShortDateString(),
                     *      End = dr["End"] is DBNull ? "" : ((DateTime)dr["End"]).Date.ToShortDateString(),
                     *      Prim = dr["Prim"] is DBNull ? "" : dr["Prim"].ToString()
                     *  });
                     * }
                     * dr.Close();
                     * Table.DataSource = data;
                     * Table.DataBind();
                     */
                    if (_id > 0)
                    {
                        SqlCommand cmd = new SqlCommand("select j.*, uif.Family as FromF, uif.IO as FromIO, uit.Family as ToF, uit.IO as ToIO from [Journal] j " +
                                                        "left join UserInfo uit on uit.UserId=j.[To] " +
                                                        "left join UserInfo uif on uif.UserId=j.[From] where j.Id=@id", conn);
                        cmd.Parameters.AddWithValue("id", _id);
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        EditRole.Text        = dt.Rows[0]["Role"].ToString();
                        EditPage.Text        = dt.Rows[0]["Page"].ToString();
                        EditDescription.Text = dt.Rows[0]["Description"].ToString();
                        if (!(dt.Rows[0]["Prim"] is DBNull))
                        {
                            EditPrim.Text = dt.Rows[0]["Prim"].ToString();
                        }
                        if (!(dt.Rows[0]["FromF"] is DBNull))
                        {
                            EditFrom.Text = dt.Rows[0]["FromF"].ToString() + " " + dt.Rows[0]["FromIO"].ToString();
                        }
                        if (!(dt.Rows[0]["ToF"] is DBNull))
                        {
                            EditTo.Text = dt.Rows[0]["ToF"].ToString() + " " + dt.Rows[0]["ToIO"].ToString();
                        }
                    }
                }
            }
        }
Example #13
0
        string CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Zayavka.aspx");
            }

            List <string> roles = new List <string>()
            {
                "ODS"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                XmlDocument doc = new XmlDocument();
                if (!File.Exists(ipConfig))
                {
                    SaveFirst(doc);
                }
                XmlTextReader reader = new XmlTextReader(ipConfig);
                doc.Load(reader);
                XmlNode ipx = doc["zayavka"][User.Identity.Name];
                reader.Close();
                if (ipx != null && ipx.HasChildNodes)
                {
                    for (int i = 0; i < ipx.ChildNodes.Count; i++)
                    {
                        string ip = ipx.ChildNodes[i].InnerText;
                        if (ip == Request.UserHostAddress || ip == "*")
                        {
                            return("ODS");
                        }
                    }
                    Response.Redirect("~/About.aspx");
                }
                else
                {
                    SaveNext(doc);
                }
                return("ODS");
            }
            roles = new List <string>()
            {
                "Administrator", "Cadry"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Administrator");
            }
            roles = new List <string>()
            {
                "Manager"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Manager");
            }
            roles = new List <string>()
            {
                "Worker"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Worker");
            }
            roles = new List <string>()
            {
                "Cadry "
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Cadry");
            }

            Response.Redirect("~/About.aspx");
            return(null);
        }