private void FmCardShow_Load(object sender, EventArgs e) { string name = Gloable.LessonName; string sql1 = ""; sql1 = "select * from Qualifications where QuaName = '" + name + "'"; try { SqlDataReader dr = db.DB_Red(sql1); dr.Read(); LbQuaType.Text = dr.GetString(0); LaLessonName.Text = dr.GetString(1); LbQuaCost.Text = dr.GetString(4); LbQuaCandidate.Text = dr.GetString(2); LbQuaTime.Text = dr.GetString(5); LbQuaRequirement.Text = dr.GetString(3); LbQuaCourse.Text = dr.GetString(6); LbQuaAttention.Text = dr.GetString(7); dr.Close(); } catch { MessageBox.Show("无此数据!"); } }
private void formCGAdd_Load(object sender, EventArgs e) { //下拉菜单 this.comboBoxformCGGYS.Items.Add("全部"); string sql = "select distinct GYS from GYSAllFood"; SqlDataReader dr = db.DB_Red(sql); if (dr.HasRows) { while (dr.Read()) { this.comboBoxformCGGYS.Items.Add(dr[0].ToString()); this.comboBoxformCGGYS.SelectedIndex = 0; } dr.Close(); } //表格 this.dataGridViewformCG.AutoGenerateColumns = false; string sql1 = "select * from GYSAllFood"; SqlDataAdapter da = db.DB_Adp(sql1); DataTable dt = new DataTable(); da.Fill(dt); this.dataGridViewformCG.DataSource = dt; this.dataGridViewformCG.Columns[1].DataPropertyName = dt.Columns["GYS"].ToString(); this.dataGridViewformCG.Columns[2].DataPropertyName = dt.Columns["GYSFoodName"].ToString(); this.dataGridViewformCG.Columns[3].DataPropertyName = dt.Columns["GYSFoodType"].ToString(); this.dataGridViewformCG.Columns[4].DataPropertyName = dt.Columns["GYSDM"].ToString(); this.dataGridViewformCG.Columns[5].DataPropertyName = dt.Columns["GYSDiscountL"].ToString(); this.dataGridViewformCG.Columns[6].DataPropertyName = dt.Columns["GYSQuantity"].ToString(); this.dataGridViewformCG.Columns[7].DataPropertyName = dt.Columns["GYSText"].ToString(); this.dataGridViewformCG.Columns[8].DataPropertyName = ""; }
private void button2_Click(object sender, EventArgs e) { strID = tbID.Text.Trim(); strPsd = tbPsd.Text.Trim(); string strSql = ""; strSql = "select * from userTable where userID = '" + strID + "'"; SqlDataReader dr = db.DB_Red(strSql); if (dr.Read()) { string psd = db.DB_C(strSql, 1); if (strPsd.Equals(psd)) { string name = dr.GetString(2); string strSql2 = "delete from Users"; db.DB_ZSG(strSql2); string strSql1 = "insert into Users values('" + strID + "')"; db.DB_ZSG(strSql1); MessageBox.Show("登录成功"); Gloable.username = "******" + name; this.Close(); } } else { MessageBox.Show("用户名或者密码错误"); tbID.Text = ""; tbPsd.Text = ""; tbID.Focus(); } }
private void BackShowUser() { string strSql1 = "select * from userTable where userID = '" + username + "'"; SqlDataReader dr1; dr1 = db.DB_Red(strSql1); dr1.Read(); tbUserName.Text = dr1.GetString(2); comboBox1.Text = dr1.GetString(4); comboBox2.Text = dr1.GetString(5); tbPhone.Text = dr1.GetString(6); comboBox3.Text = dr1.GetString(7); comboBox4.Text = dr1.GetString(8); comboBox5.Text = dr1.GetString(9); dr1.Close(); }
private void FmSchool_Load(object sender, EventArgs e) { try { CbSchoolProvince.Items.Clear(); string sql1 = ""; sql1 = "select distinct schoolProvince from cardSchool"; SqlDataReader dr = db.DB_Red(sql1); if (dr.HasRows) { while (dr.Read()) { CbSchoolProvince.Items.Add(dr["schoolProvince"].ToString()); } dr.Close(); db.connClose(); } } catch { MessageBox.Show("窗口加载失败!"); } }
private void FmLesson_Load(object sender, EventArgs e) { try { CbAllType.Items.Clear(); string sql1 = ""; sql1 = "select distinct QuaType from Qualifications"; SqlDataReader dr = db.DB_Red(sql1); if (dr.HasRows) { while (dr.Read()) { CbAllType.Items.Add(dr["QuaType"].ToString()); } dr.Close(); db.connClose(); } } catch { MessageBox.Show("窗口加载失败"); } }
private void FmLessonShow_Load(object sender, EventArgs e) { string type = Gloable.type; try { string sql1 = ""; sql1 = "select QuaName from Qualifications where QuaType = '" + type + "'"; SqlDataReader dr = db.DB_Red(sql1); if (dr.HasRows) { while (dr.Read()) { CbQuaName.Items.Add(dr["QuaName"].ToString()); } dr.Close(); db.connClose(); } } catch { MessageBox.Show("窗口加载失败"); } }
private void mainWindow1_Load(object sender, EventArgs e) { //formCGAdd frmcgadd = new formCGAdd(); //frmcgadd.biaoge += new formCGAdd.caigou(mainWindow1.biaoge); this.mainWindow1.tabControlMainWindow.TabPages.Clear(); this.mainWindow1.tabPageDataAll.Parent = mainWindow1.tabControlMainWindow; //我的仓库********************************************************************************************************************* //商品类型下拉单 this.mainWindow1.tbKCXSJG.ReadOnly = true; this.mainWindow1.comboBoxKCFoodType.Items.Add("全部"); string sqlcgsplx = "select distinct KCFoodType from KC"; SqlDataReader dr = db.DB_Red(sqlcgsplx); if (dr.HasRows) { while (dr.Read()) { this.mainWindow1.comboBoxKCFoodType.Items.Add(dr[0].ToString()); this.mainWindow1.comboBoxKCFoodType.SelectedIndex = 0; } } dr.Close(); this.mainWindow1.dataGridViewCG.AutoGenerateColumns = false; string sql1 = "select * from KC"; SqlDataAdapter da = db.DB_Adp(sql1); DataTable dt = new DataTable(); da.Fill(dt); this.mainWindow1.dataGridViewKC.AutoGenerateColumns = false; this.mainWindow1.dataGridViewKC.DataSource = dt; this.mainWindow1.dataGridViewKC.Columns[0].DataPropertyName = dt.Columns["KCGYS"].ToString(); this.mainWindow1.dataGridViewKC.Columns[1].DataPropertyName = dt.Columns["KCFoodName"].ToString(); this.mainWindow1.dataGridViewKC.Columns[2].DataPropertyName = dt.Columns["KCFoodType"].ToString(); this.mainWindow1.dataGridViewKC.Columns[3].DataPropertyName = dt.Columns["KCBM"].ToString(); this.mainWindow1.dataGridViewKC.Columns[4].DataPropertyName = dt.Columns["KCSJ"].ToString(); this.mainWindow1.dataGridViewKC.Columns[5].DataPropertyName = dt.Columns["KCQuantity"].ToString(); this.mainWindow1.tabControlMainWindow.DrawMode = TabDrawMode.OwnerDrawFixed; this.mainWindow1.tabControlMainWindow.Padding = new System.Drawing.Point(Width_SIZE, Height_SIZE); this.mainWindow1.tabControlMainWindow.DrawItem += new DrawItemEventHandler(tabControlMainWindow_DrawItem); this.mainWindow1.tabControlMainWindow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tabControlMainWindow_MouseDown); }
//登录按钮事件 private void btnLogin_Click(object sender, EventArgs e) { string strUserName = ""; string strUserPwd = ""; strUserName = tbUserName.Text.Trim(); strUserPwd = tbUserPwd.Text.Trim(); if (strUserName == "") { MessageBox.Show("用户名不能为空!", "警告"); return; } if (strUserPwd == "") { MessageBox.Show("密码不能为空!", "警告"); return; } string strSql = ""; strSql = "select UserPwd from UserTable where UserName = '******'"; SqlDataReader dr = db.DB_Red(strSql); if (dr.Read()) { if (strUserPwd.Equals(db.DB_C(strSql, 0))) { Form1 frm1 = new Form1(); frm1.Show(); this.Hide(); } else { MessageBox.Show("密码错误!", "警告"); return; } } else { MessageBox.Show("用户名不存在!", "警告"); return; } }
private void buttonformGYSAdd_Click(object sender, EventArgs e) { //定义变量 string strGYS = ""; string strFoodName = ""; decimal strDM = 0; decimal strDiscountL = 0; decimal strQuantity = 0; string strFoodType = ""; string strText = ""; //校验 if (textBoxformGYSFoodName.Text.Trim() == "") { MessageBox.Show("商品名不能为空!"); textBoxformGYSFoodName.Focus(); return; } if (Validator.IsNumber(textBoxformGYSDM.Text.Trim()) == false) { MessageBox.Show("请输入单价并输入数值型数!"); textBoxformGYSDM.Focus(); return; } if (Validator.IsNumber(textBoxformGYSDiscountL.Text.Trim()) == false) { MessageBox.Show("请输入折扣率并输入数值型数!"); textBoxformGYSDiscountL.Focus(); return; } if (Validator.IsNumber(textBoxformGYSQuantity.Text.Trim()) == false) { MessageBox.Show("请输入货存并输入数值型数!"); textBoxformGYSQuantity.Focus(); return; } // 获取数据 strGYS = textBoxformGYS.Text.Trim(); strFoodName = textBoxformGYSFoodName.Text.Trim(); strFoodType = comboBoxformGYSFoodType.Text; strDM = Convert.ToDecimal(textBoxformGYSDM.Text.Trim()); strDiscountL = Convert.ToDecimal(textBoxformGYSDiscountL.Text.Trim()); strQuantity = Convert.ToDecimal(textBoxformGYSQuantity.Text.Trim()); strText = textBoxformGYSText.Text.Trim(); string strSql = "select * from GYSAllFood where GYSFoodName = '" + strFoodName + "' and GYS = '" + strGYS + "'"; SqlDataReader dr = db.DB_Red(strSql); if (dr.Read()) { MessageBox.Show("添加失败,该供应商已拥有此商品!", "警告"); dr.Close(); return; } else { string strSql1 = "insert into GYSAllFood values('" + strGYS + "','" + strFoodName + "','" + strFoodType + "','" + strDM + "','" + strDiscountL + "','" + strQuantity + "','" + strText + "')"; try { db.DB_ZSG(strSql1); MessageBox.Show("添加成功!", "添加"); this.Close(); } catch { MessageBox.Show("添加失败,请重新添加", "警告"); return; } } }