📄 cst_orders_add.aspx.cs
字号:
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;
public partial class Admin_CST_Orders_add : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.TxtID.Focus();
if (!this.IsPostBack)
{
string strOrderID = Request["id"].ToString();
if (strOrderID == "")
{
Items IT=new Items ();
DropDownList1.DataSource =IT.showtable();
DropDownList1.DataTextField="name";
DropDownList1.DataValueField="item_id";
DropDownList1.DataBind();
Ccustomer oCou=new Ccustomer ();
DropDownList2.DataSource = oCou.showtab();
DropDownList2.DataTextField = "name";
DropDownList2.DataValueField="cust_id";
DropDownList2.DataBind();
Labitem.Text = "商品名称";
Labcust.Text = "客户名称";
Txtitem_id.Visible=false;
Txtcust_id.Visible = false;
}
else
{
TxtID.Enabled = false;
Txtitem_id.Enabled = false;
Txtcust_id.Enabled = false;
this.Txtquantity.Focus();
DropDownList1.Visible = false;
DropDownList2.Visible = false;
Orders oOrd = new Orders();
DataRowView orders_view = oOrd.show(strOrderID).DefaultView[0];
this.TxtID.Text = orders_view["order_id"].ToString();
this.Txtitem_id.Text = orders_view["item_id"].ToString();
this.Txtcust_id.Text = orders_view["cust_id"].ToString();
this.Txtquantity.Text = orders_view["quantity"].ToString();
this.Txtbase_price.Text = orders_view["base_price"].ToString();
this.Txtorder_date.Text = orders_view["order_date"].ToString();
this.btOk.Text = "修改";
this.LabT.Text = "修改定单";
}
}
}
//修改订单和添加订单
protected void btOk_Click(object sender, EventArgs e)
{
Orders oOrd = new Orders();
if (this.btOk.Text == "修改")
{
bool T = oOrd.Edit(this.TxtID.Text,this.Txtitem_id.Text,this.Txtcust_id.Text,this.Txtquantity.Text,this.Txtbase_price.Text,this.Txtorder_date.Text);
if (T)
{
Response.Write("<script>alert('修改成功!');history.back()</script>");
}
else
{
Response.Write("<script>alert('修改失败!');history.back()</script>");
}
}
else
{
if (oOrd.Add(this.TxtID.Text, this.DropDownList1.Text, this.DropDownList2.Text, this.Txtquantity.Text, this.Txtbase_price.Text, this.Txtorder_date.Text))
{
Response.Write("<script>alert('添加成功!');history.back()</script>");
}
else
{
Response.Write("<script>alert('添加失败!');history.back()</script>");
}
}
}
//清空
protected void btCncel_Click(object sender, EventArgs e)
{
this.TxtID.Text = "";
this.Txtitem_id.Text = "";
this.Txtcust_id.Text = "";
this.Txtquantity.Text = "";
this.Txtbase_price.Text = "";
this.Txtorder_date.Text = "";
}
protected void Txtitem_id_TextChanged(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -