protected override bool getRecords(out List <ProductCirculationRecord> records) { records = new List <ProductCirculationRecord>(); int number = this.dataGridView1.RowCount; double num, price, totalPrice, quantityPerPiece; int pieces; bool isQuantityNull = false, isPiecesNull = false; string unit, comment; bool isInputCorrect = true; foreach (DataGridViewRow row in this.dataGridView1.Rows) { object productID = null; int ID = 0; if (ValidateUtility.getLookupValue(row.Cells["product"], out productID) == false || ValidateUtility.getInt(row.Cells["ID"], false, true, out ID) == false || ValidateUtility.getDouble(row.Cells["quantityPerPiece"], false, true, out quantityPerPiece, out isQuantityNull) == false || ValidateUtility.getInt(row.Cells["pieces"], false, true, out pieces, out isPiecesNull) == false || ValidateUtility.getDouble(row.Cells["num"], true, true, out num) == false || ValidateUtility.getString(row.Cells["unit"], false, out unit) == false || ValidateUtility.getDouble(row.Cells["price"], out price) == false || ValidateUtility.getDouble(row.Cells["totalPrice"], out totalPrice) == false || ValidateUtility.getString(row.Cells["comment"], false, out comment) == false) { return(false); } ProductStainlessCirculationRecord record = new ProductStainlessCirculationRecord(); LookupArg arg = ((row.Cells["product"] as DataGridViewLookupCell).EditedValue as LookupArg); record.ProductID = (int)arg.Value; record.ProductName = arg.Text; record.ID = ID; string serial; ValidateUtility.getString(row.Cells["serial"], false, out serial); record.Serial = serial; record.QuantityPerPiece = quantityPerPiece; record.QuantityNull = isQuantityNull; record.Pieces = pieces; record.PiecesNull = isPiecesNull; record.TotalNum = num; record.Unit = unit; record.Price = price; record.TotalPrice = totalPrice; record.Comment = comment; records.Add(record); } return(isInputCorrect); }
//set protected override void setRecord(DataGridViewRow row, ProductCirculationRecord rec) { ProductStainlessCirculationRecord record = rec as ProductStainlessCirculationRecord; row.Cells["ID"].Value = record.ID; row.Cells["product"].Value = new LookupArg(record.ProductID, record.ProductName); row.Cells["serial"].Value = record.Serial; row.Cells["quantityPerPiece"].Value = record.QuantityNull?null:record.QuantityPerPiece.ToString(); row.Cells["pieces"].Value = record.PiecesNull?null:record.Pieces.ToString(); row.Cells["num"].Value = record.TotalNum; row.Cells["unit"].Value = record.Unit; row.Cells["price"].Value = record.Price.ToString(); row.Cells["totalPrice"].Value = record.TotalPrice; row.Cells["comment"].Value = record.Comment; }
public override List <ProductCirculationRecord> FindList(int circulationID) { List <ProductCirculationRecord> records = new List <ProductCirculationRecord>(); string commandText = string.Format("select * from ProductStainlessCirculationRecord, ProductStainless where ProductStainlessCirculationRecord.productID = ProductStainless.ID and circulationID = {0} order by ProductStainlessCirculationRecord.ID", circulationID); DataTable dt = DbHelperAccess.executeQuery(commandText); foreach (DataRow dr in dt.Rows) { bool tempBool = false; ProductStainlessCirculationRecord record = new ProductStainlessCirculationRecord(); record.CirculationID = circulationID; record.ID = (int)dr["ProductStainlessCirculationRecord.ID"]; int pieces; double price, totalPrice, quantityPerPiece; double.TryParse(dr["price"].ToString(), out price); record.Price = price; record.Serial = dr["serial"].ToString(); record.ProductID = (int)dr["ProductStainless.ID"]; record.ProductName = dr["name"].ToString(); ValidateUtility.getDouble(dr, "ProductStainlessCirculationRecord.quantityPerPiece", out quantityPerPiece, out tempBool); record.QuantityPerPiece = quantityPerPiece; record.QuantityNull = tempBool; ValidateUtility.getInt(dr, "pieces", out pieces, out tempBool); record.Pieces = pieces; record.PiecesNull = tempBool; record.Unit = dr["ProductStainlessCirculationRecord.unit"].ToString(); double num; ValidateUtility.getDouble(dr, "totalNum", out num, out tempBool); record.TotalNum = num; ValidateUtility.getDouble(dr, "totalPrice", out totalPrice, out tempBool); record.TotalPrice = totalPrice; record.Comment = dr["ProductStainlessCirculationRecord.comment"].ToString(); records.Add(record); } return(records); }
public int Insert(ProductStainlessCirculationRecord info) { try { //注意这里:quantity不用'',而totalNum用 string commandText = string.Format("insert into ProductStainlessCirculationRecord(productID, quantityPerPiece, pieces, totalNum, unit, price, totalPrice, circulationID, comment) values('{0}', {1}, {2}, '{3}','{4}', '{5}', '{6}', '{7}', '{8}')", info.ProductID, info.QuantityNull ? "NULL" : info.QuantityPerPiece.ToString(), info.PiecesNull ? "NULL" : info.Pieces.ToString(), info.TotalNum, info.Unit, info.Price, info.TotalPrice, info.CirculationID, info.Comment); DbHelperAccess.executeNonQuery(commandText); int recordID = DbHelperAccess.executeMax("ID", "ProductStainlessCirculationRecord"); return(recordID); } catch (Exception ex) { throw ex; } }