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

📄 todaysellform.cs

📁 超市管理系统的完整版文档
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using SupDataBase;
using System.Data.SqlClient;

namespace WindowsApplication1
{
	/// <summary>
	/// TodaySellForm 的摘要说明。
	/// </summary>
	public class TodaySellForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid m_dataGrid;
		private System.Data.SqlClient.SqlConnection m_sqlConn;
		private System.Data.SqlClient.SqlCommand m_sqlCommand;
		private System.Windows.Forms.Label label1;
		
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public TodaySellForm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.m_dataGrid = new System.Windows.Forms.DataGrid();
			this.m_sqlConn = new System.Data.SqlClient.SqlConnection();
			this.m_sqlCommand = new System.Data.SqlClient.SqlCommand();
			this.label1 = new System.Windows.Forms.Label();
			((System.ComponentModel.ISupportInitialize)(this.m_dataGrid)).BeginInit();
			this.SuspendLayout();
			// 
			// m_dataGrid
			// 
			this.m_dataGrid.CaptionVisible = false;
			this.m_dataGrid.DataMember = "";
			this.m_dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.m_dataGrid.Location = new System.Drawing.Point(24, 64);
			this.m_dataGrid.Name = "m_dataGrid";
			this.m_dataGrid.Size = new System.Drawing.Size(856, 400);
			this.m_dataGrid.TabIndex = 0;
			// 
			// m_sqlCommand
			// 
			this.m_sqlCommand.Connection = this.m_sqlConn;
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(368, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(112, 32);
			this.label1.TabIndex = 1;
			this.label1.Text = "今日销售";
			// 
			// TodaySellForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(896, 502);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.m_dataGrid);
			this.Name = "TodaySellForm";
			this.Text = "今日销售";
			this.Load += new System.EventHandler(this.TodaySellForm_Load);
			((System.ComponentModel.ISupportInitialize)(this.m_dataGrid)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void TodaySellForm_Load(object sender, System.EventArgs e)
		{   
            System.DateTime dtime=new System.DateTime();
			dtime = System.DateTime.Now;
			try
			{
				

				String sql  ="select SaleNo,GoodsCode,GoodsName,SaleRecord.SalePrice,SaleRecord.PurchasePrice,SaleNumber,Unit,(SaleRecord.SalePrice)*SaleNumber as MoneyCount,SaleTime"+
					                       " from SaleRecord , Goods"+
                                           " where SaleRecord.GoodsID=Goods.GoodsID"+
                                           " and year(Saletime)=" + dtime.Year.ToString()+" and month(Saletime)=" + dtime.Month.ToString() +" and day(Saletime)=" + dtime.Day.ToString();



				System.Data.DataTable datatable = new System.Data.DataTable();
				System.Data.DataRow datarow;
				datatable.Columns.Add(new System.Data.DataColumn("销售记录号"));
				datatable.Columns.Add(new System.Data.DataColumn("商品条码"));
				datatable.Columns.Add(new System.Data.DataColumn("商品名称"));
				datatable.Columns.Add(new System.Data.DataColumn("售价"));
				datatable.Columns.Add(new System.Data.DataColumn("数量"));
				datatable.Columns.Add(new System.Data.DataColumn("小计"));
				datatable.Columns.Add(new System.Data.DataColumn("销售日期"));



				m_sqlConn = DBUtil.GetConnection();
				m_sqlConn.Open();
				SqlCommand cmd = new SqlCommand(sql, m_sqlConn);
				SqlDataReader reader = cmd.ExecuteReader();

				while (reader.Read())
				{
					datarow = datatable.NewRow();
					datarow[0] = reader["SaleNo"];
					datarow[1] = reader["GoodsCode"];
					datarow[2] = reader["GoodsName"];
					datarow[3] = reader["SalePrice"];
					datarow[4] = reader["SaleNumber"];
					datarow[5] = reader["MoneyCount"];
					datarow[6] = reader["SaleTime"];
					datatable.Rows.Add(datarow);
				}
				System.Data.DataView dataview = new System.Data.DataView(datatable);
				dataview.AllowNew = false;
				dataview.AllowEdit = false;
				dataview.AllowDelete = false;

				m_dataGrid.DataSource = dataview;
				m_sqlConn.Close();

			}
			catch(SqlException ex)
			{
			    MessageBox.Show("打开数据库出错!");
			}
          
		}
	}
}

⌨️ 快捷键说明

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