using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Bll;

public partial class OrdersManage_payment_open : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		DropDownList1.Attributes.Add("OnClick", "bind1()");
		DropDownList2.Attributes.Add("OnClick", "bind2()");

		if (Convert.ToString(Session["username"]) == "")
		{
			Response.Write("<script language=javascript>alert('请登录');location='../login.aspx'</script>");
		}
		if(!IsPostBack)
		{
			this.Instans();
			COPE_MONEY.Text = "";
			OrdersBll ob=new OrdersBll();
			COPE_MONEY.Text = ob.GerSingOrderInfo(Request["id"]);

		}
	}

	protected void Button1_Click(object sender, EventArgs e)
	{
		decimal money = Convert.ToDecimal(FACT_MONEY.Text == "" ? "0.00" : FACT_MONEY.Text);
		string mome = MOME.Text == "" ? "" : MOME.Text;
		string tack_bottle = Tack.Text == "" ? "" : Tack.Text;
		string delivery = Delivery.Text == "" ? "": Delivery.Text;
		string tacknumber = TackNumber.Text == "" ? "" : TackNumber.Text;
		//string delinumber = DeliNumber.Text == "" ? "" : DeliNumber.Text;

		DateTime dt = DateTime.Now;
		if (FACT_MONEY.Text != "")
		{
			OrdersBll ob = new OrdersBll();
			ob.UpdateOrder1(money, dt, mome, Request["id"].ToString());
			Response.Write("<script>alert('收款成功!');opener.location='OrdersManage.aspx';window.close()</script>");
		}

		if (tack_bottle != "")
		{
			OrdersBll ob = new OrdersBll();
			ob.UpdateOrder2(tack_bottle, Request["id"].ToString());
			Response.Write("<script>alert('操作成功!');opener.location='OrdersManage.aspx';window.close()</script>");
		}

		if (delivery != "")
		{
			OrdersBll ob = new OrdersBll();
			ob.UpdateOrder3(delivery,  Request["id"].ToString());
			Response.Write("<script>alert('操作成功!');opener.location='OrdersManage.aspx';window.close()</script>");
		}
        if (tacknumber != "")
        {
            OrdersBll ob = new OrdersBll();
            ob.UpdateOrder4(Convert.ToInt32(tacknumber), Request["id"].ToString());
            Response.Write("<script>alert('操作成功!');opener.location='OrdersManage.aspx';window.close()</script>");
        }
	}

	/// <summary>
	/// 初始化
	/// </summary>
	public void Instans()
	{
		ExpenseManage em = new ExpenseManage();
		DataSet ds = em.GetAllEmplyee();
		DropDownList1.DataSource = ds.Tables[0];
		DropDownList1.AutoPostBack = true;
		DropDownList1.DataTextField = "NAME";
		DropDownList1.DataBind();

		ExpenseManage em1 = new ExpenseManage();
		DataSet ds1 = em.GetAllEmplyee();
		DropDownList2.DataSource = ds.Tables[0];
		DropDownList2.AutoPostBack = true;
		DropDownList2.DataTextField = "NAME";
		DropDownList2.DataBind();
	}
}
