private static void ArchiveState(GoodsStateEntity goodsState, Database db, DbTransaction trans) { var sql = @"insert into goods_state_archive ( id, barcode, form_id, form_type, state_created_user, state_created_time, state_validate_user, state_validate_time,state_changed_user, state_changed_time ) values ( @p_id, @p_barcode, @p_form_id, @p_form_type, @p_state_created_user, @p_state_created_time, @p_state_validate_user, @p_state_validate_time, @p_state_changed_user, @p_state_changed_time )"; var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, Guid.NewGuid().ToString()); db.AddInParameter(dc, "p_barcode", DbType.String, goodsState.Barcode); db.AddInParameter(dc, "p_form_id", DbType.String, goodsState.FormId); db.AddInParameter(dc, "p_form_type", DbType.Int32, (int)goodsState.FormType); db.AddInParameter(dc, "p_state_created_user", DbType.String, goodsState.StateCreatedUser); db.AddInParameter(dc, "p_state_created_time", DbType.DateTime, goodsState.StateCreateTime); db.AddInParameter(dc, "p_state_validate_user", DbType.String, goodsState.StateValidateUser); db.AddInParameter(dc, "p_state_validate_time", DbType.String, goodsState.StateValidateTime); db.AddInParameter(dc, "p_state_changed_user", DbType.String, goodsState.StateChangedUser); db.AddInParameter(dc, "p_state_changed_time", DbType.DateTime, goodsState.StateChangedTime); db.ExecuteNonQuery(dc, trans); }
public static IList <GoodsStateEntity> QueryInvalid(FormType formType, string vendorId, string hospitalId) { var sql = string.Format(@"select top 30 {0} from goods_state where future_form_id in (select id from dispatch_form where vendor_id=@p_vendor_id and hospital_id=@p_hospital_id and scan_over=0) and future_form_type=@p_future_form_type and future_valid=0", COLUMNS); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_future_form_type", DbType.Int32, (int)formType); db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId); db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId); var list = new List <GoodsStateEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new GoodsStateEntity(); entity.Init(reader); list.Add(entity); } } return(list); }
private static bool ValidateIncoming(GoodsStateEntity current, string hospitalId, out string errorCode) { errorCode = string.Empty; var form = IncomingFormRepository.Get(current.FutureFormId); if (form == null) { errorCode = GoodsStateValidateCodes.FutureFormNotExist; return(false); } if (string.Compare(form.HospitalId, hospitalId, true) != 0) { errorCode = GoodsStateValidateCodes.HospitalNoFutureForm; return(false); } if (!Enum.IsDefined(typeof(FormType), current.FutureFormType) || (FormType)current.FutureFormType != FormType.Incoming) { errorCode = GoodsStateValidateCodes.NotValidState; return(false); } return(true); }
public static void Create(GoodsStateEntity goodsState, Database db, DbTransaction trans) { var sql = @"insert into goods_state( id, barcode, product_id, form_id, form_type, order_form_id, order_form_no, state_created_user, state_created_time, state_validate_user, state_validate_time,state_changed_user, state_changed_time,vendor_id) values(@p_id, @p_barcode, @p_product_id, @p_form_id, @p_form_type, @p_order_form, @p_order_form_no, @p_state_created_user, @p_state_created_time, @p_state_validate_user, @p_state_validate_time,@p_state_changed_user, @p_state_changed_time,@p_vendor_id)"; var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, Guid.NewGuid().ToString()); db.AddInParameter(dc, "p_barcode", DbType.String, goodsState.Barcode); db.AddInParameter(dc, "p_product_id", DbType.String, goodsState.ProductId); db.AddInParameter(dc, "p_order_form", DbType.String, goodsState.OrderFormId); db.AddInParameter(dc, "p_order_form_no", DbType.Int32, goodsState.OrderFormNo); db.AddInParameter(dc, "p_form_id", DbType.String, goodsState.FormId); db.AddInParameter(dc, "p_form_type", DbType.Int32, (int)goodsState.FormType); db.AddInParameter(dc, "p_state_created_user", DbType.String, goodsState.StateCreatedUser); db.AddInParameter(dc, "p_state_created_time", DbType.DateTime, goodsState.StateCreateTime); db.AddInParameter(dc, "p_state_validate_user", DbType.String, goodsState.StateValidateUser); db.AddInParameter(dc, "p_state_validate_time", DbType.DateTime, goodsState.StateValidateTime); db.AddInParameter(dc, "p_state_changed_user", DbType.String, goodsState.StateChangedUser); db.AddInParameter(dc, "p_state_changed_time", DbType.DateTime, goodsState.StateChangedTime); db.AddInParameter(dc, "p_vendor_id", DbType.String, goodsState.VendorId); db.ExecuteNonQuery(dc, trans); ArchiveState(goodsState, db, trans); }
private static bool ValidateReturn(GoodsStateEntity current, string hospitalId, string vendorId, out string errorCode) { errorCode = string.Empty; var orderForm = OrderFormRepository.Get(current.OrderFormId); if (string.Compare(orderForm.HospitalId, hospitalId, false) != 0) { errorCode = GoodsStateValidateCodes.HospitalNoFutureForm; return(false); } if (!string.IsNullOrEmpty(current.FormId) && (current.FormType == FormType.Dispatch || current.FormType == FormType.Receive || current.FormType == FormType.Inspection || current.FormType == FormType.Incoming)) { return(true); } if (string.Compare(orderForm.VendorId, vendorId, true) != 0) { errorCode = GoodsStateValidateCodes.VendorNoFutureForm; return(false); } errorCode = GoodsStateValidateCodes.NotValidState; return(false); }
public static void Create(int baseBarcode, int count, GoodsStateEntity baseState, Database db, DbTransaction trans) { var sql = @"insert into goods_state( id, barcode, product_id, order_form_id, order_form_no, future_form_id, future_form_type, future_created_user, future_created_time, vendor_id) values(@p_id, @p_barcode, @p_product_id, @p_order_form, @p_order_form_no, @p_future_form_id, @p_future_form_type, @p_future_created_user, @p_future_created_time,@p_vendor_id)"; for (var i = 0; i < count; i++) { var barcode = FormatBarcode(baseBarcode + i); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, Guid.NewGuid().ToString()); db.AddInParameter(dc, "p_barcode", DbType.String, barcode); db.AddInParameter(dc, "p_product_id", DbType.String, baseState.ProductId); db.AddInParameter(dc, "p_order_form", DbType.String, baseState.OrderFormId); db.AddInParameter(dc, "p_order_form_no", DbType.Int32, baseState.OrderFormNo); db.AddInParameter(dc, "p_future_form_id", DbType.String, baseState.FutureFormId); db.AddInParameter(dc, "p_future_form_type", DbType.Int32, (int)baseState.FutureFormType); db.AddInParameter(dc, "p_future_created_user", DbType.String, baseState.FutureCreatedUser); db.AddInParameter(dc, "p_future_created_time", DbType.DateTime, baseState.FutureCreatedTime); db.AddInParameter(dc, "p_vendor_id", DbType.String, baseState.VendorId); db.ExecuteNonQuery(dc, trans); } }
private static bool ValidateFutureState(string barcode, FormType formType, out GoodsStateEntity entity, out string errorCode) { entity = null; errorCode = string.Empty; if (string.IsNullOrEmpty(barcode)) { errorCode = GoodsStateValidateCodes.BarcodeNotExist; return(false); } entity = GetByBarcode(barcode); if (entity == null) { errorCode = GoodsStateValidateCodes.BarcodeNotExist; return(false); } //if (formType != FormType.MoveOut && formType != FormType.Return && string.IsNullOrEmpty(entity.FutureFormId)) //{ // errorCode = GoodsStateValidateCodes.NotValidState; // return false; //} return(true); }
private static bool ValidateSplitting(GoodsStateEntity current, string hospitalId, out string errorCode) { errorCode = string.Empty; return(true); //if(!string.IsNullOrEmpty(current.FormId) && current.FormType == FormType.Incoming) //{ // return true; //} //errorCode = GoodsStateValidateCodes.NotValidState; //return false; }
private static bool ValidateApply(GoodsStateEntity current, string hospitalId, out string errorCode) { errorCode = string.Empty; if (!Enum.IsDefined(typeof(FormType), current.FormType) || (FormType)current.FormType != FormType.Incoming) { errorCode = GoodsStateValidateCodes.NotValidState; return(false); } return(true); }
private static bool ValidateMovein(GoodsStateEntity current, string hospitalId, out string errorCode) { errorCode = string.Empty; if (!string.IsNullOrEmpty(current.FormId) && (current.FormType == FormType.MoveOut)) { return(true); } var orderForm = OrderFormRepository.Get(current.OrderFormId); if (string.Compare(orderForm.HospitalId, hospitalId, false) != 0) { errorCode = GoodsStateValidateCodes.HospitalNoFutureForm; return(false); } errorCode = GoodsStateValidateCodes.NotValidState; return(false); }
public static GoodsStateEntity GetByBarcode(string barcode) { var sql = string.Format("select {0} from goods_state where barcode=@p_barcode", COLUMNS); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_barcode", DbType.String, barcode); using (var reader = db.ExecuteReader(dc)) { if (reader.Read()) { var entity = new GoodsStateEntity(); entity.Init(reader); return(entity); } } return(null); }