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 PostAddress.
///
public class PostAddress : Common
{
protected int action = 0;
protected int addressID;
protected string orderId;
protected string customerId;
//*******************************************************
//
// Метод AddressItemCount()
//
// Метод AddressItemCount возвращает количество элементов
// в покупательской корзине.
//
//*******************************************************
public int AddressItemCount(int customerID)
{
// Создание экземпляра объекта подключения и команды
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("CustomerAddressCount", myConnection);
// Пометка команды как SPROC
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameterCustomerID = new SqlParameter("@customerID", SqlDbType.Int, 4);
parameterCustomerID.Value = customerID;
myCommand.Parameters.Add(parameterCustomerID);
// Добавление параметров к SPROC
SqlParameter parameterItemCount = new SqlParameter("@ItemCount", SqlDbType.Int, 4);
parameterItemCount.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(parameterItemCount);
// Открытие подключения и выполнение команды
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
// Возвращение ItemCount (получаемого как параметр вывода SPROC)
return ((int)parameterItemCount.Value);
}
protected void PrintAddressList()
{
Transform("CustomerAddress.xml?customerId="+customerId.ToString(),"AddressList.xsl",this.Response,1);
}
protected void PrintAddressListToOrder()
{
if (action == 1)
{
Transform("PostAddress.xml?addressID="+addressID.ToString(),"PostAddress.xsl",this.Response,1);
}
else
{
Transform("CustomerAddress.xml?customerId="+customerId.ToString(),"PostAddress.xsl",this.Response,1);
}
}
private void Page_Load(object sender, System.EventArgs e)
{
//Загрузить верхнее меню
TopMenu();
// Вычисление клиентского ID конечного пользователя
customerId = User.Identity.Name;
//Получить orderId из строки запроса
if (Request.QueryString["orderId"] == null)
{
orderId = "0";
}
else
{
orderId = Convert.ToString(Request.QueryString["orderId"]);
}
// action = 0 - вывод списка адресов
// action = 1 - вывод одного адреса и его правка
// action = 2 - установка связи ordersID с адресом
//Получить action из строки запроса
if (Request.QueryString["action"] == null)
{
action = 0;
}
else
{
action = Convert.ToInt32(Request.QueryString["action"]);
}
//Получить addressID (если выводится один адрес) из строки запроса
if (Request.QueryString["addressID"] == null)
{
addressID = 0;
}
else
{
addressID = Convert.ToInt32(Request.QueryString["addressID"]);
}
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}