Beispiel #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Transport ReaderBind(IDataReader dataReader)
        {
            Lebi_Transport model = new Lebi_Transport();
            object         ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Code        = dataReader["Code"].ToString();
            model.Description = dataReader["Description"].ToString();
            ojb = dataReader["IsCanofflinePay"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsCanofflinePay = Convert.ToInt32(ojb);
            }
            model.Name = dataReader["Name"].ToString();
            ojb        = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Type_id_TransportType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_TransportType = Convert.ToInt32(ojb);
            }
            return(model);
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Transport model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCanofflinePay") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_TransportType") + ")");
            strSql.Append(" values (");
            strSql.Append("@Code,@Description,@IsCanofflinePay,@Name,@Sort,@Type_id_TransportType);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",                  model.Code),
                new SqlParameter("@Description",           model.Description),
                new SqlParameter("@IsCanofflinePay",       model.IsCanofflinePay),
                new SqlParameter("@Name",                  model.Name),
                new SqlParameter("@Sort",                  model.Sort),
                new SqlParameter("@Type_id_TransportType", model.Type_id_TransportType)
            };

            object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Transport SafeBindForm(Lebi_Transport model)
 {
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = LB.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["Description"] != null)
     {
         model.Description = LB.Tools.RequestTool.RequestSafeString("Description");
     }
     if (HttpContext.Current.Request["IsCanofflinePay"] != null)
     {
         model.IsCanofflinePay = LB.Tools.RequestTool.RequestInt("IsCanofflinePay", 0);
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["Type_id_TransportType"] != null)
     {
         model.Type_id_TransportType = LB.Tools.RequestTool.RequestInt("Type_id_TransportType", 0);
     }
     return(model);
 }
Beispiel #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Transport model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + TableName + " set ");
            List <string> cols = new List <string>();

            if (("," + model.UpdateCols + ",").IndexOf(",Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "= @Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Description,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "= @Description");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsCanofflinePay,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCanofflinePay") + "= @IsCanofflinePay");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_TransportType,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_TransportType") + "= @Type_id_TransportType");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                    model.id),
                new SqlParameter("@Code",                  model.Code),
                new SqlParameter("@Description",           model.Description),
                new SqlParameter("@IsCanofflinePay",       model.IsCanofflinePay),
                new SqlParameter("@Name",                  model.Name),
                new SqlParameter("@Sort",                  model.Sort),
                new SqlParameter("@Type_id_TransportType", model.Type_id_TransportType)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Transport GetModel(string strWhere, int seconds = 0)
        {
            if (strWhere.IndexOf("lbsql{") > 0)
            {
                SQLPara para = new SQLPara(strWhere, "", "");
                return(GetModel(para, seconds));
            }
            string strTableName = TableName;
            string strFieldShow = "*";
            string cachekey     = "";
            string cachestr     = "";

            if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0)
            {
                cachestr = "select * " + TableName + " where " + strWhere + "|" + seconds;
                cachekey = LB.Tools.Utils.MD5(cachestr);
                var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey);
                if (obj != null)
                {
                    return(obj as Lebi_Transport);
                }
            }
            Lebi_Transport model = null;

            using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, null))
            {
                if (dataReader == null)
                {
                    return(null);
                }
                while (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                    if (cachekey != "")
                    {
                        LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Transport", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Transport model)
 {
     D_Lebi_Transport.Instance.Update(model);
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Transport model)
 {
     return(D_Lebi_Transport.Instance.Add(model));
 }
Beispiel #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Transport SafeBindForm(Lebi_Transport model)
 {
     return(D_Lebi_Transport.Instance.SafeBindForm(model));
 }