Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_PickUp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Address") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("BeginDays") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCanWeekend") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("NoServiceDays") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_add") + ")");
            strSql.Append(" values (");
            strSql.Append("@Address,@BeginDays,@Description,@IsCanWeekend,@Language_ids,@Name,@NoServiceDays,@Sort,@Supplier_id,@Time_add);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Address",       model.Address),
                new SqlParameter("@BeginDays",     model.BeginDays),
                new SqlParameter("@Description",   model.Description),
                new SqlParameter("@IsCanWeekend",  model.IsCanWeekend),
                new SqlParameter("@Language_ids",  model.Language_ids),
                new SqlParameter("@Name",          model.Name),
                new SqlParameter("@NoServiceDays", model.NoServiceDays),
                new SqlParameter("@Sort",          model.Sort),
                new SqlParameter("@Supplier_id",   model.Supplier_id),
                new SqlParameter("@Time_add",      model.Time_add)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_PickUp SafeBindForm(Lebi_PickUp model)
 {
     if (HttpContext.Current.Request["Address"] != null)
     {
         model.Address = LB.Tools.RequestTool.RequestSafeString("Address");
     }
     if (HttpContext.Current.Request["BeginDays"] != null)
     {
         model.BeginDays = LB.Tools.RequestTool.RequestInt("BeginDays", 0);
     }
     if (HttpContext.Current.Request["Description"] != null)
     {
         model.Description = LB.Tools.RequestTool.RequestSafeString("Description");
     }
     if (HttpContext.Current.Request["IsCanWeekend"] != null)
     {
         model.IsCanWeekend = LB.Tools.RequestTool.RequestInt("IsCanWeekend", 0);
     }
     if (HttpContext.Current.Request["Language_ids"] != null)
     {
         model.Language_ids = LB.Tools.RequestTool.RequestSafeString("Language_ids");
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["NoServiceDays"] != null)
     {
         model.NoServiceDays = LB.Tools.RequestTool.RequestSafeString("NoServiceDays");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 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);
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_PickUp ReaderBind(IDataReader dataReader)
        {
            Lebi_PickUp model = new Lebi_PickUp();
            object      ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Address = dataReader["Address"].ToString();
            ojb           = dataReader["BeginDays"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BeginDays = Convert.ToInt32(ojb);
            }
            model.Description = dataReader["Description"].ToString();
            ojb = dataReader["IsCanWeekend"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsCanWeekend = Convert.ToInt32(ojb);
            }
            model.Language_ids  = dataReader["Language_ids"].ToString();
            model.Name          = dataReader["Name"].ToString();
            model.NoServiceDays = dataReader["NoServiceDays"].ToString();
            ojb = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = 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;
            }
            return(model);
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_PickUp 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_PickUp);
                }
            }
            Lebi_PickUp 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_PickUp", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Пример #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_PickUp model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Address,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Address") + "= @Address");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",BeginDays,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("BeginDays") + "= @BeginDays");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Description,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "= @Description");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsCanWeekend,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCanWeekend") + "= @IsCanWeekend");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language_ids,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "= @Language_ids");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",NoServiceDays,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("NoServiceDays") + "= @NoServiceDays");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            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");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",            model.id),
                new SqlParameter("@Address",       model.Address),
                new SqlParameter("@BeginDays",     model.BeginDays),
                new SqlParameter("@Description",   model.Description),
                new SqlParameter("@IsCanWeekend",  model.IsCanWeekend),
                new SqlParameter("@Language_ids",  model.Language_ids),
                new SqlParameter("@Name",          model.Name),
                new SqlParameter("@NoServiceDays", model.NoServiceDays),
                new SqlParameter("@Sort",          model.Sort),
                new SqlParameter("@Supplier_id",   model.Supplier_id),
                new SqlParameter("@Time_add",      model.Time_add)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Пример #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_PickUp model)
 {
     D_Lebi_PickUp.Instance.Update(model);
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_PickUp model)
 {
     return(D_Lebi_PickUp.Instance.Add(model));
 }
Пример #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_PickUp SafeBindForm(Lebi_PickUp model)
 {
     return(D_Lebi_PickUp.Instance.SafeBindForm(model));
 }