Example #1
0
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     if (tbLogin.Text != "" && tbPassword.Text != "")
     {
         DbLink.Account findAccount = new DbLink.Account()
         {
             Login = tbLogin.Text, Password = tbPassword.Text
         };
         if (GlobalVariables.Link.Authorization(findAccount))
         {
             Session["login"]      = findAccount.Login;
             Session["name"]       = findAccount.Name;
             Session["middlename"] = findAccount.MiddleName;
             Session["lastname"]   = findAccount.LastName;
             Session["group"]      = findAccount.group.Id;
             Session["groupTitle"] = findAccount.group.Title;
             Response.Redirect(Request.Url.ToString());
         }
         else
         {
             loginError.Visible = true;
         }
     }
     tbLogin.Text = tbPassword.Text = "";
 }
Example #2
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (tbLogin.Text != "" && tbPassword.Text != "")
     {
         // проверка к базе
         DbLink.Account findAccount = new DbLink.Account()
         {
             Login = tbLogin.Text, Password = tbPassword.Text
         };
         DbLink.Group findGroup = new DbLink.Group();
         if (GlobalVariables.Link.Authorization(findAccount, findGroup))
         {
             Session["login"]      = findAccount.Login;
             Session["name"]       = findAccount.Name;
             Session["middlename"] = findAccount.MiddleName;
             Session["lastname"]   = findAccount.LastName;
             Session["group"]      = findGroup.Id;
             Session["groupTitle"] = findGroup.Title;
             Response.Redirect(Request.Url.ToString());
         }
         else
         {
             errlogin.Style.Clear();
         }
     }
     else
     {
         errlogin.Style.Clear();
     }
     tbLogin.Text = tbPassword.Text = "";
 }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["ok"] != null)
     {
         OkMessage     = Session["ok"].ToString();
         Session["ok"] = null;
     }
     errs = new Dictionary <string, string>();
     if (Session["login"] == null)
     {
         Response.Redirect(GlobalVariables.UrlHost);
     }
     account       = new DbLink.Account();
     account.Login = Session["login"].ToString();
     GlobalVariables.Link.GetUser(account);
 }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["ok"] != null)
     {
         SuccessText.Visible  = true;
         showSuccessText.Text = Session["ok"].ToString();
         Session["ok"]        = null;
     }
     if (Session["login"] == null)
     {
         Response.Redirect(GlobalVariables.UrlHost);
     }
     errs          = new Dictionary <PlaceHolder, string>();
     account       = new DbLink.Account();
     account.Login = Session["login"].ToString();
     GlobalVariables.Link.GetUser(account);
     ErrorOldPass.Visible   = false;
     ErrorNewPass.Visible   = false;
     ErrorReNewPass.Visible = false;
 }
Example #5
0
 protected void EditUser()
 {
     account       = new DbLink.Account();
     account.Login = Session["login"].ToString();
     if (GlobalVariables.Link.GetUser(account))
     {
         if (!IsPostBack)
         {
             tbName.Text       = account.Name;
             tbMiddleName.Text = account.MiddleName;
             tbLastName.Text   = account.LastName;
             tbEmail.Text      = account.Email;
             tbPhone.Text      = account.Phone;
         }
     }
     else
     {
         Response.Redirect(GlobalVariables.UrlHost);
     }
 }
Example #6
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (CheckUser() == 0)
     {
         DbLink.Account newAccount = new DbLink.Account()
         {
             Name       = tbName.Text,
             MiddleName = tbMiddleName.Text,
             LastName   = tbLastName.Text,
             Email      = tbEmail.Text,
             Phone      = tbPhone.Text,
         };
         DbLink.Group newGroup = new DbLink.Group()
         {
             Id = DefineGroup()
         };
         if (Mode == "add")
         {
             newAccount.Login    = tbLogin.Text;
             newAccount.Password = tbPass.Text;
             if (GlobalVariables.Link.AddUser(newAccount, newGroup))
             {
                 if (Session["group"] == null)
                 {
                     Session["login"]      = tbLogin.Text;
                     Session["name"]       = tbName.Text;
                     Session["middlename"] = tbMiddleName.Text;
                     Session["lastname"]   = tbLastName.Text;
                     Session["group"]      = newGroup.Id;
                     Session["groupTitle"] = newGroup.Title;
                 }
                 else
                 {
                     Session["ok"] = "Администратор добавлен";
                     Response.Redirect(Request.Url.ToString());
                 }
                 Response.Redirect(GlobalVariables.UrlHost);
             }
             else
             {
                 ErrorInsert.Visible  = true;
                 showErrorInsert.Text = "Ошибка вставки в базу данных";
             }
         }
         else // edit
         {
             newAccount.Login    = Session["login"].ToString();
             newAccount.Password = account.Password;
             if (GlobalVariables.Link.EditUser(newAccount))
             {
                 Session["name"]       = tbName.Text;
                 Session["middlename"] = tbMiddleName.Text;
                 Session["lastname"]   = tbLastName.Text;
                 Session["ok"]         = "Данные изменены";
                 Response.Redirect(Request.Url.ToString());
             }
             else
             {
                 ErrorInsert.Visible  = true;
                 showErrorInsert.Text = "Ошибка вставки в базу данных";
             }
         }
     }
     else
     {
         foreach (var item in Errs)
         {
             item.Key.Visible = true;
             Literal control = (Literal)item.Key.FindControl("show" + item.Key.ID);
             control.Text = item.Value;
         }
     }
 }