private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(id.Text)) { MessageBox.Show("你还没有选择任何记录"); } else { //通过产品名称,查询产品id int pid = Myhelper.Getpidbyname(pnamet.Text); //获取入库产品的剩余库存 string sqlstock = string.Format("select [stock] from [product] where [id] = '{0}'", pid); int systock = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.constr, CommandType.Text, sqlstock)); //if (Convert.ToInt32(numbert.Text) > systock) //{ // MessageBox.Show("库存不足!"); //} //else //{ string spnamett = spnamet.Text; string sqlsid = string.Format("select [id] from [sup] where [name] = '{0}'", spnamett); //获取供应商id int spid = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.constr, CommandType.Text, sqlsid)); string time = DateTime.Now.ToLongDateString().ToString(); //获取当前时间 string sql = string.Format("update [in] set [number] = '{0}',[pname] = '{1}',[spname] = '{2}',[intime] = '{3}',[spid] = '{4}',[note] = '{5}' where [id] = '{6}'", numbert.Text, pnamet.Text, spnamet.Text, time, spid, notet.Text, id.Text); int row = SqlHelper.ExecuteNonQuery(SqlHelper.constr, CommandType.Text, sql); if (row == 1) { int newnumber = Convert.ToInt32(numbert.Text); int kucun = newnumber - number; systock = systock + kucun; string sqlup = string.Format("update [product] set [stock] = '{0}' where [id] = '{1}'", systock, pid); int rows = Convert.ToInt32(SqlHelper.ExecuteNonQuery(SqlHelper.constr, CommandType.Text, sqlup)); if (rows == 1) { MessageBox.Show("修改成功"); inmerre(); } else { MessageBox.Show("这条记录真的存在吗?"); } //} } } }
private void deletebut_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(ids.Text) == false) { int pids = Myhelper.Getpidbyname(pnamett.Text); string sqls = string.Format("update [product] set [stock] = [stock] - '{0}' where [id]='{1}'", numbertt.Text, pids); int rows = SqlHelper.ExecuteNonQuery(SqlHelper.constr, CommandType.Text, sqls); if (rows == 1) { string sql = string.Format("delete from [in] where [id] = '{0}'", ids.Text); int row = SqlHelper.ExecuteNonQuery(SqlHelper.constr, CommandType.Text, sql); if (row == 1) { MessageBox.Show("删除成功"); this.Clear(); } } } else { MessageBox.Show("你没有选中任何行"); } }
private void inbut_Click(object sender, EventArgs e) { if (number.Value != 0 & string.IsNullOrWhiteSpace(spname.Text) == false & string.IsNullOrWhiteSpace(pname.Text) == false) { string time = Myhelper.Gettime(); int spid = Myhelper.Getspidbyname(spname.Text); string sql = string.Format("insert into [in] (number,pname,spname,spid,intime,uid) values('{0}','{1}','{2}','{3}','{4}','{5}')", number.Text, pname.Text, spname.Text, spid, time, user.uid); int rows = SqlHelper.ExecuteNonQuery(SqlHelper.constr, CommandType.Text, sql); if (rows == 1) { int pid = Myhelper.Getpidbyname(pname.Text); int row = Myhelper.Upstock_sql(pid, Convert.ToInt32(number.Text)); if (row == 1) { MessageBox.Show("入库成功"); this.inTableAdapter.Fill(this.wMSDataSet._in); } } } else { MessageBox.Show("出库失败,请检查:\n1:入库数量是否为'0'\n2:供应商名称与产品名称是否正确填写"); } }
private void backwarning_DoWork(object sender, DoWorkEventArgs e) { Myhelper.Speak("你真的要那么做吗?"); }
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Myhelper.Speak("现在你又想成为谁呢?"); }
private void backlogin_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Myhelper.Speak(user.uname + "!欢迎使用仓库管理系统!"); }
private void backspeak_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Myhelper.Speak(hi.Text + ",请问你是谁?"); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { Myhelper.Speak("测试,后台播放测试 测试1"); }