public static GoodsFlowEntity GetByBarcode(GoodsFlowValidType validType, string barcode, string vendorId, string hospitalId) { var sql = string.Format(@"select {0} from goods_flow where 1=1 and barcode=@p_barcode {1}", COLUMN_SQL, GetValidTypeSql(validType)); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); if (validType == GoodsFlowValidType.Dispatch) { db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId); } db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId); db.AddInParameter(dc, "p_barcode", DbType.String, barcode); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new GoodsFlowEntity(); entity.Init(reader); return(entity); } } return(null); }
public static IList <GoodsFlowEntity> QueryWaitingValid(GoodsFlowValidType validType, int formNo, bool isValid, string vendorId, string hospitalId) { var sql = string.Format(@"select top 30 {0} from goods_flow where 1=1 {1} order by barcode", COLUMN_SQL, GetFormNoSql(validType, true)); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_form_no", DbType.Int32, formNo); if (validType == GoodsFlowValidType.Dispatch) { db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId); } db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId); AddValidValue(db, dc, validType, isValid); var list = new List <GoodsFlowEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new GoodsFlowEntity(); entity.Init(reader); list.Add(entity); } } return(list); }
private static string GetSumWhere(GoodsFlowValidType validType) { string sql; switch (validType) { case GoodsFlowValidType.Incoming: sql = " and incoming_valid=1 and incoming_form=@p_form"; break; case GoodsFlowValidType.Inspection: sql = " and inspection_valid=1 and inspection_form=@p_form"; break; case GoodsFlowValidType.Receive: sql = " and receive_valid=1 and receive_form=@p_form"; break; default: sql = " and dispatch_valid=1 and dispatch_form=@p_form"; break; } return(sql); }
public static void BatchCancelValid(GoodsFlowValidType validType, string formId, string userId) { var sql = string.Format("update goods_flow set {0} where 1=1 {1}", GetUpdateValidSql(validType), GetFormIdWhere(validType)); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_is_valid", DbType.Boolean, false); db.AddInParameter(dc, "p_user", DbType.String, userId); db.AddInParameter(dc, "p_datetime", DbType.DateTime, DateTime.Now); db.AddInParameter(dc, "p_form_id", DbType.String, formId); db.ExecuteNonQuery(dc); }
private static string GetUpdateValidSql(GoodsFlowValidType validType) { var sql = string.Empty; switch (validType) { case GoodsFlowValidType.Receive: sql = "receive_valid=@p_is_valid, receive_user=@p_user, receive_time=@p_datetime"; break; case GoodsFlowValidType.Dispatch: default: sql = "dispatch_valid=@p_is_valid, dispatch_user=@p_user, dispatch_time=@p_datetime"; break; } return(sql); }
private static string GetFormIdWhere(GoodsFlowValidType validType) { var sql = string.Empty; switch (validType) { case GoodsFlowValidType.Receive: sql = " and receive_form = @p_form_id"; break; case GoodsFlowValidType.Dispatch: default: sql = " and dispatch_form = @p_form_id"; break; } return(sql); }
private static string GetValidTypeSql(GoodsFlowValidType validType) { var sql = string.Empty; switch (validType) { case GoodsFlowValidType.Receive: sql = " and dispatch_valid=1 and receive_form in (select id from receive_form where hospital_id=@p_hospital_id and scan_over=0)"; break; case GoodsFlowValidType.Dispatch: default: sql = " and dispatch_form in (select id from dispatch_form where vendor_id=@p_vendor_id and hospital_id=@p_hospital_id and scan_over=0)"; break; } return(sql); }
private static void AddValidValue(Database db, DbCommand dc, GoodsFlowValidType validType, bool isValid) { string name; switch (validType) { case GoodsFlowValidType.Receive: name = "p_receive_valid"; break; case GoodsFlowValidType.Dispatch: default: name = "p_dispatch_valid"; break; } db.AddInParameter(dc, name, DbType.Boolean, isValid); }
private static string GetValidColumn(GoodsFlowValidType validType) { var name = string.Empty; switch (validType) { case GoodsFlowValidType.Receive: name = "receive_valid"; break; case GoodsFlowValidType.Dispatch: default: name = "dispatch_valid"; break; } return(name); }
public static void Valid(GoodsFlowValidType validType, string barcode, string userId, string vendorId, string hospitalId) { var sql = string.Format("update goods_flow set {0} where barcode=@p_barcode {1}", GetUpdateValidSql(validType), GetValidTypeSql(validType)); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_barcode", DbType.String, barcode); db.AddInParameter(dc, "p_is_valid", DbType.Boolean, true); db.AddInParameter(dc, "p_user", DbType.String, userId); db.AddInParameter(dc, "p_datetime", DbType.DateTime, DateTime.Now); if (validType == GoodsFlowValidType.Dispatch) { db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId); } db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId); db.ExecuteNonQuery(dc); }
private static string GetFormNoSql(GoodsFlowValidType validType, bool includeFormNo) { var sql = string.Empty; switch (validType) { case GoodsFlowValidType.Receive: sql = " and dispatch_valid=1 and receive_valid=@p_receive_valid and receive_form in (select id from receive_form where 1=1 {0} and hospital_id=@p_hospital_id and scan_over=0)"; break; case GoodsFlowValidType.Dispatch: default: sql = " and dispatch_valid=@p_dispatch_valid and dispatch_form in (select id from dispatch_form where 1=1 {0} and vendor_id=@p_vendor_id and hospital_id=@p_hospital_id and scan_over=0)"; break; } sql = string.Format(sql, includeFormNo ? " and order_form_no = @p_form_no " : ""); return(sql); }
public static int SumValid(GoodsFlowValidType validType, string validFormId) { var sql = "select count(*) from goods_flow where 1=1 " + GetSumWhere(validType); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_form", DbType.String, validFormId); int count = 0; using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { count = Convert.ToInt32(reader[0]); break; } } return(count); }
public void BatchCancelValid(GoodsFlowValidType validType, string id, string userId) { GoodsFlowRepository.BatchCancelValid(validType, id, userId); }
public GoodsFlowEntity GetByBarcode(GoodsFlowValidType validType, string barcode, string vendorId, string hospitalId) { return(GoodsFlowRepository.GetByBarcode(validType, barcode, vendorId, hospitalId)); }
public GoodsFlowEntity GetByBarcode(GoodsFlowValidType validType, string barcode, string hospitalId) { return(this.GetByBarcode(validType, barcode, null, hospitalId)); }
public int SumValid(GoodsFlowValidType validType, string formId) { return(GoodsFlowRepository.SumValid(validType, formId)); }
public void Valid(GoodsFlowValidType validType, string barcode, string userId, string vendorId, string hospitalId) { GoodsFlowRepository.Valid(validType, barcode, userId, vendorId, hospitalId); }
public void CancelValid(GoodsFlowValidType validType, string barcode, string userId, string hospitalId) { this.CancelValid(validType, barcode, userId, null, hospitalId); }
public IList <GoodsFlowEntity> QueryWaitingValid(GoodsFlowValidType validType, int formNo, bool isValid, string vendorId, string hospitalId) { return(GoodsFlowRepository.QueryWaitingValid(validType, formNo, isValid, vendorId, hospitalId)); }
public IList <GoodsFlowEntity> QueryWaitingValid(GoodsFlowValidType validType, int formNo, bool isValid, string hospitalId) { return(this.QueryWaitingValid(validType, formNo, isValid, "", hospitalId)); }