using System; using System.Globalization; using System.Collections; using System.ComponentModel; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace AeroNet.ops { /// /// Входная страница раздела администрирования /// public class ops : Common { protected System.Web.UI.WebControls.Label lblText; protected System.Web.UI.WebControls.Button LogBtn; protected System.Web.UI.WebControls.RequiredFieldValidator rfvLogin; protected System.Web.UI.WebControls.TextBox password; protected System.Web.UI.WebControls.RequiredFieldValidator rvfPass; protected System.Web.UI.WebControls.TextBox login; protected int Result; public string exit; private void LogBtn_Click(object sender, System.EventArgs e) { // Попытка входа в систему делается только в случае, если все поля формы на // странице верны if (Page.IsValid == true) { SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); SqlCommand myCommand = new SqlCommand("ops_Login", myConnection); myCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterLogin = new SqlParameter("@Login", SqlDbType.VarChar, 15); parameterLogin.Value = login.Text; myCommand.Parameters.Add(parameterLogin); SqlParameter parameterPassword = new SqlParameter("@Password", SqlDbType.VarChar, 15); parameterPassword.Value = password.Text; myCommand.Parameters.Add(parameterPassword); SqlParameter parameterResult = new SqlParameter("@Result", SqlDbType.Int, 4); parameterResult.Direction = ParameterDirection.Output; myCommand.Parameters.Add(parameterResult); myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); Result = Convert.ToInt32(parameterResult.Value); if (Result == 1) { Session["admin"]=1; if (Session["exit"] != null) { exit = Session["exit"].ToString(); } else { exit = "/ops/ops_start.aspx"; } Response.Redirect(exit,true); } else { lblText.Text = "
Пользователь не найден. Возможно Вы неправильно указали имя или пароль.

"; } } } private void Page_Load(object sender, System.EventArgs e) { OpsMenu(); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.LogBtn.Click += new System.EventHandler(this.LogBtn_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion } }