⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cacountin.aspx.cs

📁 用Visual C#.net开发企业材料采购管理系统数据库使用的是SqlServer2000
💻 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>
	/// CAcountIN 的摘要说明。
	/// </summary>
	public class CAcountIN : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.ImageButton Img_search;
		protected System.Web.UI.WebControls.ImageButton Img_edit;
		protected System.Web.UI.WebControls.ImageButton Img_report;
		protected System.Web.UI.WebControls.ImageButton Img_save;
	    protected DataBase Data=new  DataBase();
		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 r_ID;
		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.Panel Panel1;
		protected Resource res=new Resource(); 
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			Data.AddEvent("确定是否存盘?",Img_save,"onclick");  
			if (!Page.IsPostBack)
			{    
			    //Data.OpenConn();    
				Data.BindData(DataGrid1,"SELECT * FROM LIST","LIST"); 
				Data.BindData(DDList3,"SELECT * FROM PROVIDER","PROVIDER","C_NAME");
				Data.BindData(DDList4,"SELECT * FROM GOODS","GOODS","C_NAME");
				
				
				InitData();
			}
		}
		private void InitData()
		{
			  ////添加年项目到控件///
			for (int i=0;i<=30;i++)
			{
				DDList1.Items.Add(Convert.ToString(1990+i));
			}
			////绑定数据到月控件///
			for (int j=0;j<=11;j++)
			{
				DDList2.Items.Add(Convert.ToString(j+1));  
			}
			///初始化数据到货物名称
			//for (int i=0;i<=res.GOODS_NAME.Length-1;i++)
			//{
			//	 DDList4.Items.Add(res.GOODS_NAME[i]);
			//}
			////自动添加序号////
            r_ID.Text=Convert.ToString(Data.GetResultCount("List")+1);

		}
		
		#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.Img_report.Click += new System.Web.UI.ImageClickEventHandler(this.Img_report_Click);
			this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Img_save_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{   

			if ((Account.Text).ToString().Trim()=="")
			{
                Data.ShowMessage("输入挂帐不能为空!",Page);
				return;
			}
			///验证付款是否为空///
			if ((PayMent.Text).ToString().Trim()=="")
			{
				Data.ShowMessage("输入付款不能为空!",Page);
				return;
			}
			int c_id=Int32.Parse((r_ID.Text).ToString().Trim());
			if (Data.FindID("List",c_id))
			{
				Data.ShowMessage("此记录已经存在!",Page);
				r_ID.Text=Convert.ToString(Data.GetResultCount("List")+1);
				return;
            }
            string c_year=DDList1.SelectedItem.Value;
			string c_month=DDList2.SelectedItem.Value;
			string c_provider=DDList3.SelectedItem.Value;
			string c_goods=DDList4.SelectedItem.Value;
			int c_account=Int32.Parse((Account.Text).ToString().Trim());
			int c_payment=Int32.Parse((PayMent.Text).ToString().Trim());
			string c_remark=(Remark.Text).ToString().Trim();
			////定义插入记录的查询语句///   
			string strUpdate="Insert into  list(c_year,c_month,c_provider,c_goods,c_account,c_payment,c_remark) values('"+c_year+"','"+c_month+"','"+c_provider+"','"+c_goods+"',"+c_account+","+c_payment+",'"+c_remark+"')";
			////执行插入记录大查询///
			Data.runNonSql(strUpdate);
			////重新绑定数据源
            Data.BindData(DataGrid1,"SELECT * FROM LIST","LIST"); 
			////自动添加序号////
			r_ID.Text=Convert.ToString(Data.GetResultCount("List")+1);
			
		}

		private void Img_search_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
		    Response.Redirect("CAaccountFind.aspx"); 
			
		}

		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_report_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect("CAreport.aspx"); 
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -