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

📄 returnform.cs

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

namespace WindowsApplication1
{
	/// <summary>
	/// ReturnForm 的摘要说明。
	/// </summary>
	public class ReturnForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox m_txtGoodsCode;
		private System.Windows.Forms.TextBox m_txtReason;
		private System.Windows.Forms.TextBox m_txtMoney;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Button m_bntConfirm;
		private System.Windows.Forms.Button m_bntCancel;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.TextBox m_txtGoodsName;
		private System.Windows.Forms.TextBox m_txtGoodsID;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ReturnForm()
		{
			//
			// 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_txtGoodsCode = new System.Windows.Forms.TextBox();
			this.m_bntConfirm = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.m_txtReason = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.m_bntCancel = new System.Windows.Forms.Button();
			this.m_txtMoney = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.m_txtGoodsName = new System.Windows.Forms.TextBox();
			this.m_txtGoodsID = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// m_txtGoodsCode
			// 
			this.m_txtGoodsCode.Location = new System.Drawing.Point(120, 40);
			this.m_txtGoodsCode.Name = "m_txtGoodsCode";
			this.m_txtGoodsCode.Size = new System.Drawing.Size(216, 21);
			this.m_txtGoodsCode.TabIndex = 0;
			this.m_txtGoodsCode.Text = "";
			this.m_txtGoodsCode.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.m_txtGoodsCode_KeyPress);
			// 
			// m_bntConfirm
			// 
			this.m_bntConfirm.Location = new System.Drawing.Point(88, 256);
			this.m_bntConfirm.Name = "m_bntConfirm";
			this.m_bntConfirm.TabIndex = 1;
			this.m_bntConfirm.Text = "确定";
			this.m_bntConfirm.Click += new System.EventHandler(this.m_bntConfirm_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(48, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "商品条码";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(48, 104);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(64, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "退货理由";
			// 
			// m_txtReason
			// 
			this.m_txtReason.Location = new System.Drawing.Point(120, 104);
			this.m_txtReason.Multiline = true;
			this.m_txtReason.Name = "m_txtReason";
			this.m_txtReason.Size = new System.Drawing.Size(216, 56);
			this.m_txtReason.TabIndex = 4;
			this.m_txtReason.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(48, 200);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(56, 16);
			this.label3.TabIndex = 5;
			this.label3.Text = "退货金额";
			// 
			// m_bntCancel
			// 
			this.m_bntCancel.Location = new System.Drawing.Point(240, 256);
			this.m_bntCancel.Name = "m_bntCancel";
			this.m_bntCancel.Size = new System.Drawing.Size(64, 23);
			this.m_bntCancel.TabIndex = 6;
			this.m_bntCancel.Text = "取消";
			this.m_bntCancel.Click += new System.EventHandler(this.m_bntCancel_Click);
			// 
			// m_txtMoney
			// 
			this.m_txtMoney.Location = new System.Drawing.Point(120, 192);
			this.m_txtMoney.Name = "m_txtMoney";
			this.m_txtMoney.Size = new System.Drawing.Size(72, 21);
			this.m_txtMoney.TabIndex = 7;
			this.m_txtMoney.Text = "";
			// 
			// label4
			// 
			this.label4.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label4.Location = new System.Drawing.Point(160, 16);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(88, 24);
			this.label4.TabIndex = 8;
			this.label4.Text = "商品退货";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(48, 72);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(56, 24);
			this.label5.TabIndex = 9;
			this.label5.Text = "商品名称";
			// 
			// m_txtGoodsName
			// 
			this.m_txtGoodsName.Location = new System.Drawing.Point(120, 72);
			this.m_txtGoodsName.Name = "m_txtGoodsName";
			this.m_txtGoodsName.Size = new System.Drawing.Size(216, 21);
			this.m_txtGoodsName.TabIndex = 10;
			this.m_txtGoodsName.Text = "";
			// 
			// m_txtGoodsID
			// 
			this.m_txtGoodsID.Location = new System.Drawing.Point(160, 304);
			this.m_txtGoodsID.Name = "m_txtGoodsID";
			this.m_txtGoodsID.Size = new System.Drawing.Size(64, 21);
			this.m_txtGoodsID.TabIndex = 11;
			this.m_txtGoodsID.Text = "";
			this.m_txtGoodsID.Visible = false;
			// 
			// ReturnForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(400, 334);
			this.Controls.Add(this.m_txtGoodsID);
			this.Controls.Add(this.m_txtGoodsName);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.m_txtMoney);
			this.Controls.Add(this.m_bntCancel);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.m_txtReason);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.m_bntConfirm);
			this.Controls.Add(this.m_txtGoodsCode);
			this.Name = "ReturnForm";
			this.Text = "退货";
			this.Load += new System.EventHandler(this.ReturnForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

	

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

		private void m_txtGoodsCode_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if (e.KeyChar != 13 && e.KeyChar != 8 && e.KeyChar!=22 && (e.KeyChar < '0'|| e.KeyChar > '9'))
			{				
				e.Handled = true;
			}

			if(e.KeyChar == 13)
			{  
				e.Handled = true;
				OnGoodsCodeEnter();
			}
		}

		private void OnGoodsCodeEnter()
		{
		    string gcode = m_txtGoodsCode.Text;
		    string sql = "select * from Goods where GoodsCode='"+gcode+"'";
		   
		    SqlConnection conn = DBUtil.GetConnection();

		    SqlCommand command = new SqlCommand ("",conn);
			command.Connection.Open();
            command.CommandText = sql;
			SqlDataReader  readerset = command.ExecuteReader();

			if(readerset.Read())
			{   
				m_txtGoodsName.Text = readerset["GoodsName"].ToString();
				m_txtMoney.Text = readerset["SalePrice"].ToString();
		        m_txtGoodsID.Text = readerset["GoodsID"].ToString();
			}
			else
			{
			   MessageBox.Show("该商品非本店出售");
			}
		    conn.Close();
		
		}

		private void m_bntConfirm_Click(object sender, System.EventArgs e)
		{
			string reason = this.m_txtReason.Text;
			double money;

			if(reason == "")
			{
			   MessageBox.Show("退货理由不能为空");
				return ;
			
			}

		    int  goodsid = System.Convert.ToInt32(this.m_txtGoodsID.Text);
			try
			{
				 money = System.Convert.ToDouble(this.m_txtMoney.Text);

			}
			catch (System.FormatException ex)
			{
			    
				MessageBox.Show("请检查退货金额的格式");
				return ;
			}
			string sql = "insert into TakeBack (GoodsID,Reason,Money) values ("+
				          goodsid.ToString() + 
				          ", '" + reason+"',"+
				          money.ToString() +")";

			SqlConnection conn = DBUtil.GetConnection();
            SqlCommand command = new SqlCommand ("",conn);
			command.Connection.Open();
			command.CommandText = sql;
		    int rows = command.ExecuteNonQuery();
			if(rows>0)
			{
				MessageBox.Show("退货成功");
			}
			conn.Close();

		}

		private void m_bntCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

	}
}

⌨️ 快捷键说明

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