}// end if #endregion #region//修改产品信息,返回值, 1表示成功,0表示失败 public int tbProductionUpdate(tbProductionClass Customer) { int intFalg = 0; try { tbDai = new tbDaiConnection(); oledCon = tbDai.OledCon(); string strAdd = "update tb_Production set "; strAdd += "ProName='" + Customer.strProName + "',SellPrice='" + Customer.dePrice + "',ProPath='" + Customer.strProPath + "',"; strAdd += "ProManufacturer='" + Customer.strProManufacturer + "',ProPOV='" + Customer.intProPOV + "',ProExplain ='" + Customer.strProExplain + "',"; strAdd += "ProRegDate='" + Customer.daProRegDate + "',ProOperator='" + Customer.strProOperator + "',"; strAdd += "ProMemo='" + Customer.strProMemo + "',ProFalg='" + Customer.ProFalg + "' where ProNo='" + Customer.strProNo + "'"; oledCmd = new OleDbCommand(strAdd, oledCon); if (oledCmd.ExecuteNonQuery() != 0) { intFalg = 1;//添加成功 } return(intFalg); } catch (Exception ee) { return(intFalg); } }// end if
public int tbProductionAdd(tbProductionClass Customer) { int intFalg = 0; try { tbDai = new tbDaiConnection(); oledCon = tbDai.OledCon(); string strAdd = "insert into tb_Production "; strAdd += "values('" + Customer.strProNo + "','" + Customer.strProName + "','" + Customer.dePrice + "','" + Customer.strProPath + "',"; strAdd += "'" + Customer.strProManufacturer + "','" + Customer.intProPOV + "','" + Customer.strProExplain + "',"; strAdd += "'" + Customer.daProRegDate + "','" + Customer.strProOperator + "',"; strAdd += "'" + Customer.strProMemo + "','" + Customer.ProFalg + "')"; oledCmd = new OleDbCommand(strAdd, oledCon); if (oledCmd.ExecuteNonQuery() != 0) { intFalg = 1;//添加成功 } return(intFalg); } catch (Exception ee) { return(intFalg); } }// end if
}// end if #endregion #region//查询产品信息,返回,OleDbDataReader对象 public OleDbDataReader tbProductionSecarf(tbProductionClass Customer) { string strSecarf = null; try { tbDai = new tbDaiConnection(); oledCon = tbDai.OledCon(); strSecarf = "select * from tb_Production where ProNo='" + Customer.strProNo + "'"; oledCmd = new OleDbCommand(strSecarf, oledCon); oledDr = oledCmd.ExecuteReader();// return(oledDr); } catch (Exception ee) { return(oledDr); } }// end if
}// end if #endregion #region//删除产品信息,返回值, 1表示成功,0表示失败 public int tbProductionDelete(tbProductionClass Customer) { int intFalg = 0; try { tbDai = new tbDaiConnection(); oledCon = tbDai.OledCon(); string strAdd = "update tb_Production set "; strAdd += "ProFalg='" + Customer.ProFalg + "' where ProNo='" + Customer.strProNo + "'"; oledCmd = new OleDbCommand(strAdd, oledCon); if (oledCmd.ExecuteNonQuery() != 0) { intFalg = 1;//添加成功 } return(intFalg); } catch (Exception ee) { return(intFalg); } }// end if
private void bntOK_Click(object sender, EventArgs e) { if (txtProNo.Text == "") { MessageBox.Show("商品编号不能为空!", "提示"); txtProNo.Focus(); return; } if (txtProName.Text == "") { MessageBox.Show("商品名称不能为空!", "提示"); txtProName.Focus(); return; } if (txtSellPrice.Text == "") { MessageBox.Show("商品单价不能为空!", "提示"); txtSellPrice.Focus(); return; } if (txtProPath.Text == "") { MessageBox.Show("商品类别不能为空!", "提示"); txtProPath.Focus(); return; } if (txtProOperator.Text == "") { MessageBox.Show("经办人不能为空!", "提示"); txtProOperator.Focus(); return; } tbProductionClass tbClass = new tbProductionClass(); tbClass.strProNo = txtProNo.Text; tbClass.strProName = txtProName.Text; tbClass.dePrice = Convert.ToDecimal(txtSellPrice.Text); tbClass.strProPath = txtProPath.Text; tbClass.strProManufacturer = txtProManufacturer.Text; if (txtProPOV.Text != "") { tbClass.intProPOV = Convert.ToInt32(txtProPOV.Text.Trim()); } tbClass.strProExplain = txtProExplain.Text; tbClass.daProRegDate = DateTime.Now; tbClass.strProOperator = txtProOperator.Text; tbClass.strProMemo = txtProMemo.Text; tbClass.ProFalg = "0"; int intResult = tbmenthod.tbProductionAdd(tbClass); if (intResult == 1) { MessageBox.Show("添加成功!"); if (intFalg == 1) { frmProd prod = (frmProd)this.Owner; tbmenthod.filltProd(prod.treeView1, prod.imageList1); this.Close(); } this.Close(); } else { MessageBox.Show("添加失败!"); this.Close(); } }