private int MaxGoodsNO() { string strSql = @"select max(goodsno) from Purchas;"; OleDbCommand cmd = new OleDbCommand(strSql, Foundation.CreateInstance()); object o = cmd.ExecuteScalar(); if (o == DBNull.Value) { return(0); } else { return(Convert.ToInt32(o)); } }
public bool Save() { string strSql = @"insert into Recording(recordno,recorddatetime,charge,operman,remarks) "; strSql += @"values(@recordno,@recorddatetime,@charge,@operman,@remarks);"; OleDbCommand cmd = new OleDbCommand(strSql, Foundation.CreateInstance()); cmd.Parameters.AddWithValue("@recordno", RecordNO); cmd.Parameters.AddWithValue("@recorddatetime", RecordDateTime); cmd.Parameters.AddWithValue("@charge", Charge); cmd.Parameters.AddWithValue("@operman", Operman); cmd.Parameters.AddWithValue("@remarks", Remarks); return(cmd.ExecuteNonQuery() > 0); }
private void MaxNO() { string strSql = @"select max(sellno) from Sell;"; OleDbCommand cmd = new OleDbCommand(strSql, Foundation.CreateInstance()); object o = cmd.ExecuteScalar(); if (o == DBNull.Value) { this.SellNO = 1; } else { this.SellNO = 1 + Convert.ToInt32(o); } }
public bool Save() { OleDbConnection conn = Foundation.CreateInstance(); OleDbTransaction trans = conn.BeginTransaction(); string strSql = @"insert into Sell(sellno,outtime,goodsno,outcount,outprice,remarks,orderno,useing) "; strSql += "values(@sellno,@outtime,@goodsno,@outcount,@outprice,@remarks,@orderno,@useing);"; OleDbCommand cmd = new OleDbCommand(strSql, conn); cmd.Parameters.AddWithValue("@sellno", SellNO); cmd.Parameters.AddWithValue("@outtime", OutTime); cmd.Parameters.AddWithValue("@goodsno", GoodsNO); cmd.Parameters.AddWithValue("@outcount", OutCount); cmd.Parameters.AddWithValue("@outprice", OutPrice); cmd.Parameters.AddWithValue("@remarks", Remarks); cmd.Parameters.AddWithValue("@orderno", OrderNO); cmd.Parameters.AddWithValue("@useing", 1); cmd.Transaction = trans; string strSql2 = @"update purchas set outcount = outcount + @outcount where goodsno=@goodsno;"; OleDbCommand cmd2 = new OleDbCommand(strSql2, conn); cmd2.Parameters.AddWithValue("@outcount", OutCount); cmd2.Parameters.AddWithValue("@goodsno", GoodsNO); cmd2.Transaction = trans; try { cmd.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); trans.Commit(); return(true); } catch (System.Exception err) { Console.Write(err.Message + err.StackTrace); trans.Rollback(); return(false); } }
public bool Update() { string strSql = @"update Purchas set goodsname=@goodsname,goodscode=@goodscode,incount=@incount,inprice=@inprice,remarks=@remarks,fixprice=@fixprice,unitno=@unitno,typeno=@typeno,providerno=@providerno where goodsno=@goodsno;"; OleDbCommand cmd = new OleDbCommand(strSql, Foundation.CreateInstance()); cmd.Parameters.AddWithValue("@goodsname", GoodsName); cmd.Parameters.AddWithValue("@goodscode", GoodsCode); cmd.Parameters.AddWithValue("@incount", InCount); cmd.Parameters.AddWithValue("@inprice", InPrice); cmd.Parameters.AddWithValue("@remarks", Remarks); cmd.Parameters.AddWithValue("@fixprice", FixPrice); cmd.Parameters.AddWithValue("@unitno", UnitNO); cmd.Parameters.AddWithValue("@typeno", TypeNO); cmd.Parameters.AddWithValue("@providerno", ProviderNO); cmd.Parameters.AddWithValue("@goodsno", GoodsNO); return(cmd.ExecuteNonQuery() > 0); }
public bool Save() { string strSql = @"insert into Purchas(goodsno,intime,goodsname,goodscode,unitno,typeno,providerno,incount,inprice,outcount,remarks,fixprice) "; strSql += @"values(@goodsno,@intime,@goodsname,@goodscode,@unitno,@typeno,@providerno,@incount,@inprice,@outcount,@remarks,@fixprice);"; OleDbCommand cmd = new OleDbCommand(strSql, Foundation.CreateInstance()); cmd.Parameters.AddWithValue("@goodsno", GoodsNO); cmd.Parameters.AddWithValue("@intime", InTime); cmd.Parameters.AddWithValue("@goodsname", GoodsName); cmd.Parameters.AddWithValue("@goodscode", GoodsCode); cmd.Parameters.AddWithValue("@unitno", UnitNO); cmd.Parameters.AddWithValue("@typeno", TypeNO); cmd.Parameters.AddWithValue("@providerno", ProviderNO); cmd.Parameters.AddWithValue("@incount", InCount); cmd.Parameters.AddWithValue("@inprice", InPrice); cmd.Parameters.AddWithValue("@outcount", 0); cmd.Parameters.AddWithValue("@remarks", Remarks); cmd.Parameters.AddWithValue("@fixprice", FixPrice); return(cmd.ExecuteNonQuery() > 0); }