public SellGoodsForm(string EmpID) : this() { txtEmpID.Text = EmpID; sellGoods = new tb_SellGoods(); sellGoodsMenthod = new tb_SellGoodsMenthod(); sellGoodsMenthod.Find(dataGridView1); }
public int tb_SellGoodsUpdate(tb_SellGoods tbChGood) { int intFalg = 0; try { string str_Add = "update tb_SellGoods set "; str_Add += "KcID='" + tbChGood.strKcID + "',GoodsID='" + tbChGood.strGoodsID + "',"; str_Add += "EmpId='" + tbChGood.strEmpId + "',GoodsName='" + tbChGood.strGoodsName + "',SellGoodsNum=" + tbChGood.strSellGoodsNum + ","; str_Add += "SellGoodsTime='" + tbChGood.daSellGoodsTime + "',SellPrice=" + tbChGood.deSellPrice + ","; str_Add += "SellNeedPay=" + tbChGood.deSellNeedPay + ",SellHasPay=" + tbChGood.deSellHasPay + ",SellRemark='" + tbChGood.strSellRemark + "',SellFalg=" + tbChGood.intSellFalg + ""; str_Add += " where SellID= '" + tbChGood.strSellID + "'"; getSqlConnection getConnection = new getSqlConnection(); conn = getConnection.GetCon(); cmd = new SqlCommand(str_Add, conn); intFalg = cmd.ExecuteNonQuery(); conn.Dispose(); return(intFalg); } catch (Exception ee) { MessageBox.Show(ee.ToString()); return(intFalg); } }
//添加 public bool Add(tb_SellGoods sellGoods) { //先向销售表中添加记录 string sqlAdd = "insert into tb_SellGoods values( "; sqlAdd += "'" + sellGoods.strSellID + "','" + sellGoods.strGoodsID + "',"; sqlAdd += "'" + sellGoods.strEmpId + "','" + sellGoods.strGoodsName + "'," + sellGoods.strSellGoodsNum + ","; sqlAdd += "'" + sellGoods.daSellGoodsTime + "','" + sellGoods.deSellPrice + "',"; sqlAdd += "'" + sellGoods.deSellNeedPay + "','" + sellGoods.deSellHasPay + "','" + sellGoods.strSellRemark + "'," + sellGoods.intSellFlag + ")"; string sqlQuery = "select * from tb_KcGoods where GoodsID ='" + sellGoods.strGoodsID + "'"; int num; //当前库存数量 try { SqlConnection conn = (new GetSqlConnection()).GetCon(); SqlCommand cmd = new SqlCommand(sqlAdd, conn); cmd.ExecuteNonQuery(); conn.Dispose(); //再减少库存数量 SqlConnection conn1 = (new GetSqlConnection()).GetCon(); SqlCommand cmd1 = new SqlCommand(sqlQuery, conn1); SqlDataReader dataReader = cmd1.ExecuteReader(); dataReader.Read(); num = Convert.ToInt32(dataReader[3]); //获取当前的库存数量 dataReader.Close(); if (num == 0) //当前库存为0,不能添加 { return(false); } num -= sellGoods.strSellGoodsNum; //库存数量减少 string sqlUpdate = "update tb_KcGoods set KcNum = " + num + " where GoodsID ='" + sellGoods.strGoodsID + "'"; SqlConnection conn2 = (new GetSqlConnection()).GetCon(); SqlCommand cmd2 = new SqlCommand(sqlUpdate, conn2); cmd2.ExecuteNonQuery(); conn.Dispose(); return(true); } catch (Exception e) { MessageBox.Show(e.ToString()); return(false); } }
//删除 public bool Delete(tb_SellGoods sellGoods) { string sqlDelete = "update tb_SellGoods set "; sqlDelete += "SellFlag=" + sellGoods.intSellFlag + ""; //修改flag,置删除标记 sqlDelete += " where SellID = '" + sellGoods.strSellID + "'"; try { SqlConnection conn = (new GetSqlConnection()).GetCon(); SqlCommand cmd = new SqlCommand(sqlDelete, conn); cmd.ExecuteNonQuery(); conn.Dispose(); return(true); } catch (Exception e) { MessageBox.Show(e.ToString()); return(false); } }
//修改 public bool Update(tb_SellGoods sellGoods, string pastNum) { string sqlUpdate = "update tb_SellGoods set "; sqlUpdate += "GoodsID='" + sellGoods.strGoodsID + "',"; sqlUpdate += "EmpId='" + sellGoods.strEmpId + "',GoodsName='" + sellGoods.strGoodsName + "',SellGoodsNum=" + sellGoods.strSellGoodsNum + ","; sqlUpdate += "SellGoodsTime='" + sellGoods.daSellGoodsTime + "',SellPrice='" + sellGoods.deSellPrice + "',"; sqlUpdate += "SellNeedPay='" + sellGoods.deSellNeedPay + "',SellHasPay='" + sellGoods.deSellHasPay + "',SellRemark='" + sellGoods.strSellRemark + "',SellFlag=" + sellGoods.intSellFlag + ""; sqlUpdate += " where SellID= '" + sellGoods.strSellID + "'"; string sqlQuery = "select * from tb_KcGoods where GoodsID='" + sellGoods.strGoodsID + "'"; int num; //当前库存数量 int n = Convert.ToInt32(pastNum); //修改前销售记录中的销售数量 try { SqlConnection conn = (new GetSqlConnection()).GetCon(); SqlCommand cmd = new SqlCommand(sqlUpdate, conn); cmd.ExecuteNonQuery(); conn.Dispose(); //修改库存数量 SqlConnection conn1 = (new GetSqlConnection()).GetCon(); SqlCommand cmd1 = new SqlCommand(sqlQuery, conn1); SqlDataReader dataReader = cmd1.ExecuteReader(); dataReader.Read(); num = Convert.ToInt32(dataReader[3]); //获取当前的库存数量 dataReader.Close(); num += n; //加上修改前的销售数量 num -= sellGoods.strSellGoodsNum; //减去修改后的销售数量 string sqlUpdate1 = "update tb_KcGoods set KcNum = " + num + " where GoodsID = '" + sellGoods.strGoodsID + "'"; SqlConnection conn2 = (new GetSqlConnection()).GetCon(); SqlCommand cmd2 = new SqlCommand(sqlUpdate1, conn2); cmd2.ExecuteNonQuery(); conn.Dispose(); return(true); } catch (Exception e) { MessageBox.Show(e.ToString()); return(false); } }
public int tb_SellGoodsAdd(tb_SellGoods tbChGood) { int intFalg = 0; try { string str_Add = "insert into tb_SellGoods values( "; str_Add += "'" + tbChGood.strSellID + "','" + tbChGood.strKcID + "','" + tbChGood.strGoodsID + "',"; str_Add += "'" + tbChGood.strEmpId + "','" + tbChGood.strGoodsName + "','" + tbChGood.strSellGoodsNum + "',"; str_Add += "'" + tbChGood.daSellGoodsTime + "','" + tbChGood.deSellPrice + "',"; str_Add += "'" + tbChGood.deSellNeedPay + "','" + tbChGood.deSellHasPay + "','" + tbChGood.strSellRemark + "'," + tbChGood.intSellFalg + ")"; getSqlConnection getConnection = new getSqlConnection(); conn = getConnection.GetCon(); cmd = new SqlCommand(str_Add, conn); intFalg = cmd.ExecuteNonQuery(); conn.Dispose(); tb_KcGoodsMenthod kc1 = new tb_KcGoodsMenthod(); /*qlddr = kc1.tb_ThGoodsFind1(tbChGood.strGoodsName); * * int ykc = Convert.ToInt32(qlddr["KcNum"]); * MessageBox.Show("sdd"+ykc); * Console.WriteLine(); * * int xkc = ykc - tbChGood.strSellGoodsNum; * tb_KcGoodsMenthod kc2 = new tb_KcGoodsMenthod(); * kc2.tb_KcGoodsUpdate1(tbChGood.strGoodsName, xkc);*/ return(intFalg); } catch (Exception ee) { MessageBox.Show(ee.ToString()); return(intFalg); } }
public int tb_SellGoodsDelete(tb_SellGoods tbChGood) { int intFalg = 0; try { string str_Add = "update tb_SellGoods set "; str_Add += "SellFalg=" + tbChGood.intSellFalg + ""; str_Add += " where SellID= '" + tbChGood.strSellID + "'"; getSqlConnection getConnection = new getSqlConnection(); conn = getConnection.GetCon(); cmd = new SqlCommand(str_Add, conn); intFalg = cmd.ExecuteNonQuery(); conn.Dispose(); return(intFalg); } catch (Exception ee) { MessageBox.Show(ee.ToString()); return(intFalg); } }
public int tb_SellGoodsAdd(tb_SellGoods tbChGood) { int intFalg = 0; try { string str_Add = "insert into tb_SellGoods values( "; str_Add += "'" + tbChGood.strSellID + "','" + tbChGood.strKcID + "','" + tbChGood.strGoodsID + "',"; str_Add += "'" + tbChGood.strEmpId + "','" + tbChGood.strGoodsName + "'," + tbChGood.strSellGoodsNum + ","; str_Add += "'" + tbChGood.daSellGoodsTime + "'," + tbChGood.deSellPrice + ","; str_Add += "" + tbChGood.deSellNeedPay + "," + tbChGood.deSellHasPay + ",'" + tbChGood.strSellRemark + "'," + tbChGood.intSellFalg + ")"; getSqlConnection getConnection = new getSqlConnection(); conn = getConnection.GetCon(); cmd = new SqlCommand(str_Add, conn); intFalg = cmd.ExecuteNonQuery(); conn.Dispose(); return(intFalg); } catch (Exception ee) { MessageBox.Show(ee.ToString()); return(intFalg); } }
public int tb_SellGoodsDelete(tb_SellGoods tbChGood) { int intFalg = 0; return(intFalg); }
public int tb_SellGoodsAdd(tb_SellGoods tbChGood) { int intFalg = 0; return(intFalg); }