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

📄 消费累积优惠.cs

📁 管理学院机房计费系统,VISUAL STUDIO .NET 2003 c# 语言实现,SQL SERVER 2000数据库. 现运行正常.
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.sqlConnection1.ConnectionString = "workstation id=XU;packet size=4096;integrated security=SSPI;data source=XU;persis" +
				"t security info=False;initial catalog=jifei";
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "促销名单表", new System.Data.Common.DataColumnMapping[] {
																																																			   new System.Data.Common.DataColumnMapping("条形码", "条形码"),
																																																			   new System.Data.Common.DataColumnMapping("姓名", "姓名"),
																																																			   new System.Data.Common.DataColumnMapping("总花费", "总花费")})});
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 条形码, 姓名, 总花费 FROM 促销名单表";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlCommand1
			// 
			this.sqlCommand1.CommandType = System.Data.CommandType.StoredProcedure;
			this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@limit", System.Data.SqlDbType.NVarChar));
			this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@startTime", System.Data.SqlDbType.NVarChar));
			this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@endTime", System.Data.SqlDbType.NVarChar));
			// 
			// label6
			// 
			this.label6.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label6.Location = new System.Drawing.Point(384, 136);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(40, 23);
			this.label6.TabIndex = 12;
			this.label6.Text = "总计";
			this.label6.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// textBox3
			// 
			this.textBox3.Enabled = false;
			this.textBox3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.textBox3.Location = new System.Drawing.Point(392, 176);
			this.textBox3.Name = "textBox3";
			this.textBox3.TabIndex = 13;
			this.textBox3.Text = "";
			// 
			// label7
			// 
			this.label7.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label7.Location = new System.Drawing.Point(504, 176);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(40, 23);
			this.label7.TabIndex = 14;
			this.label7.Text = "人";
			this.label7.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// label8
			// 
			this.label8.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label8.Location = new System.Drawing.Point(296, 72);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(40, 23);
			this.label8.TabIndex = 15;
			this.label8.Text = "元";
			this.label8.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// 消费累积优惠
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(566, 428);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.dateTimePicker2);
			this.Controls.Add(this.dateTimePicker1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "消费累积优惠";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "消费累积优惠";
			this.Load += new System.EventHandler(this.消费累积优惠_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			int limit;
			try
			{
				limit=int.Parse(this.textBox1.Text);
			}
			catch(FormatException exe)
			{
				MessageBox.Show("输入累积额限无效!","累积额限",MessageBoxButtons.OK,MessageBoxIcon.Error);
				this.textBox1.Text="";
				goto finish;
			}
			string strStart=dateTimePicker1.Value.Date.ToString();
			string strEnd=dateTimePicker2.Value.AddDays(1).Date.ToString();
			//MessageBox.Show(strStart);
			//产生优惠名单表
			string sql="Exec create_namelist '"+ limit.ToString() +"','"+ strStart +"','"+ strEnd +"'";
			SqlCommand cmdYhmd=new SqlCommand(sql,this.sqlConnection1);
			try
			{
				this.sqlConnection1.Open();
				cmdYhmd.ExecuteNonQuery();
			}
			catch(SqlException exe)
			{
				MessageBox.Show("数据库产生优惠名单表出现错误!","产生优惠名单",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			finally
			{
				this.sqlConnection1.Close();
			}
			
			DataSet dsYhmd=new DataSet();
			this.sqlDataAdapter1.Fill(dsYhmd,"优惠名单表");
			this.dataGrid1.SetDataBinding(dsYhmd,"优惠名单表");
			this.dataGrid1.Refresh();
			
			sql="select count(*) from 促销名单表";
			SqlCommand cmd0=new SqlCommand(sql,this.sqlConnection1);
			try
			{
				this.sqlConnection1.Open();
				SqlDataReader rd0=cmd0.ExecuteReader();
				rd0.Read();
				this.textBox3.Text=rd0.GetSqlInt32(0).ToString();
			
			}
			catch(SqlException exe)
			{
				MessageBox.Show("数据库产生优惠名单表出现错误!","产生优惠名单",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			finally
			{
				this.sqlConnection1.Close();
			}
			this.button2.Enabled=true;

			finish:;
		}

		private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
		{
	
		}

		private void 消费累积优惠_Load(object sender, System.EventArgs e)
		{
			this.button2.Enabled=false;
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			int money=0;
			try
			{
				money=int.Parse(this.textBox2.Text);
			}
			catch(FormatException exe)
			{
				MessageBox.Show("输入赠送额无效!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				this.textBox2.Text="";
				goto finish;
			}
			
			if(int.Parse(this.textBox3.Text)>0)
			{
				this.addMoney(money);
			}
			else
			{
				goto finish;
			}
			this.button2.Enabled=false;
			finish:;
		}
		private void addMoney(int money)
		{
			string sql="Exec add_money '"+ money +"'";
			SqlCommand cmdAddMoney=new SqlCommand(sql,this.sqlConnection1);
			try
			{
				this.sqlConnection1.Open();
				int i=cmdAddMoney.ExecuteNonQuery();
				MessageBox.Show("执行成功!共为"+ i.ToString() +"个账户各充值"+ money.ToString() +"元","成功",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			catch(SqlException exe)
			{
				MessageBox.Show("执行赠送金额出错,事务回滚!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			finally
			{
				this.sqlConnection1.Close();
			}
		}
	}
}

⌨️ 快捷键说明

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