📄 maintainsale.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 超市信息管理系统.MarketSystem
{
public partial class MaintainSale : Form
{
private string merchName="";
private double merchPrice = 0.0;
private string sql = "";
public MaintainSale()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
/*
if (textBox1.Text.Trim() == string.Empty)
{
MessageBox.Show("商品编号不能为空");
return;
}
* */
//判断商品编号是否为空
if (textBox2.Text.Trim() == string.Empty)
{
MessageBox.Show("商品编号不能为空");
return;
}
//商品数量是否为空
if (textBox4.Text.Trim() == string.Empty)
{
MessageBox.Show("请输入商品数量");
return;
}
//判断员工编号是否为空
if (textBox6.Text.Trim() == string.Empty)
{
MessageBox.Show("请输入员工编号");
return;
}
sql = "insert into sale values('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + dateTimePicker1.Value.ToUniversalTime() + "','";
sql += textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + comboBox1.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "')";
//录入操作
DataBaseConnection.insert(sql);
/*
SqlConnection con1 = DataBaseConnection.connection();
SqlCommand com = new SqlCommand(sql, con1);
con1.Open();
com.ExecuteNonQuery();
* */
DataRow row = dataSet11.Tables["saleLuRu"].NewRow();
row[0]= textBox1.Text.Trim();
row[1]= textBox2.Text.Trim();
row[2]= textBox3.Text.Trim();
row[3]= dateTimePicker1.Value;
row[4]= textBox4.Text.Trim();
row[5]= textBox5.Text.Trim();
row[6]= comboBox1.Text.Trim();
row[7]= textBox6.Text.Trim();
row[8]= textBox7.Text.Trim();
dataSet11.Tables["saleLuRu"].Rows.Add(row);
}
private void textBox3_Click(object sender, EventArgs e)
{
string temp = "";
SqlConnection con1 = DataBaseConnection.connection(); ;
try
{
con1.Open();
temp = "select * from merch where merchId='" + textBox2.Text.Trim() + "'";
SqlCommand com = new SqlCommand(temp, con1);
SqlDataReader rd= com.ExecuteReader();
while (rd.Read())
{
merchName = rd.GetString(1);
merchPrice = rd.GetDouble(2);
}
textBox3.Text = merchName;
// MessageBox.Show(merchName+merchPrice);
rd.Close();
}
catch (SqlException oe)
{
MessageBox.Show(oe.Message);
}
finally
{
// rd.Close()
con1.Close();
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
if (textBox4.Text.Trim() != string.Empty)
{
double t = Convert.ToDouble(textBox4.Text.Trim()) * merchPrice;
textBox5.Text = Convert.ToString(t);
//MessageBox.Show(textBox5.Text);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -