本来不想发这个实验的,但是数据库期末考试考的巨差,心情很不好,不想打游戏了,把实验发出来给大伙参考一下吧。
实验是我在准备一堆考试的时候赶工出来的,界面奇丑无比,数据库设计也是几乎没有,如果你只是图个及格可以参考我的程序,想申优建议网上找教程或者自己写一个。
开发环境用的是Visual Studio 2019,语言C#,数据库用的是SQL server。
数据库中一共四张表,分别是扫描信息,商品信息,职工信息,账户信息。
扫描信息里面是收银台扫描该商品的具体时间,精确到秒(本来想精确到小数点后三位的,但是不知道为什么对显示到datagridview里在提取出来就只有小数点前面了,改format也只是改了显示,tostring之后还是没有小数点后,然后我懒得查资料了,就这样吧),以扫描时间为主键,毕竟收银台扫描条形码是有时间间隔的,两次购物的扫描时间肯定是不一样的,我个人建议自己设置一个编号为主键,但是当时没想起来,现在也不想改了,扫描信息的属性还有商品编号,商品名称,单价,质量,总价,扫描人员编号。
商品信息以商品编号为主键,商品名称,单价,库存都是可以重复的。
职工信息以编号为主键,姓名职位什么的随便起,在职情况对外不可见,用于避免编号重复。
账户信息独立于其他三张表,以用户名(账号)为主键,权限只有两种,经理和员工,与职员的职位无关,仅表示账户权限,经理权限账户在手动注册时密码应当有固定前缀jldkl,当然也可以让程序员在数据库中预置好账号。
没有创建视图,存储过程,触发器,也不符合第三范式,纯粹是为了及格来的,界面也丑的离谱,年月日都要手输,C#是我纯自学的,甚至都没看过教程视频,程序写完了才发现还有datetimepicker这种东西,改不动了。
程序的流程图如下,右键修改是老师验收的时候让我加的,所以只能右键修改扫描信息,会直接跳转到修改界面,虽然文本框里日期是0,但是后台已经填好了,为什么不显示出来?答案是我懒,不想改了。老师还让我新加了一个功能,具体要求我忘了,按钮在form4里,内容写在form8里,不想要可以自行删除,不要吐槽界面丑了,毕竟赶工出来的,能动就行,要什么自行车。
补充一句,查询商品信息那里只能填一项查询条件,我也不知道当时为什么这么限制,想改的自己改一下,我在软件测试与质量保证的实验里改了,但是为了其他实验要求把程序改的面目全非,根本不适合放在这里。
下面把代码放一下,不过窗体布局什么的就不放上来了,代码仅供没学过C#的人参考一下,直接复制粘贴是运行不了的。
form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class login_page : Form
{
public login_page()
{
InitializeComponent();
}
private void login_button_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("用户名不可为空!");
return;
}
if (string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("密码不可为空!");
return;
}
/*if (string.IsNullOrEmpty(comboBox1.Text))
{
//MessageBox.Show("填写你的权限!");
//return;
}*/
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection log_con = new SqlConnection(constr);
log_con.Open();
if (log_con.State != ConnectionState.Open)
{
MessageBox.Show("数据库打开失败!错误位于登录按钮!");
return;
}
string userstr = textBox1.Text;
string passwordstr = textBox2.Text;
string rightstr = comboBox1.Text;
string select_user = "SELECT * FROM 账户 WHERE ID='" + userstr + "'";
SqlCommand cmd = new SqlCommand(select_user,log_con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
if (dr["PASSWORD"].ToString() == passwordstr)
{
if (dr["JOB"].ToString() == rightstr)
{
if (rightstr == "经理")
{
Manager_Page form4 = new Manager_Page();
form4.ShowDialog();
}
if (rightstr == "员工")
{
staff_right form3 = new staff_right();
form3.ShowDialog();
}
}
else
{
MessageBox.Show("密码或权限有误");
// textBox1.Text = "";
// textBox2.Text = "";
//comboBox1.Text = "";
}
}
else
{
MessageBox.Show("密码或权限有误");
//textBox1.Text = "";
//textBox2.Text = "";
// comboBox1.Text = "";
}
}
else
{
MessageBox.Show("无此用户,检查你的输入");
//textBox1.Text = "";
//textBox2.Text = "";
//comboBox1.Text = "";
}
log_con.Close();
}
private void user_name_label_Click(object sender, EventArgs e)
{
}
private void user_password_label_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
string[] str = new string[] { "经理", "员工" };
comboBox1.Items.AddRange(str);
comboBox1.SelectedIndex = 1;
comboBox1.Text = "员工";
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void register_button_Click(object sender, EventArgs e)
{
regist form2 = new regist();
form2.ShowDialog();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
bool check=false;
private void radioButton1_Click(object sender, EventArgs e)
{
if (check){
radioButton1.Checked = false;
check = false;
}
else
{
radioButton1.Checked = true;
check = true;
}
if (radioButton1.Checked == true)
{
textBox2.PasswordChar = '\0';
}
if (radioButton1.Checked == false)
{
textBox2.PasswordChar = '*';
}
}
private void right_label_Click(object sender, EventArgs e)
{
}
}
}
designer
namespace WindowsFormsApp3
{
partial class login_page
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.login_button = new System.Windows.Forms.Button();
this.register_button = new System.Windows.Forms.Button();
this.user_name_label = new System.Windows.Forms.Label();
this.user_password_label = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.right_label = new System.Windows.Forms.Label();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
//
// login_button
//
this.login_button.Location = new System.Drawing.Point(206, 293);
this.login_button.Name = "login_button";
this.login_button.Size = new System.Drawing.Size(124, 64);
this.login_button.TabIndex = 0;
this.login_button.Text = "登录";
this.login_button.UseVisualStyleBackColor = true;
this.login_button.Click += new System.EventHandler(this.login_button_Click);
//
// register_button
//
this.register_button.Location = new System.Drawing.Point(494, 293);
this.register_button.Name = "register_button";
this.register_button.Size = new System.Drawing.Size(113, 64);
this.register_button.TabIndex = 1;
this.register_button.Text = "注册";
this.register_button.UseVisualStyleBackColor = true;
this.register_button.Click += new System.EventHandler(this.register_button_Click);
//
// user_name_label
//
this.user_name_label.AutoSize = true;
this.user_name_label.Location = new System.Drawing.Point(203, 88);
this.user_name_label.Name = "user_name_label";
this.user_name_label.Size = new System.Drawing.Size(62, 18);
this.user_name_label.TabIndex = 2;
this.user_name_label.Text = "用户名";
this.user_name_label.Click += new System.EventHandler(this.user_name_label_Click);
//
// user_password_label
//
this.user_password_label.AutoSize = true;
this.user_password_label.Location = new System.Drawing.Point(203, 144);
this.user_password_label.Name = "user_password_label";
this.user_password_label.Size = new System.Drawing.Size(44, 18);
this.user_password_label.TabIndex = 3;
this.user_password_label.Text = "密码";
this.user_password_label.Click += new System.EventHandler(this.user_password_label_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(294, 88);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 28);
this.textBox1.TabIndex = 4;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(294, 133);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(100, 28);
this.textBox2.TabIndex = 5;
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(486, 88);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 26);
this.comboBox1.TabIndex = 6;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// right_label
//
this.right_label.AutoSize = true;
this.right_label.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.right_label.Location = new System.Drawing.Point(433, 91);
this.right_label.Name = "right_label";
this.right_label.Size = new System.Drawing.Size(44, 18);
this.right_label.TabIndex = 7;
this.right_label.Text = "权限";
this.right_label.Click += new System.EventHandler(this.right_label_Click);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(436, 138);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(105, 22);
this.radioButton1.TabIndex = 8;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "显示密码";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
//
// login_page
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.right_label);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.user_password_label);
this.Controls.Add(this.user_name_label);
this.Controls.Add(this.register_button);
this.Controls.Add(this.login_button);
this.Name = "login_page";
this.Text = "Login_Page";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button login_button;
private System.Windows.Forms.Button register_button;
private System.Windows.Forms.Label user_name_label;
private System.Windows.Forms.Label user_password_label;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label right_label;
private System.Windows.Forms.RadioButton radioButton1;
}
}
form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class regist : Form
{
public regist()
{
InitializeComponent();
}
private void return_login_button_Click(object sender, EventArgs e)
{
this.Close();
}
private void regist_button_Click(object sender, EventArgs e)
{
right_box.SelectedIndex = 1;
if (string.IsNullOrEmpty(user_namebox.Text))
{
MessageBox.Show("账号为空");
return;
}
else if (string.IsNullOrEmpty(password_box.Text))
{
MessageBox.Show("密码为空");
return;
}
else if (string.IsNullOrEmpty(confirm_box.Text))
{
MessageBox.Show("确认密码为空");
return;
}
else if (string.IsNullOrEmpty(right_box.Text))
{
MessageBox.Show("权限为空");
return;
}
string userstr = user_namebox.Text;
string password_str = password_box.Text;
string right = right_box.Text;
if (userstr.Length < 5)
{
MessageBox.Show("用户名过短");
return;
}
if (password_str.Length < 5)
{
MessageBox.Show("密码过短");
return;
}
if (password_box.Text != confirm_box.Text)
{
MessageBox.Show("两次输入的密码不一致");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection reg_con = new SqlConnection(constr);
reg_con.Open();
if (reg_con.State != ConnectionState.Open)
{
MessageBox.Show("数据库打开失败!错误位于注册页面的注册按钮!");
return;
}
string select_user = "SELECT * FROM 账户 WHERE ID='" + userstr + "'";
SqlCommand cmd_sel = new SqlCommand(select_user, reg_con);
SqlDataReader dr_sel = cmd_sel.ExecuteReader();
if (dr_sel.HasRows)
{
MessageBox.Show("该用户已存在!");
user_namebox.Text = "";
reg_con.Close();
return;
}
else
{
reg_con.Close();
string token = "jldkl";//此处为经理账号固定密码前五位
if (right == "经理")
{
for (int i = 0; i < 5; i++)
{
if (password_str[i] != token[i])
{
MessageBox.Show("请询问经理如何注册经理账号!");
password_box.Text = "";
confirm_box.Text = "";
return;
}
}
}
string insert_str = "insert into 账户(ID,PASSWORD,JOB)values('" + userstr + "','" + password_str + "','" + right + "')";
SqlCommand reg_cmd = new SqlCommand(insert_str, reg_con);
try
{
reg_con.Open();
int num = reg_cmd.ExecuteNonQuery();
if (num > 0)
{
MessageBox.Show("注册成功");
reg_con.Close();
return;
}
else
{
MessageBox.Show("注册失败");
reg_con.Close();
return;
}
}
catch(Exception ex)
{
MessageBox.Show("错误位于注册添加用户阶段");
return;
}
}
}
private void password_box_TextChanged(object sender, EventArgs e)
{
if (password_box.Text.Length > 10)
{
password_box.Text = "";
MessageBox.Show("输入过长");
return;
}
if (password_box.Text.Length < 5 && password_box.Text.Length > 0)
{
label1.Text = "输入的密码过短";
}
else
{
label1.Text = "";
}
}
private void user_namebox_TextChanged(object sender, EventArgs e)
{
if (user_namebox.Text.Length > 10)
{
user_namebox.Text = "";
MessageBox.Show("输入过长");
return;
}
if (user_namebox.Text.Length < 5 && user_namebox.Text.Length > 0)
{
label1.Text = "输入的账号过短";
}
else
{
label1.Text = "";
}
}
private void right_box_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void confirm_box_TextChanged(object sender, EventArgs e)
{
if (confirm_box.Text.Length > 10)
{
confirm_box.Text = "";
MessageBox.Show("输入过长");
return;
}
if (confirm_box.Text.Length < 5 && confirm_box.Text.Length > 0)
{
label1.Text = "输入的密码过短";
}
else
{
label1.Text = "";
}
}
private void limit_Click(object sender, EventArgs e)
{
}
private void regist_Load(object sender, EventArgs e)
{
string[] str = new string[] { "经理", "员工" };
right_box.Items.AddRange(str);
}
private void password_box_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z')||e.KeyChar=='\b')
{
}
else
{
password_box.Text = "";
e.Handled = true;
MessageBox.Show("你的输入有误,重新输入!");
return;
}
}
private void confirm_box_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z') || e.KeyChar == '\b')
{
}
else
{
MessageBox.Show("你的输入不符合格式,重新输入!");
confirm_box.Text = "";
e.Handled = true;
return;
}
}
private void user_namebox_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z') || e.KeyChar == '\b')
{
}
else
{
MessageBox.Show("你的输入有误,重新输入!");
user_namebox.Clear();
e.Handled = true;
/*char temp=Console.ReadKey().KeyChar;
while( string.IsNullOrEmpty(temp.ToString())){
temp = Console.ReadKey().KeyChar;
}*/
}
}
bool check = false;
private void radioButton1_Click(object sender, EventArgs e)
{
if (check)
{
radioButton1.Checked = false;
check = false;
}
else
{
radioButton1.Checked = true;
check = true;
}
if (radioButton1.Checked == true)
{
password_box.PasswordChar = '\0';
confirm_box.PasswordChar = '\0';
}
if (radioButton1.Checked == false)
{
password_box.PasswordChar = '*';
confirm_box.PasswordChar = '*';
}
}
}
}
designer
namespace WindowsFormsApp3
{
partial class regist
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.regist_button = new System.Windows.Forms.Button();
this.user_name_label = new System.Windows.Forms.Label();
this.password_label = new System.Windows.Forms.Label();
this.right_box = new System.Windows.Forms.ComboBox();
this.right = new System.Windows.Forms.Label();
this.user_namebox = new System.Windows.Forms.TextBox();
this.password_box = new System.Windows.Forms.TextBox();
this.confirm_label = new System.Windows.Forms.Label();
this.confirm_box = new System.Windows.Forms.TextBox();
this.limit = new System.Windows.Forms.Label();
this.return_login_button = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// regist_button
//
this.regist_button.Location = new System.Drawing.Point(503, 292);
this.regist_button.Name = "regist_button";
this.regist_button.Size = new System.Drawing.Size(179, 73);
this.regist_button.TabIndex = 0;
this.regist_button.Text = "点击此处注册新账号";
this.regist_button.UseVisualStyleBackColor = true;
this.regist_button.Click += new System.EventHandler(this.regist_button_Click);
//
// user_name_label
//
this.user_name_label.AutoSize = true;
this.user_name_label.Location = new System.Drawing.Point(163, 116);
this.user_name_label.Name = "user_name_label";
this.user_name_label.Size = new System.Drawing.Size(44, 18);
this.user_name_label.TabIndex = 1;
this.user_name_label.Text = "账号";
//
// password_label
//
this.password_label.AutoSize = true;
this.password_label.Location = new System.Drawing.Point(163, 181);
this.password_label.Name = "password_label";
this.password_label.Size = new System.Drawing.Size(44, 18);
this.password_label.TabIndex = 2;
this.password_label.Text = "密码";
//
// right_box
//
this.right_box.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.right_box.FormattingEnabled = true;
this.right_box.Location = new System.Drawing.Point(545, 113);
this.right_box.Name = "right_box";
this.right_box.Size = new System.Drawing.Size(121, 26);
this.right_box.TabIndex = 3;
this.right_box.SelectedIndexChanged += new System.EventHandler(this.right_box_SelectedIndexChanged);
//
// right
//
this.right.AutoSize = true;
this.right.Location = new System.Drawing.Point(474, 116);
this.right.Name = "right";
this.right.Size = new System.Drawing.Size(44, 18);
this.right.TabIndex = 4;
this.right.Text = "权限";
//
// user_namebox
//
this.user_namebox.Location = new System.Drawing.Point(252, 110);
this.user_namebox.Name = "user_namebox";
this.user_namebox.Size = new System.Drawing.Size(100, 28);
this.user_namebox.TabIndex = 5;
this.user_namebox.TextChanged += new System.EventHandler(this.user_namebox_TextChanged);
this.user_namebox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.user_namebox_KeyPress);
//
// password_box
//
this.password_box.Location = new System.Drawing.Point(252, 178);
this.password_box.Name = "password_box";
this.password_box.PasswordChar = '*';
this.password_box.Size = new System.Drawing.Size(100, 28);
this.password_box.TabIndex = 6;
this.password_box.TextChanged += new System.EventHandler(this.password_box_TextChanged);
this.password_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.password_box_KeyPress);
//
// confirm_label
//
this.confirm_label.AutoSize = true;
this.confirm_label.Location = new System.Drawing.Point(438, 188);
this.confirm_label.Name = "confirm_label";
this.confirm_label.Size = new System.Drawing.Size(80, 18);
this.confirm_label.TabIndex = 7;
this.confirm_label.Text = "确认密码";
//
// confirm_box
//
this.confirm_box.Location = new System.Drawing.Point(545, 178);
this.confirm_box.Name = "confirm_box";
this.confirm_box.PasswordChar = '*';
this.confirm_box.Size = new System.Drawing.Size(100, 28);
this.confirm_box.TabIndex = 8;
this.confirm_box.TextChanged += new System.EventHandler(this.confirm_box_TextChanged);
this.confirm_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.confirm_box_KeyPress);
//
// limit
//
this.limit.AutoSize = true;
this.limit.Location = new System.Drawing.Point(163, 259);
this.limit.Name = "limit";
this.limit.Size = new System.Drawing.Size(530, 18);
this.limit.TabIndex = 9;
this.limit.Text = "用户名和密码必须5-10位,可以使用大小写字母和数字,不得为空";
this.limit.Click += new System.EventHandler(this.limit_Click);
//
// return_login_button
//
this.return_login_button.Location = new System.Drawing.Point(145, 292);
this.return_login_button.Name = "return_login_button";
this.return_login_button.Size = new System.Drawing.Size(167, 73);
this.return_login_button.TabIndex = 10;
this.return_login_button.Text = "返回登录";
this.return_login_button.UseVisualStyleBackColor = true;
this.return_login_button.Click += new System.EventHandler(this.return_login_button_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.SystemColors.Info;
this.label1.ForeColor = System.Drawing.SystemColors.Highlight;
this.label1.Location = new System.Drawing.Point(163, 61);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 18);
this.label1.TabIndex = 11;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(670, 184);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(105, 22);
this.radioButton1.TabIndex = 12;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "显示密码";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(545, 154);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(170, 18);
this.label2.TabIndex = 13;
this.label2.Text = "权限不填默认为员工";
//
// regist
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(886, 492);
this.Controls.Add(this.label2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.label1);
this.Controls.Add(this.return_login_button);
this.Controls.Add(this.limit);
this.Controls.Add(this.confirm_box);
this.Controls.Add(this.confirm_label);
this.Controls.Add(this.password_box);
this.Controls.Add(this.user_namebox);
this.Controls.Add(this.right);
this.Controls.Add(this.right_box);
this.Controls.Add(this.password_label);
this.Controls.Add(this.user_name_label);
this.Controls.Add(this.regist_button);
this.Name = "regist";
this.Text = "Regist_Page";
this.Load += new System.EventHandler(this.regist_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button regist_button;
private System.Windows.Forms.Label user_name_label;
private System.Windows.Forms.Label password_label;
private System.Windows.Forms.ComboBox right_box;
private System.Windows.Forms.Label right;
private System.Windows.Forms.TextBox user_namebox;
private System.Windows.Forms.TextBox password_box;
private System.Windows.Forms.Label confirm_label;
private System.Windows.Forms.TextBox confirm_box;
private System.Windows.Forms.Label limit;
private System.Windows.Forms.Button return_login_button;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.Label label2;
}
}
form3
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class staff_right : Form
{
public staff_right()
{
InitializeComponent();
}
DataTable dt = new DataTable();
private void select_button_Click(object sender, EventArgs e)
{
//if (string.IsNullOrEmpty(comboBox1.Text) && string.IsNullOrEmpty(comboBox2.Text) && string.IsNullOrEmpty(comboBox3.Text))
//{
/* MessageBox.Show("三个不可都为空!");
return;*/
//}
//else
//{
if (string.IsNullOrEmpty(dateTimePicker1.Text))
{
MessageBox.Show("未选择日期!");
}
string sctime = dateTimePicker1.Text; //+ " %" + comboBox1.Text + ":%" + comboBox2.Text + ":%" + comboBox3.Text + ".000";
string name = textBox2.Text;
string id = textBox3.Text;
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection sel_con = new SqlConnection(constr);
if (string.IsNullOrEmpty(sctime))
{
sctime = "";
}
if (string.IsNullOrEmpty(name))
{
name = "";
}
if (!string.IsNullOrEmpty(id))
{
try
{
string sel = "select * from 扫描信息 where 扫描时间 like '" + sctime+"'and 商品名称 like '%"+name+"%' and 扫描人员编号="+id;
SqlDataAdapter ad = new SqlDataAdapter(sel, sel_con);
dt.Clear();
ad.Fill(dt);
dataGridView1.DataSource = dt;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
else
{
try
{
//string sel = "select * from 扫描信息 where Convert(varchar,扫描时间,30) like '%" + sctime+"%'and 商品名称 like '%"+name+"%'";
//string sel = "select * from 扫描信息 where 扫描时间 like '" + sctime + "'and 商品名称 like '%" + name + "%'";
string sel = "select * from 扫描信息 where datediff(d,扫描时间,convert(datetime,'"+sctime+"',121))=0 ";
SqlDataAdapter ad = new SqlDataAdapter(sel, constr);
dt.Clear();
ad.Fill(dt);
//dataGridView1.Columns["扫描时间"].DefaultCellStyle.Format = "yyyy-MM-dd hh:mm:ss";
dataGridView1.DataSource = dt;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
// }
}
}
private void exit_button_Click(object sender, EventArgs e)
{
this.Close();
}
private void staff_right_Load(object sender, EventArgs e)
{
string[] strhour = new string[] { "0","1", "2" , "3", "4", "5", "6" ,"7", "8", "9", "10", "11", "12" ,"13", "14" ,"15", "16", "17", "18" ,"19", "20" ,"21", "22" ,"23" };
string[] strmin = new string[] { "0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"};
string[] strsecond = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" };
comboBox1.Items.AddRange(strhour);
comboBox2.Items.AddRange(strmin);
comboBox3.Items.AddRange(strsecond);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
/*if (!(e.KeyChar > '0' && e.KeyChar < '9'))
{
MessageBox.Show("输入只能是时间");
}*/
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
/*if (!(e.KeyChar > '0' && e.KeyChar < '9'))
{
MessageBox.Show("输入只能是");
}*/
}
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
{
if (!((e.KeyChar >= '0' && e.KeyChar <= '9')||e.KeyChar=='\b'))
{
MessageBox.Show("输入只能是数字");
e.Handled = true;
}
}
}
}
designer
namespace WindowsFormsApp3
{
partial class staff_right
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.only = new System.Windows.Forms.Label();
this.select_button = new System.Windows.Forms.Button();
this.exit_button = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.label4 = new System.Windows.Forms.Label();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.comboBox3 = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// only
//
this.only.AutoSize = true;
this.only.Location = new System.Drawing.Point(52, 49);
this.only.Name = "only";
this.only.Size = new System.Drawing.Size(224, 18);
this.only.TabIndex = 0;
this.only.Text = "员工只有查询扫描信息权限";
//
// select_button
//
this.select_button.Location = new System.Drawing.Point(931, 109);
this.select_button.Name = "select_button";
this.select_button.Size = new System.Drawing.Size(153, 91);
this.select_button.TabIndex = 1;
this.select_button.Text = "查询";
this.select_button.UseVisualStyleBackColor = true;
this.select_button.Click += new System.EventHandler(this.select_button_Click);
//
// exit_button
//
this.exit_button.Location = new System.Drawing.Point(931, 274);
this.exit_button.Name = "exit_button";
this.exit_button.Size = new System.Drawing.Size(153, 94);
this.exit_button.TabIndex = 2;
this.exit_button.Text = "退出登录";
this.exit_button.UseVisualStyleBackColor = true;
this.exit_button.Click += new System.EventHandler(this.exit_button_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(826, 467);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(336, 28);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "本框为数据库实验验收后遗留,请勿填写";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(176, 159);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 28);
this.textBox2.TabIndex = 4;
this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(90, 109);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 18);
this.label1.TabIndex = 5;
this.label1.Text = "扫描时间";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(88, 162);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 18);
this.label2.TabIndex = 6;
this.label2.Text = "商品名称";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(52, 213);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(116, 18);
this.label3.TabIndex = 7;
this.label3.Text = "扫描人员编号";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(176, 210);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 28);
this.textBox3.TabIndex = 8;
this.textBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox3_KeyPress);
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToResizeColumns = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ButtonFace;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.GridColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView1.Location = new System.Drawing.Point(55, 255);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidth = 62;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle3;
this.dataGridView1.RowTemplate.Height = 30;
this.dataGridView1.Size = new System.Drawing.Size(722, 363);
this.dataGridView1.TabIndex = 9;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(604, 220);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 18);
this.label4.TabIndex = 10;
//
// dateTimePicker1
//
this.dateTimePicker1.CustomFormat = "yyyy-MM-dd";
this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.Location = new System.Drawing.Point(176, 106);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(200, 28);
this.dateTimePicker1.TabIndex = 13;
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(826, 522);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(67, 26);
this.comboBox1.TabIndex = 14;
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(913, 522);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(67, 26);
this.comboBox2.TabIndex = 15;
//
// comboBox3
//
this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(1004, 522);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(67, 26);
this.comboBox3.TabIndex = 16;
//
// staff_right
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1206, 702);
this.Controls.Add(this.comboBox3);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.label4);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.exit_button);
this.Controls.Add(this.select_button);
this.Controls.Add(this.only);
this.Name = "staff_right";
this.Text = "Staff_Page";
this.Load += new System.EventHandler(this.staff_right_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label only;
private System.Windows.Forms.Button select_button;
private System.Windows.Forms.Button exit_button;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.ComboBox comboBox3;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Manager_Page : Form
{
public Manager_Page()
{
InitializeComponent();
}
private void select_button_Click(object sender, EventArgs e)
{
Form5 sel_del_page = new Form5();
sel_del_page.ShowDialog();
}
private void add_button_Click(object sender, EventArgs e)
{
Form6 insert_page = new Form6();
insert_page.ShowDialog();
}
private void delete_button_Click(object sender, EventArgs e)
{
}
private void modify_button_Click(object sender, EventArgs e)
{
Form7 up_page = new Form7();
up_page.ShowDialog();
}
private void exit_button_Click(object sender, EventArgs e)
{
this.Close();
}
private void Manager_Page_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form8 chaxun = new Form8();
chaxun.ShowDialog();
}
}
}
designer
namespace WindowsFormsApp3
{
partial class Manager_Page
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.select_button = new System.Windows.Forms.Button();
this.add_button = new System.Windows.Forms.Button();
this.modify_button = new System.Windows.Forms.Button();
this.exit_button = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// select_button
//
this.select_button.Location = new System.Drawing.Point(225, 138);
this.select_button.Name = "select_button";
this.select_button.Size = new System.Drawing.Size(207, 97);
this.select_button.TabIndex = 0;
this.select_button.Text = "查询/删除信息";
this.select_button.UseVisualStyleBackColor = true;
this.select_button.Click += new System.EventHandler(this.select_button_Click);
//
// add_button
//
this.add_button.Location = new System.Drawing.Point(225, 349);
this.add_button.Name = "add_button";
this.add_button.Size = new System.Drawing.Size(207, 97);
this.add_button.TabIndex = 1;
this.add_button.Text = "增加信息";
this.add_button.UseVisualStyleBackColor = true;
this.add_button.Click += new System.EventHandler(this.add_button_Click);
//
// modify_button
//
this.modify_button.Location = new System.Drawing.Point(629, 138);
this.modify_button.Name = "modify_button";
this.modify_button.Size = new System.Drawing.Size(207, 97);
this.modify_button.TabIndex = 3;
this.modify_button.Text = "修改信息";
this.modify_button.UseVisualStyleBackColor = true;
this.modify_button.Click += new System.EventHandler(this.modify_button_Click);
//
// exit_button
//
this.exit_button.Location = new System.Drawing.Point(629, 349);
this.exit_button.Name = "exit_button";
this.exit_button.Size = new System.Drawing.Size(207, 97);
this.exit_button.TabIndex = 4;
this.exit_button.Text = "退出登录";
this.exit_button.UseVisualStyleBackColor = true;
this.exit_button.Click += new System.EventHandler(this.exit_button_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(371, 58);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(314, 18);
this.label1.TabIndex = 5;
this.label1.Text = "经理可以增删查改数据库中的任何内容";
//
// button1
//
this.button1.Location = new System.Drawing.Point(897, 277);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(143, 121);
this.button1.TabIndex = 6;
this.button1.Text = "本按钮为现场提问的功能,仅供验收时使用";
this.button1.UseVisualStyleBackColor = true;
this.button1.Visible = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Manager_Page
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1072, 635);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.exit_button);
this.Controls.Add(this.modify_button);
this.Controls.Add(this.add_button);
this.Controls.Add(this.select_button);
this.Name = "Manager_Page";
this.Text = "Manager_Page";
this.Load += new System.EventHandler(this.Manager_Page_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button select_button;
private System.Windows.Forms.Button add_button;
private System.Windows.Forms.Button modify_button;
private System.Windows.Forms.Button exit_button;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
}
}
form5
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class Form5 : Form
{
// public string upkey;
public Form5()
{
InitializeComponent();
}
private void label9_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void Form5_Load(object sender, EventArgs e)
{
string[] str = new string[] { "查询扫描信息", "查询商品信息","查询职工信息","查询注册信息" };
comboBox1.Items.AddRange(str);
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(comboBox1.Text))
{
MessageBox.Show("未选择所查询表");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection sel_con = new SqlConnection(constr);
DataTable dt = new DataTable();
try
{
if (comboBox1.Text == "查询注册信息")
{
string user_name = username_box.Text;
string right = right_box.Text;
if (string.IsNullOrEmpty(user_name) && string.IsNullOrEmpty(right)){
MessageBox.Show("查询信息不可全为空");
return;
}//最好在此处将两项中空的一项转换为""
string sel_reg = "select ID,JOB from 账户 where ID like '%" + user_name + "%' and JOB like '%" + right + "%'";
SqlDataAdapter sqlda = new SqlDataAdapter(sel_reg, sel_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
return;
}
if (comboBox1.Text == "查询商品信息")
{
string goods_id = id_box3.Text;
string goods_name = name_box2.Text;
string store = singlemoney_box.Text;//这里做了修改,把单价框变成库存了,
if (string.IsNullOrEmpty(goods_id) && string.IsNullOrEmpty(goods_name) && string.IsNullOrEmpty(store))
{
MessageBox.Show("查询信息不可全为空");
return;
}
if (!string.IsNullOrEmpty(goods_name)&&string.IsNullOrEmpty(store)&&string.IsNullOrEmpty(goods_id))
{
string sel_goods = "select * from 商品信息 where 商品名称 like '%" + goods_name + "%' and 是否打折='" + radioButton2.Checked + "'";
SqlDataAdapter sqlda = new SqlDataAdapter(sel_goods, sel_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
return;
}
if (string.IsNullOrEmpty(goods_name) && !string.IsNullOrEmpty(store) && string.IsNullOrEmpty(goods_id))
{
string sel_goods = "select * from 商品信息 where 库存 <='" + store + "' and 是否打折='" + radioButton2.Checked + "'";
SqlDataAdapter sqlda = new SqlDataAdapter(sel_goods, sel_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
return;
}
if (string.IsNullOrEmpty(goods_name) && string.IsNullOrEmpty(store) && !string.IsNullOrEmpty(goods_id))
{
string sel_goods = "select * from 商品信息 where 商品编号= '" + goods_id + "' and 是否打折='" + radioButton2.Checked + "'";
SqlDataAdapter sqlda = new SqlDataAdapter(sel_goods, sel_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
return;
}
MessageBox.Show("只能填一项");
}
if (comboBox1.Text == "查询职工信息")
{
string staff_id= id_box4.Text;
string staff_name = name_box3.Text;
string sex = sex_box.Text;
string staff_job = job_box.Text;
string sel_staff = "";
if (string.IsNullOrEmpty(staff_id) && string.IsNullOrEmpty(staff_name)&&string.IsNullOrEmpty(sex)&&string.IsNullOrEmpty(staff_job))
{
MessageBox.Show("查询信息不可全为空");
return;
}
if (string.IsNullOrEmpty(staff_id))
{
sel_staff = "select * from 职员信息 where 姓名 like '%" + staff_name + "%' and 性别 like '%" + sex + "%' and 职位 like '%" + staff_job + "%'"+"and 在职 = 'True'";
}
else
{
sel_staff = "select * from 职员信息 where 编号 like '%" + staff_id + "%' and 姓名 like '%" + staff_name + "%' and 性别 like '%" + sex + "%' and 职位 like '%" + staff_job + "%'" + "and 在职 = 'True'";
}
SqlDataAdapter sqlda = new SqlDataAdapter(sel_staff, sel_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
return;
}
if (comboBox1.Text == "查询扫描信息")
{
string scantime1 = scantime_box1.Text;
string scantime2 = scantime_box2.Text;
string goods_name = name_box1.Text;
string sc_id = id_box2.Text;
string total_money = total_box.Text;
string sel_scan = "";
if (string.IsNullOrEmpty(scantime1) && string.IsNullOrEmpty(scantime2)&&string.IsNullOrEmpty(goods_name)&&string.IsNullOrEmpty(total_money))
{
MessageBox.Show("查询信息不可全为空");
return;
}//最好在此处将两项中空的一项转换为""
if (radioButton1.Checked == true)
{
if (string.IsNullOrEmpty(total_money))
{
if (string.IsNullOrEmpty(sc_id))
{
sel_scan = "select * from 扫描信息 where 扫描时间 >= '" + scantime1 + "' and 扫描时间 <= '" + scantime2 + "' and 商品名称 like '%" + goods_name + "%'";
}
else
{
sel_scan = "select * from 扫描信息 where 扫描时间 >= '" + scantime1 + "' and 扫描时间 <= '" + scantime2 + "' and 商品名称 like '%" + goods_name + "%' and 扫描人员编号 = '" + sc_id + "'";
}
}
else
{
if (string.IsNullOrEmpty(sc_id))
{
sel_scan = "select * from 扫描信息 where 扫描时间 >= '" + scantime1 + "' and 扫描时间 <= '" + scantime2 + "' and 商品名称 like '%" + goods_name + "%'and 总价 >= '" + total_money + "'";
}
else
{
sel_scan = "select * from 扫描信息 where 扫描时间 >= '" + scantime1 + "' and 扫描时间 <= '" + scantime2 + "' and 商品名称 like '%" + goods_name + "%'and 总价 >= '" + total_money + "'and 扫描人员编号 ='"+sc_id+"'";
}
}
}
else
{
if (string.IsNullOrEmpty(total_money))
{
if (string.IsNullOrEmpty(sc_id))
{
sel_scan = "select * from 扫描信息 where 扫描时间 like '%" + scantime1 + "%' and 商品名称 like '%" + goods_name + "%'";
}
else
{
sel_scan = "select * from 扫描信息 where 扫描时间 like '%" + scantime1 + "%' and 商品名称 like '%" + goods_name + "%' and 扫描人员编号 = '"+sc_id+"'";
}
}
else
{
if (string.IsNullOrEmpty(sc_id))
{
sel_scan = "select * from 扫描信息 where 扫描时间 like '%" + scantime1 + "%' and 商品名称 like '%" + goods_name + "%'and 总价 >= '" + total_money + "'";
}
else
{
sel_scan = "select * from 扫描信息 where 扫描时间 like '%" + scantime1 + "%' and 商品名称 like '%" + goods_name + "%'and 总价 >= '" + total_money + "'and 扫描人员编号 = '"+sc_id+"'";
}
}
}
SqlDataAdapter sqlda = new SqlDataAdapter(sel_scan, sel_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
if (comboBox1.Text == "查询扫描信息")
{
dataGridView1.Columns["扫描时间"].DefaultCellStyle.Format = "yyyy-MM-dd hh:mm:ss";
}
return;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
}
bool ra2_check = false;
private void radioButton2_Click(object sender, EventArgs e)
{
if (ra2_check)
{
radioButton2.Checked = false;
ra2_check= false;
}
else
{
radioButton2.Checked = true;
ra2_check = true;
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void contextMenuStrip1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
string del_index;
string sql_del="" ;
if (dataGridView1.CurrentRow!=null)
{
// MessageBox.Show("进入删除");
del_index = dataGridView1.CurrentRow.Cells[0].Value.ToString();
if (comboBox1.Text == "查询扫描信息")
{
// dataGridView1.CurrentRow
sql_del = "delete from 扫描信息 where 扫描时间 = '" + del_index + "'";
}
if (comboBox1.Text == "查询职工信息")
{
sql_del = "update 职员信息 set 在职 = 'False' where 编号='" + del_index + "'";
}
if (comboBox1.Text == "查询注册信息")
{
sql_del = "delete from 账户 where ID='" + del_index + "'";
}
if (comboBox1.Text == "查询商品信息")
{
sql_del = "delete from 商品信息 where 商品编号='" + del_index + "'";
}
}
else
{
MessageBox.Show("没有进入删除");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection del_con = new SqlConnection(constr);
del_con.Open();
/*DataTable dt = new DataTable();
SqlDataAdapter sqlda = new SqlDataAdapter(, del_con);
dt.Clear();
sqlda.Fill(dt);
dataGridView1.DataSource = dt;
return;*/
SqlCommand sqlcom = new SqlCommand(sql_del, del_con);
int k=sqlcom.ExecuteNonQuery();
if (k > 0)
{
MessageBox.Show("成功删除了"+k.ToString()+"行");
}
else
{
MessageBox.Show("此行已被删除,请重新查询刷新");
}
del_con.Close();
}
bool ra1_check = false;
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton1_Click(object sender, EventArgs e)
{
if (ra1_check)
{
radioButton1.Checked = false;
ra1_check = false;
scantime_box2.Text = "";
scantime_box2.ReadOnly = true;
}
else
{
radioButton1.Checked = true;
ra1_check = true;
scantime_box2.ReadOnly = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
{
string sql_del = "";
if (dataGridView1.CurrentRow != null)
{
// MessageBox.Show("进入删除");
string upkey = dataGridView1.CurrentRow.Cells[0].Value.ToString();
string tranid = dataGridView1.CurrentRow.Cells[1].Value.ToString();
string tranname = dataGridView1.CurrentRow.Cells[2].Value.ToString();
string transin = dataGridView1.CurrentRow.Cells[3].Value.ToString();
string tranmass = dataGridView1.CurrentRow.Cells[4].Value.ToString();
string tranto = dataGridView1.CurrentRow.Cells[5].Value.ToString();
string transta = dataGridView1.CurrentRow.Cells[6].Value.ToString();
/*if (comboBox1.Text == "查询扫描信息")
{
// dataGridView1.CurrentRow
//sql_del = "delete from 扫描信息 where 扫描时间 = '" + del_index + "'";
}
if (comboBox1.Text == "查询职工信息")
{
//sql_del = "update 职员信息 set 在职 = 'False' where 编号='" + del_index + "'";
}
if (comboBox1.Text == "查询注册信息")
{
//sql_del = "delete from 账户 where ID='" + del_index + "'";
}
if (comboBox1.Text == "查询商品信息")
{
//sql_del = "delete from 商品信息 where 商品编号='" + del_index + "'";
}
*/
Form7 up_page_ = new Form7(upkey,tranid,tranname,transin,tranmass,tranto,transta);
up_page_.ShowDialog();
}
else
{
MessageBox.Show("没有进入修改");
return;
}
}
}
}
designer
namespace WindowsFormsApp3
{
partial class Form5
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.scantime_box1 = new System.Windows.Forms.TextBox();
this.scantime_box2 = new System.Windows.Forms.TextBox();
this.name_box1 = new System.Windows.Forms.TextBox();
this.id_box3 = new System.Windows.Forms.TextBox();
this.name_box2 = new System.Windows.Forms.TextBox();
this.singlemoney_box = new System.Windows.Forms.TextBox();
this.id_box4 = new System.Windows.Forms.TextBox();
this.name_box3 = new System.Windows.Forms.TextBox();
this.sex_box = new System.Windows.Forms.TextBox();
this.job_box = new System.Windows.Forms.TextBox();
this.username_box = new System.Windows.Forms.TextBox();
this.right_box = new System.Windows.Forms.TextBox();
this.id_box2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.删除ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.修改ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label18 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.label6 = new System.Windows.Forms.Label();
this.total_box = new System.Windows.Forms.TextBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(53, 94);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(107, 18);
this.label1.TabIndex = 0;
this.label1.Text = "扫描时间 起";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(80, 182);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 18);
this.label2.TabIndex = 1;
this.label2.Text = "商品名称";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(44, 223);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(116, 18);
this.label4.TabIndex = 3;
this.label4.Text = "扫描人员编号";
this.label4.Click += new System.EventHandler(this.label4_Click);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(354, 182);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(71, 18);
this.label5.TabIndex = 4;
this.label5.Text = "库存(<)";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(613, 94);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(80, 18);
this.label7.TabIndex = 6;
this.label7.Text = "人员编号";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(649, 139);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(44, 18);
this.label8.TabIndex = 7;
this.label8.Text = "姓名";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(649, 223);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(44, 18);
this.label9.TabIndex = 8;
this.label9.Text = "职位";
this.label9.Click += new System.EventHandler(this.label9_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(345, 97);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(80, 18);
this.label10.TabIndex = 9;
this.label10.Text = "商品编号";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(649, 182);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(44, 18);
this.label11.TabIndex = 10;
this.label11.Text = "性别";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(345, 142);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(80, 18);
this.label12.TabIndex = 11;
this.label12.Text = "商品名称";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(869, 94);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(62, 18);
this.label17.TabIndex = 16;
this.label17.Text = "用户名";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(887, 142);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(44, 18);
this.label19.TabIndex = 18;
this.label19.Text = "权限";
//
// scantime_box1
//
this.scantime_box1.Location = new System.Drawing.Point(176, 94);
this.scantime_box1.Name = "scantime_box1";
this.scantime_box1.Size = new System.Drawing.Size(100, 28);
this.scantime_box1.TabIndex = 19;
//
// scantime_box2
//
this.scantime_box2.Location = new System.Drawing.Point(176, 139);
this.scantime_box2.Name = "scantime_box2";
this.scantime_box2.ReadOnly = true;
this.scantime_box2.Size = new System.Drawing.Size(100, 28);
this.scantime_box2.TabIndex = 20;
//
// name_box1
//
this.name_box1.Location = new System.Drawing.Point(176, 176);
this.name_box1.Name = "name_box1";
this.name_box1.Size = new System.Drawing.Size(100, 28);
this.name_box1.TabIndex = 21;
//
// id_box3
//
this.id_box3.Location = new System.Drawing.Point(450, 94);
this.id_box3.Name = "id_box3";
this.id_box3.Size = new System.Drawing.Size(100, 28);
this.id_box3.TabIndex = 23;
//
// name_box2
//
this.name_box2.Location = new System.Drawing.Point(450, 136);
this.name_box2.Name = "name_box2";
this.name_box2.Size = new System.Drawing.Size(100, 28);
this.name_box2.TabIndex = 24;
//
// singlemoney_box
//
this.singlemoney_box.Location = new System.Drawing.Point(450, 176);
this.singlemoney_box.Name = "singlemoney_box";
this.singlemoney_box.Size = new System.Drawing.Size(100, 28);
this.singlemoney_box.TabIndex = 25;
//
// id_box4
//
this.id_box4.Location = new System.Drawing.Point(711, 91);
this.id_box4.Name = "id_box4";
this.id_box4.Size = new System.Drawing.Size(100, 28);
this.id_box4.TabIndex = 26;
//
// name_box3
//
this.name_box3.Location = new System.Drawing.Point(711, 136);
this.name_box3.Name = "name_box3";
this.name_box3.Size = new System.Drawing.Size(100, 28);
this.name_box3.TabIndex = 27;
//
// sex_box
//
this.sex_box.Location = new System.Drawing.Point(711, 179);
this.sex_box.Name = "sex_box";
this.sex_box.Size = new System.Drawing.Size(100, 28);
this.sex_box.TabIndex = 28;
//
// job_box
//
this.job_box.Location = new System.Drawing.Point(711, 220);
this.job_box.Name = "job_box";
this.job_box.Size = new System.Drawing.Size(100, 28);
this.job_box.TabIndex = 29;
//
// username_box
//
this.username_box.Location = new System.Drawing.Point(952, 91);
this.username_box.Name = "username_box";
this.username_box.Size = new System.Drawing.Size(100, 28);
this.username_box.TabIndex = 30;
//
// right_box
//
this.right_box.Location = new System.Drawing.Point(952, 139);
this.right_box.Name = "right_box";
this.right_box.Size = new System.Drawing.Size(100, 28);
this.right_box.TabIndex = 31;
//
// id_box2
//
this.id_box2.Location = new System.Drawing.Point(176, 223);
this.id_box2.Name = "id_box2";
this.id_box2.Size = new System.Drawing.Size(100, 28);
this.id_box2.TabIndex = 32;
//
// button1
//
this.button1.Location = new System.Drawing.Point(399, 280);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(170, 84);
this.button1.TabIndex = 33;
this.button1.Text = "查询";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToResizeColumns = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.DisplayedCells;
this.dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ButtonFace;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.ContextMenuStrip = this.contextMenuStrip1;
this.dataGridView1.GridColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView1.Location = new System.Drawing.Point(47, 381);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidth = 62;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView1.RowTemplate.Height = 30;
this.dataGridView1.Size = new System.Drawing.Size(764, 326);
this.dataGridView1.TabIndex = 34;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.删除ToolStripMenuItem,
this.修改ToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(117, 64);
this.contextMenuStrip1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.contextMenuStrip1_PreviewKeyDown);
//
// 删除ToolStripMenuItem
//
this.删除ToolStripMenuItem.Name = "删除ToolStripMenuItem";
this.删除ToolStripMenuItem.Size = new System.Drawing.Size(116, 30);
this.删除ToolStripMenuItem.Text = "删除";
this.删除ToolStripMenuItem.Click += new System.EventHandler(this.删除ToolStripMenuItem_Click);
//
// 修改ToolStripMenuItem
//
this.修改ToolStripMenuItem.Name = "修改ToolStripMenuItem";
this.修改ToolStripMenuItem.Size = new System.Drawing.Size(116, 30);
this.修改ToolStripMenuItem.Text = "修改";
this.修改ToolStripMenuItem.Click += new System.EventHandler(this.修改ToolStripMenuItem_Click);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(134, 139);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(26, 18);
this.label18.TabIndex = 36;
this.label18.Text = "至";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(56, 24);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(178, 26);
this.comboBox1.TabIndex = 37;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(348, 24);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(195, 22);
this.radioButton1.TabIndex = 38;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "扫描时间使用时间段";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(89, 269);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(71, 18);
this.label6.TabIndex = 39;
this.label6.Text = "总价(>)";
//
// total_box
//
this.total_box.Location = new System.Drawing.Point(176, 266);
this.total_box.Name = "total_box";
this.total_box.Size = new System.Drawing.Size(100, 28);
this.total_box.TabIndex = 40;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(450, 223);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(69, 22);
this.radioButton2.TabIndex = 41;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "打折";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
this.radioButton2.Click += new System.EventHandler(this.radioButton2_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(901, 280);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(151, 84);
this.button2.TabIndex = 43;
this.button2.Text = "退出本窗口";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form5
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1370, 762);
this.Controls.Add(this.button2);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.total_box);
this.Controls.Add(this.label6);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label18);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.button1);
this.Controls.Add(this.id_box2);
this.Controls.Add(this.right_box);
this.Controls.Add(this.username_box);
this.Controls.Add(this.job_box);
this.Controls.Add(this.sex_box);
this.Controls.Add(this.name_box3);
this.Controls.Add(this.id_box4);
this.Controls.Add(this.singlemoney_box);
this.Controls.Add(this.name_box2);
this.Controls.Add(this.id_box3);
this.Controls.Add(this.name_box1);
this.Controls.Add(this.scantime_box2);
this.Controls.Add(this.scantime_box1);
this.Controls.Add(this.label19);
this.Controls.Add(this.label17);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form5";
this.Text = "Form5";
this.Load += new System.EventHandler(this.Form5_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.TextBox scantime_box1;
private System.Windows.Forms.TextBox scantime_box2;
private System.Windows.Forms.TextBox name_box1;
private System.Windows.Forms.TextBox id_box3;
private System.Windows.Forms.TextBox name_box2;
private System.Windows.Forms.TextBox singlemoney_box;
private System.Windows.Forms.TextBox id_box4;
private System.Windows.Forms.TextBox name_box3;
private System.Windows.Forms.TextBox sex_box;
private System.Windows.Forms.TextBox job_box;
private System.Windows.Forms.TextBox username_box;
private System.Windows.Forms.TextBox right_box;
private System.Windows.Forms.TextBox id_box2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox total_box;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem 删除ToolStripMenuItem;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ToolStripMenuItem 修改ToolStripMenuItem;
}
}
form6
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label6_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(comboBox1.Text))
{
MessageBox.Show("选择添加的表");
return;
}
if (comboBox1.Text == "添加扫描信息")
{
string addyear = year_box.Text;
string addmonth = month_box.Text;
string addday = day_box.Text;
string addhour = hour_box.Text;
string addmin = min_box.Text;
string addsecond = second_box.Text;
string addexsecond = exsecond_box.Text;
string addscid = scid_box.Text;
string addname = scname_box.Text;
string addsin = scsin_box.Text;
string addtotal = total_box.Text;
string addscstaffid = scanid_box.Text;
string addmass = mass_box.Text;
if (string.IsNullOrEmpty(addyear) || string.IsNullOrEmpty(addscid) || string.IsNullOrEmpty(addname) || string.IsNullOrEmpty(addsin) || string.IsNullOrEmpty(addtotal) || string.IsNullOrEmpty(addscstaffid) || string.IsNullOrEmpty(addmonth) || string.IsNullOrEmpty(addday) || string.IsNullOrEmpty(addhour) || string.IsNullOrEmpty(addmin) || string.IsNullOrEmpty(addsecond) || string.IsNullOrEmpty(addexsecond))
{
MessageBox.Show("不可有空缺!");
return;
}
float temp;
bool flag = float.TryParse(addsin, out temp);
if (!flag)
{
MessageBox.Show("输入的单价不是钱数");
return;
}
flag = float.TryParse(addmass, out temp);
if (!flag)
{
MessageBox.Show("输入的质量不是合法数字");
return;
}
flag = float.TryParse(addtotal, out temp);
if (!flag)
{
MessageBox.Show("输入的总价不是合法数字");
return;
}
int tempt, year_;
flag = int.TryParse(addyear, out year_);
if (!flag)
{
MessageBox.Show("输入的年不是合法数字");
return;
}
if (year_ > 2025 || year_ < 2000)
{
MessageBox.Show("检查年份!");
return;
}
int month_;
flag = int.TryParse(addmonth, out month_);
if (!flag)
{
MessageBox.Show("输入的月不是合法数字");
return;
}
if (month_ < 1 || month_ > 12)
{
MessageBox.Show("检查月份!");
return;
}
int day_;
flag = int.TryParse(addday, out day_);
if (!flag)
{
MessageBox.Show("输入的日不是合法数字");
return;
}
if (day_ > 31 || day_ < 1)
{
MessageBox.Show("检查输入的日期!");
return;
}
if (month_ == 2 || month_ == 4 || month_ == 6 || month_ == 9 || month_ == 11)
{
if (day_ == 31)
{
MessageBox.Show("这个月真的有31天吗?");
return;
}
}
if (month_ == 2)
{
if (year_ == 2000 || year_ == 2004 || year_ == 2008 || year_ == 2012 || year_ == 2016 || year_ == 2020 || year_ == 2024)
{
if (day_ > 29)
{
MessageBox.Show("检查输入的日期!");
return;
}
}
else
{
if (day_ > 28)
{
MessageBox.Show("检查输入的日期!");
return;
}
}
}
flag = int.TryParse(addhour, out tempt);
if (!flag)
{
MessageBox.Show("输入的小时不是合法数字");
return;
}
if (tempt > 59 || tempt < 0)
{
MessageBox.Show("检查输入的小时");
return;
}
flag = int.TryParse(addmin, out tempt);
if (!flag)
{
MessageBox.Show("输入的分不是合法数字");
return;
}
if (tempt > 59 || tempt < 0)
{
MessageBox.Show("检查输入的分");
return;
}
flag = int.TryParse(addsecond, out tempt);
if (!flag)
{
MessageBox.Show("输入的秒不是合法数字");
return;
}
if (tempt > 59 || tempt < 0)
{
MessageBox.Show("检查输入的秒");
return;
}
flag = int.TryParse(addexsecond, out tempt);
if (!flag)
{
MessageBox.Show("输入的秒后小数点不是合法数字");
return;
}
if (tempt > 999 || tempt < 0)
{
MessageBox.Show("输入的小数点后数字不正确");
return;
}
string sctimestr = addyear + "-" + addmonth + "-" + addday + " " + addhour + ":" + addmin + ":" + addsecond + "." + addexsecond;
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection insert_con = new SqlConnection(constr);
insert_con.Open();
string sel_str = "select * from 扫描信息 where 扫描时间 ='" + sctimestr + "'";
string insert_str = "insert into 扫描信息 VALUES ('" + sctimestr + "','" + addscid + "','" + addname + "','" + addsin + "','" + addmass + "','" + addtotal + "','" + addscstaffid + "')";
SqlCommand sel_com = new SqlCommand(sel_str, insert_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
MessageBox.Show("该时间已存在扫描信息!");
insert_con.Close();
return;
}
insert_con.Close();
insert_con.Open();
string sel_goods_str = "select * from 商品信息 where 商品编号 ='" + addscid + "' and 商品名称= '"+addname+"'";
SqlCommand sel_goods_com = new SqlCommand(sel_goods_str, insert_con);
SqlDataReader dr_goods_sel = sel_goods_com.ExecuteReader();
if (!dr_goods_sel.HasRows)
{
MessageBox.Show("无此商品!");
insert_con.Close();
return;
}
insert_con.Close();
insert_con.Open();
SqlCommand insert_com = new SqlCommand(insert_str, insert_con);
int num = insert_com.ExecuteNonQuery();
insert_con.Close();
MessageBox.Show(num + "条信息已插入");
}
if (comboBox1.Text == "添加商品信息")
{
string addid = goods_id.Text;
string addname = goods_name.Text;
string addsin = goods_sin.Text;
string addstore = goods_store.Text;
string adddiscount = ifdiscount.Checked.ToString();
if (string.IsNullOrEmpty(addid) || string.IsNullOrEmpty(addsin) || string.IsNullOrEmpty(addname) || string.IsNullOrEmpty(addstore))
{
MessageBox.Show("未填写全信息!");
return;
}
float temp;
bool flag1 = float.TryParse(addsin, out temp);
bool flag2 = float.TryParse(addstore, out temp);
if (!flag1 || !flag2)
{
MessageBox.Show("输入的单价和库存不是合法数字");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection insert_con = new SqlConnection(constr);
insert_con.Open();
string sel_str = "select * from 商品信息 where 商品编号 ='" + addid + "'";
string insert_str = "insert into 商品信息 VALUES ('" + addid + "','" + addname + "','" + addsin + "','" + addstore + "','" + adddiscount + "')";
SqlCommand sel_com = new SqlCommand(sel_str, insert_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
MessageBox.Show("该编号商品已存在!");
insert_con.Close();
return;
}
insert_con.Close();
insert_con.Open();
SqlCommand insert_com = new SqlCommand(insert_str, insert_con);
int num = insert_com.ExecuteNonQuery();
insert_con.Close();
MessageBox.Show(num + "条信息已插入");
}
if (comboBox1.Text == "添加职工信息")
{
string addid = staid.Text;
string addname = staname.Text;
string addsex = stasex.Text;
string addjob = stajob.Text;
string addsal = stasal.Text;
if (string.IsNullOrEmpty(addid) || string.IsNullOrEmpty(addname) || string.IsNullOrEmpty(addsex) || string.IsNullOrEmpty(addsal) || string.IsNullOrEmpty(addjob))
{
MessageBox.Show("不得有空!");
return;
}
if (addsex != "男" && addsex != "女")
{
MessageBox.Show("本店只招聘正常人类");
return;
}
float temp;
bool flag = float.TryParse(addsal, out temp);
if (!flag)
{
MessageBox.Show("输入的工资不是合法数字");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection insert_con = new SqlConnection(constr);
insert_con.Open();
string sel_str = "select * from 职员信息 where 编号 ='" + addid + "'";
string insert_str = "insert into 职员信息 VALUES ('" + addid + "','" + addname + "','" + addsex + "','" + addjob + "','" + addsal + "','True')";
SqlCommand sel_com = new SqlCommand(sel_str, insert_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
MessageBox.Show("该编号人员已存在/存在过!");
insert_con.Close();
return;
}
insert_con.Close();
insert_con.Open();
SqlCommand insert_com = new SqlCommand(insert_str, insert_con);
int num = insert_com.ExecuteNonQuery();
insert_con.Close();
MessageBox.Show(num + "条信息已插入");
}
if (comboBox1.Text == "添加注册信息")
{
string adduser = user_box.Text;
string addpass = pass_box.Text;
string addright = right_box.Text;
if (string.IsNullOrEmpty(adduser) || string.IsNullOrEmpty(addpass) || string.IsNullOrEmpty(addright))
{
MessageBox.Show("输入不得有空");
return;
}
if (addright != "经理" && addright != "员工")
{
MessageBox.Show("权限只有经理或员工");
return;
}
if (adduser.Length < 5 || adduser.Length > 20 || addpass.Length < 5 || addpass.Length > 20)
{
MessageBox.Show("账户和密码应当在5到20位之间");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection insert_con = new SqlConnection(constr);
insert_con.Open();
string sel_str = "select * from 账户 where ID ='" + adduser + "'";
string insert_str = "insert into 账户 VALUES ('" + adduser + "','" + addpass + "','" + addright + "')";
SqlCommand sel_com = new SqlCommand(sel_str, insert_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
MessageBox.Show("用户名存在重复!");
insert_con.Close();
return;
}
insert_con.Close();
insert_con.Open();
SqlCommand insert_com = new SqlCommand(insert_str, insert_con);
int num = insert_com.ExecuteNonQuery();
insert_con.Close();
MessageBox.Show(num + "条信息已插入");
}
}
private void Form6_Load(object sender, EventArgs e)
{
string[] str = new string[] { "添加扫描信息", "添加商品信息", "添加职工信息", "添加注册信息" };
comboBox1.Items.AddRange(str);
}
private void scid_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
scid_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void scanid_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
scanid_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void year_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
year_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void month_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
month_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void day_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
day_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void hour_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
hour_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void min_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
min_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void second_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
second_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void exsecond_box_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
exsecond_box.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void goods_id_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
goods_id.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
}
}
private void staid_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\b')
{
staid.Text = "";
MessageBox.Show("输入只能为数字");
e.Handled = true;
return;
}
}
private void stasex_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void user_box_KeyPress(object sender, KeyPressEventArgs e)
{
}
bool discount_check = false;
private void ifdiscount_CheckedChanged(object sender, EventArgs e)
{
/*if (discount_check)
{
ifdiscount.Checked = false;
discount_check = false;
}
else
{
ifdiscount.Checked = true;
discount_check = true;
}*/
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void exsecond_box_TextChanged(object sender, EventArgs e)
{
}
private void ifdiscount_Click(object sender, EventArgs e)
{
if (discount_check)
{
ifdiscount.Checked = false;
discount_check = false;
}
else
{
ifdiscount.Checked = true;
discount_check = true;
}
}
}
}
designer
namespace WindowsFormsApp3
{
partial class Form6
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.商品编号 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.year_box = new System.Windows.Forms.TextBox();
this.scid_box = new System.Windows.Forms.TextBox();
this.scname_box = new System.Windows.Forms.TextBox();
this.scsin_box = new System.Windows.Forms.TextBox();
this.mass_box = new System.Windows.Forms.TextBox();
this.total_box = new System.Windows.Forms.TextBox();
this.scanid_box = new System.Windows.Forms.TextBox();
this.goods_id = new System.Windows.Forms.TextBox();
this.goods_name = new System.Windows.Forms.TextBox();
this.goods_sin = new System.Windows.Forms.TextBox();
this.goods_store = new System.Windows.Forms.TextBox();
this.user_box = new System.Windows.Forms.TextBox();
this.pass_box = new System.Windows.Forms.TextBox();
this.right_box = new System.Windows.Forms.TextBox();
this.staname = new System.Windows.Forms.TextBox();
this.stasex = new System.Windows.Forms.TextBox();
this.staid = new System.Windows.Forms.TextBox();
this.stajob = new System.Windows.Forms.TextBox();
this.stasal = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.ifdiscount = new System.Windows.Forms.RadioButton();
this.button2 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.label23 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.month_box = new System.Windows.Forms.TextBox();
this.day_box = new System.Windows.Forms.TextBox();
this.hour_box = new System.Windows.Forms.TextBox();
this.second_box = new System.Windows.Forms.TextBox();
this.min_box = new System.Windows.Forms.TextBox();
this.exsecond_box = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 315);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(116, 18);
this.label1.TabIndex = 0;
this.label1.Text = "扫描时间(年)";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// 商品编号
//
this.商品编号.AutoSize = true;
this.商品编号.Location = new System.Drawing.Point(45, 40);
this.商品编号.Name = "商品编号";
this.商品编号.Size = new System.Drawing.Size(80, 18);
this.商品编号.TabIndex = 1;
this.商品编号.Text = "商品编号";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(45, 85);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 18);
this.label3.TabIndex = 2;
this.label3.Text = "商品名称";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(45, 130);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 18);
this.label4.TabIndex = 3;
this.label4.Text = "商品单价";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(81, 176);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(44, 18);
this.label5.TabIndex = 4;
this.label5.Text = "质量";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 272);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(116, 18);
this.label6.TabIndex = 5;
this.label6.Text = "扫描人员编号";
this.label6.Click += new System.EventHandler(this.label6_Click);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(81, 223);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(44, 18);
this.label7.TabIndex = 6;
this.label7.Text = "总价";
//
// year_box
//
this.year_box.Location = new System.Drawing.Point(141, 312);
this.year_box.Name = "year_box";
this.year_box.Size = new System.Drawing.Size(100, 28);
this.year_box.TabIndex = 7;
this.year_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.year_box_KeyPress);
//
// scid_box
//
this.scid_box.Location = new System.Drawing.Point(141, 37);
this.scid_box.Name = "scid_box";
this.scid_box.Size = new System.Drawing.Size(100, 28);
this.scid_box.TabIndex = 8;
this.scid_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.scid_box_KeyPress);
//
// scname_box
//
this.scname_box.Location = new System.Drawing.Point(141, 82);
this.scname_box.Name = "scname_box";
this.scname_box.Size = new System.Drawing.Size(100, 28);
this.scname_box.TabIndex = 9;
//
// scsin_box
//
this.scsin_box.Location = new System.Drawing.Point(141, 127);
this.scsin_box.Name = "scsin_box";
this.scsin_box.Size = new System.Drawing.Size(100, 28);
this.scsin_box.TabIndex = 10;
//
// mass_box
//
this.mass_box.Location = new System.Drawing.Point(141, 173);
this.mass_box.Name = "mass_box";
this.mass_box.Size = new System.Drawing.Size(100, 28);
this.mass_box.TabIndex = 11;
//
// total_box
//
this.total_box.Location = new System.Drawing.Point(141, 220);
this.total_box.Name = "total_box";
this.total_box.Size = new System.Drawing.Size(100, 28);
this.total_box.TabIndex = 12;
//
// scanid_box
//
this.scanid_box.Location = new System.Drawing.Point(141, 269);
this.scanid_box.Name = "scanid_box";
this.scanid_box.Size = new System.Drawing.Size(100, 28);
this.scanid_box.TabIndex = 13;
this.scanid_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.scanid_box_KeyPress);
//
// goods_id
//
this.goods_id.Location = new System.Drawing.Point(441, 37);
this.goods_id.Name = "goods_id";
this.goods_id.Size = new System.Drawing.Size(100, 28);
this.goods_id.TabIndex = 14;
this.goods_id.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.goods_id_KeyPress);
//
// goods_name
//
this.goods_name.Location = new System.Drawing.Point(441, 82);
this.goods_name.Name = "goods_name";
this.goods_name.Size = new System.Drawing.Size(100, 28);
this.goods_name.TabIndex = 15;
//
// goods_sin
//
this.goods_sin.Location = new System.Drawing.Point(441, 130);
this.goods_sin.Name = "goods_sin";
this.goods_sin.Size = new System.Drawing.Size(100, 28);
this.goods_sin.TabIndex = 16;
//
// goods_store
//
this.goods_store.Location = new System.Drawing.Point(441, 173);
this.goods_store.Name = "goods_store";
this.goods_store.Size = new System.Drawing.Size(100, 28);
this.goods_store.TabIndex = 17;
//
// user_box
//
this.user_box.Location = new System.Drawing.Point(997, 37);
this.user_box.Name = "user_box";
this.user_box.Size = new System.Drawing.Size(100, 28);
this.user_box.TabIndex = 19;
this.user_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.user_box_KeyPress);
//
// pass_box
//
this.pass_box.Location = new System.Drawing.Point(997, 82);
this.pass_box.Name = "pass_box";
this.pass_box.Size = new System.Drawing.Size(100, 28);
this.pass_box.TabIndex = 20;
//
// right_box
//
this.right_box.Location = new System.Drawing.Point(997, 127);
this.right_box.Name = "right_box";
this.right_box.Size = new System.Drawing.Size(100, 28);
this.right_box.TabIndex = 21;
//
// staname
//
this.staname.Location = new System.Drawing.Point(715, 82);
this.staname.Name = "staname";
this.staname.Size = new System.Drawing.Size(100, 28);
this.staname.TabIndex = 22;
//
// stasex
//
this.stasex.Location = new System.Drawing.Point(715, 130);
this.stasex.Name = "stasex";
this.stasex.Size = new System.Drawing.Size(100, 28);
this.stasex.TabIndex = 23;
this.stasex.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.stasex_KeyPress);
//
// staid
//
this.staid.Location = new System.Drawing.Point(715, 37);
this.staid.Name = "staid";
this.staid.Size = new System.Drawing.Size(100, 28);
this.staid.TabIndex = 24;
this.staid.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.staid_KeyPress);
//
// stajob
//
this.stajob.Location = new System.Drawing.Point(715, 173);
this.stajob.Name = "stajob";
this.stajob.Size = new System.Drawing.Size(100, 28);
this.stajob.TabIndex = 25;
//
// stasal
//
this.stasal.Location = new System.Drawing.Point(715, 220);
this.stasal.Name = "stasal";
this.stasal.Size = new System.Drawing.Size(100, 28);
this.stasal.TabIndex = 26;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(340, 40);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(80, 18);
this.label8.TabIndex = 27;
this.label8.Text = "商品编号";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(340, 85);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(80, 18);
this.label9.TabIndex = 28;
this.label9.Text = "商品名称";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(376, 133);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(44, 18);
this.label10.TabIndex = 29;
this.label10.Text = "单价";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(376, 176);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(44, 18);
this.label11.TabIndex = 30;
this.label11.Text = "库存";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(618, 40);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(80, 18);
this.label13.TabIndex = 32;
this.label13.Text = "职工编号";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(618, 85);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(80, 18);
this.label14.TabIndex = 33;
this.label14.Text = "职工姓名";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(654, 130);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(44, 18);
this.label15.TabIndex = 34;
this.label15.Text = "性别";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(654, 176);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(44, 18);
this.label16.TabIndex = 35;
this.label16.Text = "职位";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(654, 223);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(44, 18);
this.label17.TabIndex = 36;
this.label17.Text = "工资";
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(915, 40);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(62, 18);
this.label18.TabIndex = 37;
this.label18.Text = "账户名";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(933, 85);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(44, 18);
this.label19.TabIndex = 38;
this.label19.Text = "密码";
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(933, 133);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(44, 18);
this.label20.TabIndex = 39;
this.label20.Text = "职位";
//
// ifdiscount
//
this.ifdiscount.AutoSize = true;
this.ifdiscount.Location = new System.Drawing.Point(436, 221);
this.ifdiscount.Name = "ifdiscount";
this.ifdiscount.Size = new System.Drawing.Size(105, 22);
this.ifdiscount.TabIndex = 48;
this.ifdiscount.TabStop = true;
this.ifdiscount.Text = "是否打折";
this.ifdiscount.UseVisualStyleBackColor = true;
this.ifdiscount.CheckedChanged += new System.EventHandler(this.ifdiscount_CheckedChanged);
this.ifdiscount.Click += new System.EventHandler(this.ifdiscount_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(537, 357);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(225, 116);
this.button2.TabIndex = 50;
this.button2.Text = "添加";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(768, 357);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(154, 26);
this.comboBox1.TabIndex = 51;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(99, 357);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(26, 18);
this.label2.TabIndex = 52;
this.label2.Text = "月";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(99, 394);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(26, 18);
this.label12.TabIndex = 53;
this.label12.Text = "日";
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(273, 315);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(26, 18);
this.label21.TabIndex = 54;
this.label21.Text = "时";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(273, 360);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(26, 18);
this.label22.TabIndex = 55;
this.label22.Text = "分";
//
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(273, 394);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(26, 18);
this.label23.TabIndex = 56;
this.label23.Text = "秒";
//
// label24
//
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(201, 438);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(98, 18);
this.label24.TabIndex = 57;
this.label24.Text = "秒后小数点";
//
// month_box
//
this.month_box.Location = new System.Drawing.Point(140, 354);
this.month_box.Name = "month_box";
this.month_box.Size = new System.Drawing.Size(100, 28);
this.month_box.TabIndex = 58;
this.month_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.month_box_KeyPress);
//
// day_box
//
this.day_box.Location = new System.Drawing.Point(140, 391);
this.day_box.Name = "day_box";
this.day_box.Size = new System.Drawing.Size(100, 28);
this.day_box.TabIndex = 59;
this.day_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.day_box_KeyPress);
//
// hour_box
//
this.hour_box.Location = new System.Drawing.Point(305, 312);
this.hour_box.Name = "hour_box";
this.hour_box.Size = new System.Drawing.Size(100, 28);
this.hour_box.TabIndex = 60;
this.hour_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.hour_box_KeyPress);
//
// second_box
//
this.second_box.Location = new System.Drawing.Point(305, 391);
this.second_box.Name = "second_box";
this.second_box.Size = new System.Drawing.Size(100, 28);
this.second_box.TabIndex = 61;
this.second_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.second_box_KeyPress);
//
// min_box
//
this.min_box.Location = new System.Drawing.Point(305, 354);
this.min_box.Name = "min_box";
this.min_box.Size = new System.Drawing.Size(100, 28);
this.min_box.TabIndex = 62;
this.min_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.min_box_KeyPress);
//
// exsecond_box
//
this.exsecond_box.Location = new System.Drawing.Point(305, 435);
this.exsecond_box.Name = "exsecond_box";
this.exsecond_box.ReadOnly = true;
this.exsecond_box.Size = new System.Drawing.Size(100, 28);
this.exsecond_box.TabIndex = 63;
this.exsecond_box.Text = "000";
this.exsecond_box.TextChanged += new System.EventHandler(this.exsecond_box_TextChanged);
this.exsecond_box.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.exsecond_box_KeyPress);
//
// button1
//
this.button1.Location = new System.Drawing.Point(971, 414);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(126, 59);
this.button1.TabIndex = 64;
this.button1.Text = "退出";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form6
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1220, 626);
this.Controls.Add(this.button1);
this.Controls.Add(this.exsecond_box);
this.Controls.Add(this.min_box);
this.Controls.Add(this.second_box);
this.Controls.Add(this.hour_box);
this.Controls.Add(this.day_box);
this.Controls.Add(this.month_box);
this.Controls.Add(this.label24);
this.Controls.Add(this.label23);
this.Controls.Add(this.label22);
this.Controls.Add(this.label21);
this.Controls.Add(this.label12);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.ifdiscount);
this.Controls.Add(this.label20);
this.Controls.Add(this.label19);
this.Controls.Add(this.label18);
this.Controls.Add(this.label17);
this.Controls.Add(this.label16);
this.Controls.Add(this.label15);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.stasal);
this.Controls.Add(this.stajob);
this.Controls.Add(this.staid);
this.Controls.Add(this.stasex);
this.Controls.Add(this.staname);
this.Controls.Add(this.right_box);
this.Controls.Add(this.pass_box);
this.Controls.Add(this.user_box);
this.Controls.Add(this.goods_store);
this.Controls.Add(this.goods_sin);
this.Controls.Add(this.goods_name);
this.Controls.Add(this.goods_id);
this.Controls.Add(this.scanid_box);
this.Controls.Add(this.total_box);
this.Controls.Add(this.mass_box);
this.Controls.Add(this.scsin_box);
this.Controls.Add(this.scname_box);
this.Controls.Add(this.scid_box);
this.Controls.Add(this.year_box);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.商品编号);
this.Controls.Add(this.label1);
this.Name = "Form6";
this.Text = "Form6";
this.Load += new System.EventHandler(this.Form6_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label 商品编号;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox year_box;
private System.Windows.Forms.TextBox scid_box;
private System.Windows.Forms.TextBox scname_box;
private System.Windows.Forms.TextBox scsin_box;
private System.Windows.Forms.TextBox mass_box;
private System.Windows.Forms.TextBox total_box;
private System.Windows.Forms.TextBox scanid_box;
private System.Windows.Forms.TextBox goods_id;
private System.Windows.Forms.TextBox goods_name;
private System.Windows.Forms.TextBox goods_sin;
private System.Windows.Forms.TextBox goods_store;
private System.Windows.Forms.TextBox user_box;
private System.Windows.Forms.TextBox pass_box;
private System.Windows.Forms.TextBox right_box;
private System.Windows.Forms.TextBox staname;
private System.Windows.Forms.TextBox stasex;
private System.Windows.Forms.TextBox staid;
private System.Windows.Forms.TextBox stajob;
private System.Windows.Forms.TextBox stasal;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.RadioButton ifdiscount;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.TextBox month_box;
private System.Windows.Forms.TextBox day_box;
private System.Windows.Forms.TextBox hour_box;
private System.Windows.Forms.TextBox second_box;
private System.Windows.Forms.TextBox min_box;
private System.Windows.Forms.TextBox exsecond_box;
private System.Windows.Forms.Button button1;
}
}
form7
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
public Form7(string upkey,string tranid,string tranname,string transin,string tranmass,string tranto,string transta)
{
InitializeComponent();
transkey.Text = upkey;
scgoodsid.Text= tranid;
scname.Text = tranname;
scsin.Text = transin;
mass.Text = tranmass;
total.Text = tranto;
scstaid.Text = transta;
}
private void label24_Click(object sender, EventArgs e)
{
}
private void Form7_Load(object sender, EventArgs e)
{
//transkey.Text=Form5.
string[] str1 = new string[] { "修改扫描信息", "修改商品信息", "修改职工信息", "修改注册信息" };
string[] str2 = new string[] { "True","False"};
string[] str3 = new string[] { "男","女" };
string[] str4 = new string[] { "经理","员工" };
comboBox1.Items.AddRange(str1);
ifdiscount.Items.AddRange(str2);
sex.Items.AddRange(str3);
right.Items.AddRange(str4);
if (transkey.Text != "无传入参数(本文本为验收时要求新加的功能)")
{
year.Text = "0";
month.Text = "0";
day.Text = "0";
hour.Text = "00";
minute.Text = "00";
second.Text = "0";
/*year.ReadOnly = true;
month.ReadOnly = true;
day.ReadOnly = true;
hour.ReadOnly = true;
minute.ReadOnly = true;
second.ReadOnly = true;*/
}
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(comboBox1.Text))
{
MessageBox.Show("选择修改的表");
return;
}
if (comboBox1.Text == "修改扫描信息")
{
string upyear = year.Text;
string upmonth = month.Text;
string upday = day.Text;
string uphour = hour.Text;
string upmin = minute.Text;
string upsecond = second.Text;
string upexsecond = exsecond.Text;
string upid = scgoodsid.Text;
string upname = scname.Text;
string upsin = scsin.Text;
string upmass = mass.Text;
string uptotal = total.Text;
string upstaid = scstaid.Text;
if (string.IsNullOrEmpty(upyear) || string.IsNullOrEmpty(upmonth) || string.IsNullOrEmpty(upday) || string.IsNullOrEmpty(uphour) || string.IsNullOrEmpty(upmin) || string.IsNullOrEmpty(upsecond) || string.IsNullOrEmpty(upexsecond) || string.IsNullOrEmpty(upstaid) || string.IsNullOrEmpty(upname) || string.IsNullOrEmpty(upid) || string.IsNullOrEmpty(upsin) || string.IsNullOrEmpty(upmass) || string.IsNullOrEmpty(uptotal))
{
MessageBox.Show("信息不得有空");
return;
}
bool flag1,flag2,flag3,flag4,flag5,flag6,flag7,flag8,flag9,flag10,flag11,flag12;
float temp;
int tempt,year_,month_,day_;
flag1 = int.TryParse(upyear, out year_);
flag2 = int.TryParse(upmonth, out month_);
flag3 = int.TryParse(upday, out day_);
flag4 = int.TryParse(uphour, out tempt);
flag5 = int.TryParse(upmin, out tempt);
flag6 = int.TryParse(upsecond, out tempt);
flag7 = int.TryParse(upexsecond, out tempt);
flag8 = float.TryParse(upid, out temp);
flag9 = float.TryParse(upsin, out temp);
flag10 = float.TryParse(upmass, out temp);
flag11 = float.TryParse(uptotal, out temp);
flag12 = float.TryParse(upstaid, out temp);
if(!flag1|| !flag2 || !flag3 || !flag4 || !flag5 || !flag6 || !flag7 || !flag8 || !flag9 || !flag10 || !flag11 || !flag12)
{
MessageBox.Show("输入的数据不合法!");
return;
}
if (year_ > 2024 || year_ < 2000)
{
MessageBox.Show("输入年份不合法");
return;
}
if (month_ < 1 || month_ > 12)
{
MessageBox.Show("检查月份!");
return;
}
if (day_ > 31 || day_ < 1)
{
MessageBox.Show("检查输入的日期!");
return;
}
if (month_ == 2 || month_ == 4 || month_ == 6 || month_ == 9 || month_ == 11)
{
if (day_ == 31)
{
MessageBox.Show("这个月真的有31天吗?");
return;
}
}
if (month_ == 2)
{
if (year_ == 2000 || year_ == 2004 || year_ == 2008 || year_ == 2012 || year_ == 2016 || year_ == 2020 || year_ == 2024)
{
if (day_ > 29)
{
MessageBox.Show("检查输入的日期!");
return;
}
}
else
{
if (day_ > 28)
{
MessageBox.Show("检查输入的日期!");
return;
}
}
}
string time="'"+upyear+"-"+upmonth+"-"+upday+" "+uphour+":"+upmin+":"+upsecond+"."+upexsecond+"'";
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection up_con = new SqlConnection(constr);
if (transkey.Text != "无传入参数(本文本为验收时要求新加的功能)")
{
time = transkey.Text + ".000";
//string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection insert_con = new SqlConnection(constr);
insert_con.Open();
string sel_goods_str = "select * from 商品信息 where 商品编号 ='" + upid + "'and 商品名称 ='"+upname+"'";
SqlCommand sel_goods_com = new SqlCommand(sel_goods_str, insert_con);
SqlDataReader dr_goods_sel = sel_goods_com.ExecuteReader();
if (!dr_goods_sel.HasRows)
{
MessageBox.Show("无此商品!");
insert_con.Close();
return;
}
insert_con.Close();
// insert_con.Open();
//string sel_str = "select * from 扫描信息 where 扫描时间 ="+time;
string up_str = "update 扫描信息 set 商品编号 = '" + upid + "' ,商品名称 = '" + upname + "' ,商品单价 = '" + upsin + "' ,质量 = '" + upmass + "' ,总价 = '" + uptotal + "' ,扫描人员编号 = '" + upstaid + "' where 扫描时间 = "+ time+"";
//SqlCommand sel_com = new SqlCommand(sel_str, up_con);
//SqlDataReader dr_sel = sel_com.ExecuteReader();
up_con.Open();
SqlCommand up_com = new SqlCommand(up_str, up_con);
int num = up_com.ExecuteNonQuery();
MessageBox.Show(num + "条信息被修改");
return;
}
else
{
SqlConnection insert_con = new SqlConnection(constr);
insert_con.Open();
string sel_goods_str = "select * from 商品信息 where 商品编号 ='" + upid + "'and 商品名称 ='" + upname + "'";
SqlCommand sel_goods_com = new SqlCommand(sel_goods_str, insert_con);
SqlDataReader dr_goods_sel = sel_goods_com.ExecuteReader();
if (!dr_goods_sel.HasRows)
{
MessageBox.Show("无此商品!");
insert_con.Close();
return;
}
insert_con.Close();
// insert_con.Open();
//string sel_str = "select * from 扫描信息 where 扫描时间 ="+time;
string up_str = "update 扫描信息 set 商品编号 = '" + upid + "' ,商品名称 = '" + upname + "' ,商品单价 = '" + upsin + "' ,质量 = '" + upmass + "' ,总价 = '" + uptotal + "' ,扫描人员编号 = '" + upstaid + "' where 扫描时间 = " + time + "";
//SqlCommand sel_com = new SqlCommand(sel_str, up_con);
//SqlDataReader dr_sel = sel_com.ExecuteReader();
up_con.Open();
SqlCommand up_com = new SqlCommand(up_str, up_con);
int num = up_com.ExecuteNonQuery();
MessageBox.Show(num + "条信息被修改");
return;
}
}
if (comboBox1.Text == "修改商品信息")
{
string upid = goodsid.Text;
string upname = goodsname.Text;
string upsin = sin.Text;
string upstore = store.Text;
string updiscount = ifdiscount.Text;
if (string.IsNullOrEmpty(upid) || string.IsNullOrEmpty(upname) || string.IsNullOrEmpty(upsin) || string.IsNullOrEmpty(upstore) || string.IsNullOrEmpty(updiscount))
{
MessageBox.Show("信息不能有空!");
return;
}
bool flag1, flag2, flag3;
float temp;
flag1 = float.TryParse(upsin, out temp);
flag2 = float.TryParse(upid, out temp);
flag3 = float.TryParse(upstore, out temp);
if (!flag1 || !flag2 || !flag3)
{
MessageBox.Show("输入数字不合法");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection up_con = new SqlConnection(constr);
up_con.Open();
string sel_str = "select * from 商品信息 where 商品编号 = '" + upid+"'";
string up_str = "update 商品信息 set 商品名称 = '" + upname + "' ,单价 = '" + upsin + "' ,库存 = '" + upstore + "' ,是否打折 = '" + updiscount + "' where 商品编号 = '" + upid + "'";
SqlCommand sel_com = new SqlCommand(sel_str, up_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
up_con.Close();
up_con.Open();
SqlCommand up_com = new SqlCommand(up_str, up_con);
int num = up_com.ExecuteNonQuery();
MessageBox.Show(num + "条信息被修改");
return;
}
else
{
MessageBox.Show("没有这条信息");
return;
}
}
if (comboBox1.Text == "修改职工信息")
{
string upid = staid.Text;
string upname = staname.Text;
string upsex = sex.Text;
string upjob = job.Text;
string upsal = salary.Text;
if (string.IsNullOrEmpty(upid) || string.IsNullOrEmpty(upname) || string.IsNullOrEmpty(upsex) || string.IsNullOrEmpty(upjob) || string.IsNullOrEmpty(upsal))
{
MessageBox.Show("信息不能有空!");
return;
}
bool flag1, flag2;
float temp;
flag1 = float.TryParse(upsal, out temp);
flag2 = float.TryParse(upid, out temp);
if (!flag1 || !flag2)
{
MessageBox.Show("输入数字不合法");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = 'True'";
SqlConnection up_con = new SqlConnection(constr);
up_con.Open();
string sel_str = "select * from 职员信息 where 编号 = '"+ upid+"' and 在职 = 'True'";
string up_str = "update 职员信息 set 姓名 = '" + upname + "' ,性别 = '" + upsex + "' ,职位 = '" + upjob + "' ,工资 = '" + upsal + "' where 编号 = '" + upid + "'and 在职 = 'True'";
SqlCommand sel_com = new SqlCommand(sel_str, up_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
up_con.Close();
up_con.Open();
SqlCommand up_com = new SqlCommand(up_str, up_con);
int num = up_com.ExecuteNonQuery();
MessageBox.Show(num + "条信息被修改");
return;
}
else
{
MessageBox.Show("没有这条信息");
return;
}
}
if (comboBox1.Text == "修改注册信息")
{
string upuser = username.Text;
string uppass = password.Text;
string upright = right.Text;
if (string.IsNullOrEmpty(upuser) || string.IsNullOrEmpty(uppass) || string.IsNullOrEmpty(upright))
{
MessageBox.Show("信息不得有空");
return;
}
if (upuser.Length < 5 || upuser.Length > 20||uppass.Length<5||uppass.Length>20)
{
MessageBox.Show("用户名和密码必须在5-20位以内");
return;
}
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = 'True'";
SqlConnection up_con = new SqlConnection(constr);
up_con.Open();
string sel_str = "select * from 账户 where ID ='" + upuser + "'";
string up_str = "update 账户 set PASSWORD = '" + uppass + "' ,JOB = '" + upright + "' where ID = '" + upuser + "'";
SqlCommand sel_com = new SqlCommand(sel_str, up_con);
SqlDataReader dr_sel = sel_com.ExecuteReader();
if (dr_sel.HasRows)
{
up_con.Close();
up_con.Open();
SqlCommand up_com = new SqlCommand(up_str, up_con);
int num = up_com.ExecuteNonQuery();
MessageBox.Show(num + "条信息被修改");
return;
}
else
{
MessageBox.Show("没有这条信息");
return;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void label12_Click(object sender, EventArgs e)
{
}
private void 详细信息_Click(object sender, EventArgs e)
{
}
}
}
designer
namespace WindowsFormsApp3
{
partial class Form7
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.scgoodsid = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.scname = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.scsin = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.mass = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.total = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.scstaid = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.goodsid = new System.Windows.Forms.TextBox();
this.goodsname = new System.Windows.Forms.TextBox();
this.sin = new System.Windows.Forms.TextBox();
this.store = new System.Windows.Forms.TextBox();
this.编号 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.staid = new System.Windows.Forms.TextBox();
this.staname = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.job = new System.Windows.Forms.TextBox();
this.label16 = new System.Windows.Forms.Label();
this.salary = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.username = new System.Windows.Forms.TextBox();
this.password = new System.Windows.Forms.TextBox();
this.label20 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.label23 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label();
this.label26 = new System.Windows.Forms.Label();
this.year = new System.Windows.Forms.TextBox();
this.month = new System.Windows.Forms.TextBox();
this.day = new System.Windows.Forms.TextBox();
this.hour = new System.Windows.Forms.TextBox();
this.minute = new System.Windows.Forms.TextBox();
this.second = new System.Windows.Forms.TextBox();
this.exsecond = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.ifdiscount = new System.Windows.Forms.ComboBox();
this.sex = new System.Windows.Forms.ComboBox();
this.right = new System.Windows.Forms.ComboBox();
this.label27 = new System.Windows.Forms.Label();
this.transkey = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 243);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 18);
this.label1.TabIndex = 0;
this.label1.Text = "商品编号";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(92, 12);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(147, 26);
this.comboBox1.TabIndex = 1;
//
// scgoodsid
//
this.scgoodsid.Location = new System.Drawing.Point(113, 237);
this.scgoodsid.Name = "scgoodsid";
this.scgoodsid.Size = new System.Drawing.Size(100, 28);
this.scgoodsid.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(26, 293);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 18);
this.label2.TabIndex = 3;
this.label2.Text = "商品名称";
//
// scname
//
this.scname.Location = new System.Drawing.Point(113, 290);
this.scname.Name = "scname";
this.scname.Size = new System.Drawing.Size(100, 28);
this.scname.TabIndex = 4;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(26, 347);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 18);
this.label3.TabIndex = 5;
this.label3.Text = "商品单价";
//
// scsin
//
this.scsin.Location = new System.Drawing.Point(113, 344);
this.scsin.Name = "scsin";
this.scsin.Size = new System.Drawing.Size(100, 28);
this.scsin.TabIndex = 6;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(62, 397);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 18);
this.label4.TabIndex = 7;
this.label4.Text = "质量";
//
// mass
//
this.mass.Location = new System.Drawing.Point(113, 394);
this.mass.Name = "mass";
this.mass.Size = new System.Drawing.Size(100, 28);
this.mass.TabIndex = 8;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(62, 450);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(44, 18);
this.label5.TabIndex = 9;
this.label5.Text = "总价";
//
// total
//
this.total.Location = new System.Drawing.Point(113, 447);
this.total.Name = "total";
this.total.Size = new System.Drawing.Size(100, 28);
this.total.TabIndex = 10;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(219, 296);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(116, 18);
this.label6.TabIndex = 11;
this.label6.Text = "扫描人员编号";
//
// scstaid
//
this.scstaid.Location = new System.Drawing.Point(334, 293);
this.scstaid.Name = "scstaid";
this.scstaid.Size = new System.Drawing.Size(100, 28);
this.scstaid.TabIndex = 12;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(543, 93);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(80, 18);
this.label7.TabIndex = 13;
this.label7.Text = "商品编号";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(543, 143);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(80, 18);
this.label8.TabIndex = 14;
this.label8.Text = "商品名称";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(579, 194);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(44, 18);
this.label9.TabIndex = 15;
this.label9.Text = "单价";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(579, 243);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(44, 18);
this.label10.TabIndex = 16;
this.label10.Text = "库存";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(543, 293);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(80, 18);
this.label11.TabIndex = 17;
this.label11.Text = "是否打折";
//
// goodsid
//
this.goodsid.Location = new System.Drawing.Point(645, 90);
this.goodsid.Name = "goodsid";
this.goodsid.Size = new System.Drawing.Size(100, 28);
this.goodsid.TabIndex = 18;
//
// goodsname
//
this.goodsname.Location = new System.Drawing.Point(645, 140);
this.goodsname.Name = "goodsname";
this.goodsname.Size = new System.Drawing.Size(100, 28);
this.goodsname.TabIndex = 19;
//
// sin
//
this.sin.Location = new System.Drawing.Point(645, 191);
this.sin.Name = "sin";
this.sin.Size = new System.Drawing.Size(100, 28);
this.sin.TabIndex = 20;
//
// store
//
this.store.Location = new System.Drawing.Point(645, 240);
this.store.Name = "store";
this.store.Size = new System.Drawing.Size(100, 28);
this.store.TabIndex = 21;
//
// 编号
//
this.编号.AutoSize = true;
this.编号.Location = new System.Drawing.Point(852, 96);
this.编号.Name = "编号";
this.编号.Size = new System.Drawing.Size(80, 18);
this.编号.TabIndex = 23;
this.编号.Text = "人员编号";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(852, 143);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(80, 18);
this.label13.TabIndex = 24;
this.label13.Text = "人员姓名";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(888, 197);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(44, 18);
this.label14.TabIndex = 25;
this.label14.Text = "性别";
//
// staid
//
this.staid.Location = new System.Drawing.Point(955, 93);
this.staid.Name = "staid";
this.staid.Size = new System.Drawing.Size(100, 28);
this.staid.TabIndex = 26;
//
// staname
//
this.staname.Location = new System.Drawing.Point(955, 140);
this.staname.Name = "staname";
this.staname.Size = new System.Drawing.Size(100, 28);
this.staname.TabIndex = 27;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(888, 243);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(44, 18);
this.label15.TabIndex = 29;
this.label15.Text = "职位";
//
// job
//
this.job.Location = new System.Drawing.Point(955, 240);
this.job.Name = "job";
this.job.Size = new System.Drawing.Size(100, 28);
this.job.TabIndex = 30;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(888, 293);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(44, 18);
this.label16.TabIndex = 31;
this.label16.Text = "工资";
//
// salary
//
this.salary.Location = new System.Drawing.Point(955, 290);
this.salary.Name = "salary";
this.salary.Size = new System.Drawing.Size(100, 28);
this.salary.TabIndex = 32;
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(1162, 96);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(62, 18);
this.label17.TabIndex = 33;
this.label17.Text = "账户名";
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(1162, 143);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(44, 18);
this.label18.TabIndex = 34;
this.label18.Text = "密码";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(1162, 194);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(44, 18);
this.label19.TabIndex = 35;
this.label19.Text = "权限";
//
// username
//
this.username.Location = new System.Drawing.Point(1235, 93);
this.username.Name = "username";
this.username.Size = new System.Drawing.Size(100, 28);
this.username.TabIndex = 36;
//
// password
//
this.password.Location = new System.Drawing.Point(1235, 140);
this.password.Name = "password";
this.password.Size = new System.Drawing.Size(100, 28);
this.password.TabIndex = 37;
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(80, 93);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(26, 18);
this.label20.TabIndex = 39;
this.label20.Text = "年";
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(80, 150);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(26, 18);
this.label21.TabIndex = 40;
this.label21.Text = "月";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(80, 194);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(26, 18);
this.label22.TabIndex = 41;
this.label22.Text = "日";
//
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(284, 96);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(26, 18);
this.label23.TabIndex = 42;
this.label23.Text = "时";
//
// label24
//
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(284, 143);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(26, 18);
this.label24.TabIndex = 43;
this.label24.Text = "分";
this.label24.Click += new System.EventHandler(this.label24_Click);
//
// label25
//
this.label25.AutoSize = true;
this.label25.Location = new System.Drawing.Point(284, 194);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(26, 18);
this.label25.TabIndex = 44;
this.label25.Text = "秒";
//
// label26
//
this.label26.AutoSize = true;
this.label26.Location = new System.Drawing.Point(230, 240);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(98, 18);
this.label26.TabIndex = 45;
this.label26.Text = "秒后小数点";
//
// year
//
this.year.Location = new System.Drawing.Point(113, 90);
this.year.Name = "year";
this.year.Size = new System.Drawing.Size(100, 28);
this.year.TabIndex = 46;
//
// month
//
this.month.Location = new System.Drawing.Point(113, 140);
this.month.Name = "month";
this.month.Size = new System.Drawing.Size(100, 28);
this.month.TabIndex = 47;
//
// day
//
this.day.Location = new System.Drawing.Point(113, 188);
this.day.Name = "day";
this.day.Size = new System.Drawing.Size(100, 28);
this.day.TabIndex = 48;
//
// hour
//
this.hour.Location = new System.Drawing.Point(334, 90);
this.hour.Name = "hour";
this.hour.Size = new System.Drawing.Size(100, 28);
this.hour.TabIndex = 49;
//
// minute
//
this.minute.Location = new System.Drawing.Point(334, 140);
this.minute.Name = "minute";
this.minute.Size = new System.Drawing.Size(100, 28);
this.minute.TabIndex = 50;
//
// second
//
this.second.Location = new System.Drawing.Point(333, 191);
this.second.Name = "second";
this.second.Size = new System.Drawing.Size(100, 28);
this.second.TabIndex = 51;
//
// exsecond
//
this.exsecond.Location = new System.Drawing.Point(334, 237);
this.exsecond.Name = "exsecond";
this.exsecond.ReadOnly = true;
this.exsecond.Size = new System.Drawing.Size(100, 28);
this.exsecond.TabIndex = 52;
this.exsecond.Text = "000";
//
// button1
//
this.button1.Location = new System.Drawing.Point(378, 394);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(195, 90);
this.button1.TabIndex = 53;
this.button1.Text = "修改";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(764, 394);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(198, 90);
this.button2.TabIndex = 54;
this.button2.Text = "退出";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// ifdiscount
//
this.ifdiscount.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ifdiscount.FormattingEnabled = true;
this.ifdiscount.Location = new System.Drawing.Point(645, 290);
this.ifdiscount.Name = "ifdiscount";
this.ifdiscount.Size = new System.Drawing.Size(100, 26);
this.ifdiscount.TabIndex = 55;
//
// sex
//
this.sex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.sex.FormattingEnabled = true;
this.sex.Location = new System.Drawing.Point(955, 194);
this.sex.Name = "sex";
this.sex.Size = new System.Drawing.Size(100, 26);
this.sex.TabIndex = 56;
//
// right
//
this.right.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.right.FormattingEnabled = true;
this.right.Location = new System.Drawing.Point(1235, 191);
this.right.Name = "right";
this.right.Size = new System.Drawing.Size(100, 26);
this.right.TabIndex = 57;
//
// label27
//
this.label27.AutoSize = true;
this.label27.Location = new System.Drawing.Point(284, 354);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(422, 18);
this.label27.TabIndex = 59;
this.label27.Text = "你是经理,手动修改的密码只需要在5-20位以内即可";
//
// transkey
//
this.transkey.AutoSize = true;
this.transkey.Location = new System.Drawing.Point(290, 26);
this.transkey.Name = "transkey";
this.transkey.Size = new System.Drawing.Size(368, 18);
this.transkey.TabIndex = 60;
this.transkey.Text = "无传入参数(本文本为验收时要求新加的功能)";
//
// Form7
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1401, 603);
this.Controls.Add(this.transkey);
this.Controls.Add(this.label27);
this.Controls.Add(this.right);
this.Controls.Add(this.sex);
this.Controls.Add(this.ifdiscount);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.exsecond);
this.Controls.Add(this.second);
this.Controls.Add(this.minute);
this.Controls.Add(this.hour);
this.Controls.Add(this.day);
this.Controls.Add(this.month);
this.Controls.Add(this.year);
this.Controls.Add(this.label26);
this.Controls.Add(this.label25);
this.Controls.Add(this.label24);
this.Controls.Add(this.label23);
this.Controls.Add(this.label22);
this.Controls.Add(this.label21);
this.Controls.Add(this.label20);
this.Controls.Add(this.password);
this.Controls.Add(this.username);
this.Controls.Add(this.label19);
this.Controls.Add(this.label18);
this.Controls.Add(this.label17);
this.Controls.Add(this.salary);
this.Controls.Add(this.label16);
this.Controls.Add(this.job);
this.Controls.Add(this.label15);
this.Controls.Add(this.staname);
this.Controls.Add(this.staid);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.编号);
this.Controls.Add(this.store);
this.Controls.Add(this.sin);
this.Controls.Add(this.goodsname);
this.Controls.Add(this.goodsid);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.scstaid);
this.Controls.Add(this.label6);
this.Controls.Add(this.total);
this.Controls.Add(this.label5);
this.Controls.Add(this.mass);
this.Controls.Add(this.label4);
this.Controls.Add(this.scsin);
this.Controls.Add(this.label3);
this.Controls.Add(this.scname);
this.Controls.Add(this.label2);
this.Controls.Add(this.scgoodsid);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Name = "Form7";
this.Text = "Form7";
this.Load += new System.EventHandler(this.Form7_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TextBox scgoodsid;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox scname;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox scsin;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox mass;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox total;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox scstaid;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox goodsid;
private System.Windows.Forms.TextBox goodsname;
private System.Windows.Forms.TextBox sin;
private System.Windows.Forms.TextBox store;
private System.Windows.Forms.Label 编号;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.TextBox staid;
private System.Windows.Forms.TextBox staname;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox job;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.TextBox salary;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.TextBox username;
private System.Windows.Forms.TextBox password;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.Label label25;
private System.Windows.Forms.Label label26;
private System.Windows.Forms.TextBox year;
private System.Windows.Forms.TextBox month;
private System.Windows.Forms.TextBox day;
private System.Windows.Forms.TextBox hour;
private System.Windows.Forms.TextBox minute;
private System.Windows.Forms.TextBox second;
private System.Windows.Forms.TextBox exsecond;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox ifdiscount;
private System.Windows.Forms.ComboBox sex;
private System.Windows.Forms.ComboBox right;
private System.Windows.Forms.Label label27;
private System.Windows.Forms.Label transkey;
}
}
form8
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp3
{
public partial class Form8 : Form
{
public Form8()
{
InitializeComponent();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string constr = "server = LAPTOP-6O81U8K9; Initial Catalog = market; Integrated Security = True";
SqlConnection sel_con = new SqlConnection(constr);
DataTable dt = new DataTable();
string sel = "select 扫描人员编号, count(*) as 数量 from 扫描信息 where 总价 > 20 group by 扫描人员编号";
SqlDataAdapter ad = new SqlDataAdapter(sel, sel_con);
dt.Clear();
ad.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}
designer
namespace WindowsFormsApp3
{
partial class Form8
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(598, 162);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(110, 46);
this.button1.TabIndex = 0;
this.button1.Text = "点击显示";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(148, 150);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 62;
this.dataGridView1.Size = new System.Drawing.Size(404, 230);
this.dataGridView1.TabIndex = 1;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// Form8
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.button1);
this.Name = "Form8";
this.Text = "Form8";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridView dataGridView1;
}
}