📄 cst_items_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_items_add : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.TxtItem_id.Focus();
if (!this.IsPostBack)
{
string strItem_id = Request["id"].ToString();
if (strItem_id == "")
{
Catories oCat = new Catories();
TxtCat.DataSource = oCat.ShowTable();
TxtCat.DataTextField = "name";
TxtCat.DataValueField = "category_id";
TxtCat.DataBind();
this.TextId.Visible = false;
}
else
{
Items oItem = new Items();
DataRowView item_view = oItem.SelectTable(strItem_id).DefaultView[0];
this.TxtItem_id.Text = item_view["item_id"].ToString();
this.TextId.Text = item_view["category_id"].ToString();
this.TxtCat.Visible = false;
this.TxtName.Text = item_view["name"].ToString();
this.TxtDes.Text = item_view["description"].ToString();
this.TxtQua .Text = item_view["quantity"].ToString();
this.TxtPrice .Text = item_view["base_price"].ToString();
this.TxtSmall .Text = item_view["small_image_url"].ToString();
this.TxtBig .Text = item_view["large_image_url"].ToString();
this.BtnOk.Text = "修改";
this.TxtItem_id.Enabled = false;
this.TxtCat.Enabled = false;
this.TxtItem_id.Focus();
}
}
}
protected void BtnOk_Click(object sender, EventArgs e)
{
Items oItem = new Items();
if (this.BtnOk.Text == "修改")
{
bool T = oItem.update(this.TxtItem_id.Text, this.TextId.Text,this.TxtName.Text ,this.TxtDes .Text,this.TxtQua.Text ,this.TxtPrice .Text,this.TxtSmall.Text,this.TxtBig.Text);
if (T)
{
Response.Write("<script>alert('修改成功!');history.back()</script>");
}
else
{
Response.Write("<script>alert('修改失败!');history.back()</script>");
}
}
else
{
if (oItem.Add(this.TxtItem_id.Text, this.TxtCat.Text, this.TxtName.Text, this.TxtDes.Text, this.TxtQua.Text , this.TxtPrice.Text, this.TxtSmall.Text, this.TxtBig.Text))
{
Response.Write("<script>alert('添加成功!');history.back()</script>");
}
else
{
Response.Write("<script>alert('添加失败!');history.back()</script>");
}
}
}
protected void BtnCancel_Click(object sender, EventArgs e)
{
this.TxtItem_id.Text = "";
this.TxtCat.Text = "";
this.TxtName.Text = "";
this.TxtDes.Text = "";
this.TxtQua.Text = "";
this.TxtPrice.Text = "";
this.TxtSmall.Text = "";
this.TxtBig.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -