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

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.IdList = dataReader["IdList"].ToString();
            model.Number = dataReader["Number"].ToString();
            ojb          = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Supplier_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Supplier_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Time_Add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Add = (DateTime)ojb;
            }
            ojb = dataReader["Transport_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Transport_id = Convert.ToInt32(ojb);
            }
            model.Transport_Name = dataReader["Transport_Name"].ToString();
            return(model);
        }
示例#2
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Express_Log SafeBindForm(Lebi_Express_Log model)
 {
     if (HttpContext.Current.Request["IdList"] != null)
     {
         model.IdList = LB.Tools.RequestTool.RequestSafeString("IdList");
     }
     if (HttpContext.Current.Request["Number"] != null)
     {
         model.Number = LB.Tools.RequestTool.RequestSafeString("Number");
     }
     if (HttpContext.Current.Request["Status"] != null)
     {
         model.Status = LB.Tools.RequestTool.RequestInt("Status", 0);
     }
     if (HttpContext.Current.Request["Supplier_id"] != null)
     {
         model.Supplier_id = LB.Tools.RequestTool.RequestInt("Supplier_id", 0);
     }
     if (HttpContext.Current.Request["Time_Add"] != null)
     {
         model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Transport_id"] != null)
     {
         model.Transport_id = LB.Tools.RequestTool.RequestInt("Transport_id", 0);
     }
     if (HttpContext.Current.Request["Transport_Name"] != null)
     {
         model.Transport_Name = LB.Tools.RequestTool.RequestSafeString("Transport_Name");
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Express_Log model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("IdList") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Number") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Transport_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Transport_Name") + ")");
            strSql.Append(" values (");
            strSql.Append("@IdList,@Number,@Status,@Supplier_id,@Time_Add,@Transport_id,@Transport_Name);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@IdList",         model.IdList),
                new SqlParameter("@Number",         model.Number),
                new SqlParameter("@Status",         model.Status),
                new SqlParameter("@Supplier_id",    model.Supplier_id),
                new SqlParameter("@Time_Add",       model.Time_Add),
                new SqlParameter("@Transport_id",   model.Transport_id),
                new SqlParameter("@Transport_Name", model.Transport_Name)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Express_Log model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",IdList,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IdList") + "= @IdList");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Number,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Number") + "= @Number");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Status,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "= @Status");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "= @Supplier_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Transport_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Transport_id") + "= @Transport_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Transport_Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Transport_Name") + "= @Transport_Name");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             model.id),
                new SqlParameter("@IdList",         model.IdList),
                new SqlParameter("@Number",         model.Number),
                new SqlParameter("@Status",         model.Status),
                new SqlParameter("@Supplier_id",    model.Supplier_id),
                new SqlParameter("@Time_Add",       model.Time_Add),
                new SqlParameter("@Transport_id",   model.Transport_id),
                new SqlParameter("@Transport_Name", model.Transport_Name)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
示例#5
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Express_Log 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_Express_Log);
                }
            }
            Lebi_Express_Log 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_Express_Log", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
示例#6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Express_Log model)
 {
     D_Lebi_Express_Log.Instance.Update(model);
 }
示例#7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Express_Log model)
 {
     return(D_Lebi_Express_Log.Instance.Add(model));
 }
示例#8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Express_Log SafeBindForm(Lebi_Express_Log model)
 {
     return(D_Lebi_Express_Log.Instance.SafeBindForm(model));
 }