示例#1
0
        private static void Add(ReturnFormEntity entity)
        {
            var sql = string.Format(@"insert into return_form({0})
values(
@p_id, @p_form_no, @p_filter_id, @p_vendor_id, @p_hospital_id, @p_apply_date, @p_status, '', '',
@p_created_id, @p_created_time, @p_updated_id, @p_updated_time
)", COLUMN_SQL);

            entity.Id = Guid.NewGuid().ToString();

            var db = DatabaseFactory.CreateDatabase();

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_id", DbType.String, entity.Id);
            db.AddInParameter(dc, "p_form_no", DbType.Int32, entity.FormNo);
            db.AddInParameter(dc, "p_filter_id", DbType.String, entity.FilterId);
            db.AddInParameter(dc, "p_vendor_id", DbType.String, entity.VendorId);
            db.AddInParameter(dc, "p_hospital_id", DbType.String, entity.HospitalId);
            db.AddInParameter(dc, "p_apply_date", DbType.DateTime, entity.ApplyDate);
            db.AddInParameter(dc, "p_status", DbType.Int32, entity.Status);
            db.AddInParameter(dc, "p_created_id", DbType.String, entity.CreatedId);
            db.AddInParameter(dc, "p_created_time", DbType.DateTime, entity.CreatedTime);
            db.AddInParameter(dc, "p_updated_id", DbType.String, entity.UpdatedId);
            db.AddInParameter(dc, "p_updated_time", DbType.DateTime, entity.UpdatedTime);

            db.ExecuteNonQuery(dc);
        }
        public JsonNetResult SaveReturn(ReturnFormEntity form)
        {
            if (form == null)
            {
                return(JsonNet(new ResponseResult()));
            }

            try
            {
                if (string.IsNullOrEmpty(form.Id))
                {
                    form.FilterId   = this.UserContext.UserId;
                    form.HospitalId = this.UserContext.CurrentHospital;
                    form.Status     = ReturnFormStatus.Applying;
                    form.CreatedId  = this.UserContext.UserId;
                    form.UpdatedId  = this.UserContext.UserId;
                }

                new ReturnFormService().Save(form);
                return(JsonNet(new ResponseResult()));
            }
            catch (Exception e)
            {
                return(JsonNet(new ResponseResult(false, e)));
            }
        }
示例#3
0
 public static void Save(ReturnFormEntity entity)
 {
     if (string.IsNullOrEmpty(entity.Id))
     {
         Add(entity);
     }
     else
     {
         Update(entity);
     }
 }
示例#4
0
        public static IList <ReturnFormEntity> Query(ReturnQueryCondition condition, PagerInfo pager)
        {
            pager.ComputePageCount(QueryCount(condition));

            var list = new List <ReturnFormEntity>();


            var orderSql = " ORDER BY ";

            if (pager.OrderFields.Count > 0)
            {
                foreach (var field in pager.OrderFields)
                {
                    orderSql += field.Field + (field.Desc ? " DESC" : "") + ",";
                }
            }
            else
            {
                orderSql += "form_no DESC";
            }

            var sql = string.Format(@"SELECT {0} FROM return_form WHERE {1}", COLUMN_SQL, GetConditionSql(condition));

            sql = @"SELECT * FROM
            (
                SELECT ROW_NUMBER() OVER(" + orderSql + @") pid," + COLUMN_SQL + @"
                FROM (" + sql + @") t            
            ) t1 WHERE t1.pid BETWEEN @p_pageNo * @p_pageSize + 1 AND (@p_pageNo + 1) * @p_pageSize ";

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            AddParameter(dc, db, condition);

            db.AddInParameter(dc, "p_pageNo", DbType.Int32, pager.PageIndex);
            db.AddInParameter(dc, "p_pageSize", DbType.Int32, pager.PageSize);

            using (IDataReader reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new ReturnFormEntity();
                    entity.Init(reader);

                    list.Add(entity);
                }
            }

            return(list);
        }
示例#5
0
        private static void Update(ReturnFormEntity entity)
        {
            var sql = string.Format(@"update return_form
set filter_id = @p_filter_id, vendor_id = @p_vendor_id, status = @p_status, updated_id = @p_updated_id, updated_time = @p_updated_time
where id = @p_id", COLUMN_SQL);

            entity.Id = Guid.NewGuid().ToString();

            var db = DatabaseFactory.CreateDatabase();

            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_id", DbType.String, entity.Id);
            db.AddInParameter(dc, "p_filter_id", DbType.String, entity.FilterId);
            db.AddInParameter(dc, "p_vendor_id", DbType.String, entity.VendorId);
            db.AddInParameter(dc, "p_status", DbType.Int32, entity.Status);
            db.AddInParameter(dc, "p_updated_id", DbType.String, entity.UpdatedId);
            db.AddInParameter(dc, "p_updated_time", DbType.DateTime, entity.UpdatedTime);

            db.ExecuteNonQuery(dc);
        }
示例#6
0
        public static ReturnFormEntity Get(string id)
        {
            var sql = string.Format("select {0} from return_form where id = @p_id", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_id", DbType.String, id);

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new ReturnFormEntity();
                    entity.Init(reader);

                    return(entity);
                }
            }

            return(null);
        }
示例#7
0
 public void Save(ReturnFormEntity entity)
 {
     ReturnFormRepository.Save(entity);
 }