📄 material.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication5
{
/// <summary>
/// Material 的摘要说明。
/// </summary>
public class Material : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ImageButton Img_save;
protected System.Web.UI.WebControls.ImageButton Img_search;
protected System.Web.UI.WebControls.TextBox r_ID;
protected System.Web.UI.WebControls.DropDownList DDList1;
protected System.Web.UI.WebControls.DropDownList DDList2;
protected System.Web.UI.WebControls.DropDownList DDList3;
protected System.Web.UI.WebControls.DropDownList DDList4;
protected System.Web.UI.WebControls.TextBox Account;
protected System.Web.UI.WebControls.TextBox PayMent;
protected System.Web.UI.WebControls.TextBox Remark;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox Txt_id;
protected System.Web.UI.WebControls.DropDownList DD_year;
protected System.Web.UI.WebControls.DropDownList DD_month;
protected System.Web.UI.WebControls.DropDownList DD_provider;
protected System.Web.UI.WebControls.DropDownList DD_material;
protected System.Web.UI.WebControls.TextBox Txt_price;
protected System.Web.UI.WebControls.TextBox Txt_amount;
protected System.Web.UI.WebControls.TextBox Txt_money;
protected System.Web.UI.WebControls.DropDownList DD_unit;
protected System.Web.UI.WebControls.DropDownList DD_catagory;
protected System.Web.UI.WebControls.TextBox Txt_remark;
protected System.Web.UI.WebControls.Panel Panel1;
protected DataBase Data=new DataBase();
protected Resource Res=new Resource();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Data.AddEvent("确定是否存盘?",Img_save,"onclick");
if (!Page.IsPostBack)
{
Txt_price.Text="0";
Txt_amount.Text="0";
Txt_money.Text="0";
InitData();
Data.BindData(DataGrid1,"select * from material_info","material_info");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Img_save.Click += new System.Web.UI.ImageClickEventHandler(this.Img_save_Click);
this.Img_search.Click += new System.Web.UI.ImageClickEventHandler(this.Img_search_Click);
this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void InitData()
{
Txt_id.Text=Convert.ToString(Data.GetResultCount("material_info")+1);
////添加年项目到控件///
for (int i=0;i<=30;i++)
{
DD_year.Items.Add(Convert.ToString(1990+i));
}
////绑定数据到月控件///
for (int j=0;j<=11;j++)
{
DD_month.Items.Add(Convert.ToString(j+1));
}
////绑定到计量单位控件///
for (int i=0;i<Res.UNIT_NAME.Length;i++)
{
DD_unit.Items.Add(Res.UNIT_NAME[i]);
}
Data.BindData(DD_provider,"select * from provider","provider","c_name");
DD_catagory.Items.Add("包装");
DD_catagory.Items.Add("原材料");
DD_catagory.Items.Add("辅助材料");
DD_material.Items.Add("大米");
}
private void Img_save_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
int c_id=Int32.Parse(Txt_id.Text);
if ((Txt_id.Text).ToString().Trim()=="")
{
Data.ShowMessage("序号不能为空!",Page);
return;
}
if (Data.FindID("material_info",c_id))
{
Data.ShowMessage("此记录已经存在...",Page);
return;
}
string m_year=(DD_year.SelectedItem.Value).ToString().Trim();
string m_month=(DD_month.SelectedItem.Value).ToString().Trim();
string m_provider=(DD_provider.SelectedItem.Value).ToString().Trim();
string m_material=(DD_material.SelectedItem.Value).ToString().Trim();
int m_price=Int32.Parse(Txt_price.Text);
int m_amount=Int32.Parse(Txt_amount.Text);
int m_money=Int32.Parse(Txt_money.Text);
string m_unit=(DD_unit.SelectedItem.Value).ToString().Trim();
string m_catagory=(DD_catagory.SelectedItem.Value).ToString().Trim();
string m_remark=(Txt_remark.Text);
////
string strInsert="Insert Into material_info(c_id,m_year,m_month,m_provider,m_material,m_price,m_amount,m_money,m_unit,m_catagory,m_remark) values("+c_id;
strInsert+=",'"+m_year+"','"+m_month+"','"+m_provider+"','"+m_material+"',"+m_price+","+m_amount+","+m_money+",'"+m_unit+"','"+m_catagory+"','"+m_remark+"')";
Data.ShowMessage(strInsert,Page);
Data.runNonSql(strInsert);
Data.BindData(DataGrid1,"select * from material_info","material_info");
}
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseOver","this.style.backgroundColor='seashell'");
e.Item.Attributes.Add("onmouseOut","this.style.backgroundColor='white'");
}
}
private void Img_search_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("MaterialFind.aspx");
}
}///类结束
}///命名空间结束
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -