using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using FireBirdUtil.SqlUtils; using WeighBusiness.BO; using WeighBusiness.Utils; using WeighBusiness.Utils.SqlUtils; namespace WeighBusiness.BL { public static class UnfinishedBatchBL { private static bool Insert(UnfinishedBatch batch) { string insertSql = InsertUtil.GetInsertSql(TableNames.未完成生产批次, new string[] { "ProductBatch", "LegType" }, new string[] { batch.ProductBatch, batch.LegType.ToString()}); bool success; using (var she = new SqlHelperEx()) { she.CreateTransaction(); she.ExecuteNonQuery(insertSql, out success); if (!success) she.Rollback(); else she.Commit(); } return success; } public static void Delete(string batch) { var sql = SqlUtil.GetDeleteSql(TableNames.未完成生产批次, "where ProductBatch=" + batch); using (var she = new SqlHelperEx()) { bool success; she.CreateTransaction(); she.ExecuteNonQuery(sql, out success); if (!success) she.Rollback(); else she.Commit(); } } public static List GetUnfinishedBatchs() { var sql = "select ProductBatch,LegType from {0}".FormatWith(TableNames.未完成生产批次); var table = SqlHelperEx.DoQuery(sql); if (table.Rows.Count == 0) return null; var batchs = new List(); foreach(DataRow row in table.Rows) { var batch = new UnfinishedBatch(); batch.ProductBatch = (string)row[0]; batch.LegType = row[0].ToString() == "前腿" ? LegType.前腿 : LegType.后腿; batchs.Add(batch); } return batchs; } } }