using System;
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.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace AeroNet
{
///
/// Summary description for Messages.
///
public class Messages : Common
{
protected System.Web.UI.WebControls.TextBox Question;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvQuestion;
protected System.Web.UI.WebControls.Button AddBtn;
protected System.Web.UI.WebControls.Label lblAdd;
protected string customerID;
private void AddBtn_Click(object sender, System.EventArgs e)
{
if (Page.IsValid == true)
{
// Создание экземпляра объекта подключения и команды
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("MessagesAdd", myConnection);
// Пометка команды как SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Добавление параметров к SPROC
SqlParameter parameterCustomerID = new SqlParameter("@customerID", SqlDbType.Int, 4);
parameterCustomerID.Value = Int32.Parse(customerID);
myCommand.Parameters.Add(parameterCustomerID);
SqlParameter parameterQuestion = new SqlParameter("@question", SqlDbType.VarChar, 1000);
parameterQuestion.Value = Question.Text;
myCommand.Parameters.Add(parameterQuestion);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
Response.Redirect("Messages.aspx",true);
}
catch
{
lblAdd.Text = "
Ошибка при выполнении.
";
}
}
}
protected void PrintMessages()
{
Transform("Messages.xml?customerID="+customerID.ToString(),"Messages.xsl",this.Response,1);
}
private void Page_Load(object sender, System.EventArgs e)
{
///Загрузить верхнее меню
TopMenu();
// Получение ID клиента
customerID = User.Identity.Name;
}
#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.AddBtn.Click += new System.EventHandler(this.AddBtn_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}