private static IncomingFormEntity Get(string id, Database db, DbTransaction trans) { var sql = string.Format("select {0} from incoming_form {1} where id=@p_id", COLUMN_SQL, TransHelper.UpdateLock(trans)); if (db == null) { db = DatabaseFactory.CreateDatabase(); } var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, id); IncomingFormEntity entity = null; using (var reader = (trans == null ? db.ExecuteReader(dc) : db.ExecuteReader(dc, trans))) { while (reader.Read()) { entity = new IncomingFormEntity(); entity.Init(reader); break; } } return(entity); }
private static void CreateInventory(IncomingFormEntity form, Database db, DbTransaction trans) { var goodsSerial = GoodsSerialRepository.Get(form.SerialId, db, trans); var barcodes = GoodsSerialRepository.GetBarcodes(form.SerialId, db, trans); var product = ProductRepository.Get(goodsSerial.ProductId); var inventory = new GoodsInventoryEntity { SerialId = goodsSerial.Id, BatchNo = goodsSerial.BatchNo, ProductId = goodsSerial.ProductId, StoreroomId = form.StoreroomId, ExpiredDate = goodsSerial.ExpiredDate.Value, HospitalId = goodsSerial.HospitalId, VendorId = goodsSerial.VendorId, OriginalCount = form.IncomingCount, SplitCount = 0, UsableCount = form.IncomingCount, //goodsSerial.NeedSplit ? 0 : form.IncomingCount, GrantedCount = 0, CreatedId = form.ConfirmedId, CreatedTime = form.ConfirmedTime }; inventory.ApplyCount = inventory.UsableCount * product.MiniPackageCount; GoodsInventoryRepository.Create(inventory, db, trans); AllocateBarcodes(barcodes, inventory, product, db, trans); }
public static void Pass(IncomingFormEntity form) { var db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { Update(form, db, trans); CreateInventory(form, db, trans); UpdateOrderStatus(form.Id, db, trans); trans.Commit(); } catch { trans.Rollback(); throw; } } } }
private static void Update(IncomingFormEntity form, Database db, DbTransaction trans) { var sql = @"update incoming_form set storeroom_id=@p_storeroom_id,is_confirmed=@p_is_confirmed,confirmed_id=@p_confirmed_id,confirmed_time=@p_confirmed_time where id=@p_id"; var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, form.Id); db.AddInParameter(dc, "p_storeroom_id", DbType.String, form.StoreroomId); db.AddInParameter(dc, "p_is_confirmed", DbType.String, form.IsConfirmed); db.AddInParameter(dc, "p_confirmed_id", DbType.String, form.ConfirmedId); db.AddInParameter(dc, "p_confirmed_time", DbType.String, form.ConfirmedTime); db.ExecuteNonQuery(dc, trans); }
public static IncomingFormEntity GetBySerialId(string serialId, Database db, DbTransaction trans) { var sql = string.Format("select {0} from incoming_form where serial_id=@p_serial_id", COLUMN_SQL); var cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "p_serial_id", DbType.String, serialId); using (var reader = db.ExecuteReader(cmd, trans)) { if (reader.Read()) { var entity = new IncomingFormEntity(); entity.Init(reader); return(entity); } } return(null); }
internal static void Create(IncomingFormEntity entity, Database db, DbTransaction trans) { var sql = @"insert into incoming_form ( id,order_id,order_form_no,order_detail_id,apply_unit_id,serial_id,product_id,incoming_count, hospital_id,vendor_id,is_confirmed,created_id,created_time ) values( @p_id,@p_order_id,@p_order_form_no,@p_order_detail_id,@p_apply_unit_id,@p_serial_id,@p_product_id,@p_incoming_count, @p_hospital_id,@p_vendor_id,@p_is_confirmed,@p_created_id,@p_created_time )"; entity.Id = Guid.NewGuid().ToString(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, entity.Id); db.AddInParameter(dc, "p_order_id", DbType.String, entity.OrderId); db.AddInParameter(dc, "p_order_form_no", DbType.Int32, entity.OrderFormNo); db.AddInParameter(dc, "p_order_detail_id", DbType.String, entity.OrderDetailId); db.AddInParameter(dc, "p_apply_unit_id", DbType.String, entity.ApplyUnitId); db.AddInParameter(dc, "p_serial_id", DbType.String, entity.SerialId); db.AddInParameter(dc, "p_product_id", DbType.String, entity.ProductId); db.AddInParameter(dc, "p_incoming_count", DbType.Int32, entity.IncomingCount); db.AddInParameter(dc, "p_hospital_id", DbType.String, entity.HospitalId); db.AddInParameter(dc, "p_vendor_id", DbType.String, entity.VendorId); db.AddInParameter(dc, "p_is_confirmed", DbType.Boolean, entity.IsConfirmed); db.AddInParameter(dc, "p_created_id", DbType.String, entity.CreatedId); db.AddInParameter(dc, "p_created_time", DbType.DateTime, entity.CreatedTime); db.ExecuteNonQuery(dc, trans); GoodsSerialFormRepository.FlowNextForm(new GoodsSerialFormEntity { SerialId = entity.SerialId, FormId = entity.Id, FormKind = FormKind.Incoming, CreatedId = entity.CreatedId, CreatedTime = entity.CreatedTime }, db, trans); }
private static string CreateIncomingForm(ReceiveFormEntity form, ReceiveFormItemEntity formItem, Database db, DbTransaction trans) { var incoming = new IncomingFormEntity { OrderId = form.OrderId, OrderFormNo = form.OrderFormNo, OrderDetailId = form.OrderDetailId, ApplyUnitId = form.ApplyUnitId, SerialId = formItem.SerialId, ProductId = form.ProductId, IncomingCount = formItem.ReceivedCount, HospitalId = form.HospitalId, VendorId = form.VendorId, IsConfirmed = false, CreatedId = formItem.ConfirmedId, CreatedTime = formItem.ConfirmedTime }; IncomingFormRepository.Create(incoming, db, trans); return(incoming.Id); }
private static string SaveIncomingForm(InspectionFormEntity entity, int scanCount, string userId, Database db, DbTransaction trans) { var incoming = new IncomingFormEntity { Id = Guid.NewGuid().ToString(), IncomingCount = scanCount, OrderId = entity.OrderId, OrderFormNo = entity.OrderFormNo, OrderDetailId = entity.OrderDetailId, HospitalId = entity.HospitalId, ApplyUnitId = entity.ApplyUnitId, VendorId = entity.VendorId, ProductId = entity.ProductId, IsConfirmed = entity.ScanOver, CreatedId = userId, CreatedTime = DateTime.Now }; IncomingFormRepository.Create(incoming, db, trans); return(incoming.Id); }
//internal static void Pass(IncomingFormEntity form, Database db, DbTransaction trans) //{ // Update(form, db, trans); // CreateInventory(form, db, trans); //} public static void Pass(IncomingFormEntity form, Database db, DbTransaction trans) { Update(form, db, trans); CreateInventory(form, db, trans); UpdateOrderStatus(form.Id, db, trans); }
public void Pass(IncomingFormEntity form) { IncomingFormRepository.Pass(form); }
public void Pass(IncomingFormEntity form, Database db, DbTransaction trans) { IncomingFormRepository.Pass(form, db, trans); }