Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Card model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("CardOrder_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IndexCode") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCanOtherUse") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPayOnce") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Money") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Money_Buy") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Money_Last") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Money_Used") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("number") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Password") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Pro_Type_ids") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Begin") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_End") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_CardStatus") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_CardType") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + ")");
            strSql.Append(" values (");
            strSql.Append("@CardOrder_id,@Code,@IndexCode,@IsCanOtherUse,@IsPayOnce,@Money,@Money_Buy,@Money_Last,@Money_Used,@number,@Order_Code,@Order_id,@Password,@Pro_Type_ids,@Remark,@Time_Add,@Time_Begin,@Time_End,@Type_id_CardStatus,@Type_id_CardType,@User_id,@User_UserName);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CardOrder_id",       model.CardOrder_id),
                new SqlParameter("@Code",               model.Code),
                new SqlParameter("@IndexCode",          model.IndexCode),
                new SqlParameter("@IsCanOtherUse",      model.IsCanOtherUse),
                new SqlParameter("@IsPayOnce",          model.IsPayOnce),
                new SqlParameter("@Money",              model.Money),
                new SqlParameter("@Money_Buy",          model.Money_Buy),
                new SqlParameter("@Money_Last",         model.Money_Last),
                new SqlParameter("@Money_Used",         model.Money_Used),
                new SqlParameter("@number",             model.number),
                new SqlParameter("@Order_Code",         model.Order_Code),
                new SqlParameter("@Order_id",           model.Order_id),
                new SqlParameter("@Password",           model.Password),
                new SqlParameter("@Pro_Type_ids",       model.Pro_Type_ids),
                new SqlParameter("@Remark",             model.Remark),
                new SqlParameter("@Time_Add",           model.Time_Add),
                new SqlParameter("@Time_Begin",         model.Time_Begin),
                new SqlParameter("@Time_End",           model.Time_End),
                new SqlParameter("@Type_id_CardStatus", model.Type_id_CardStatus),
                new SqlParameter("@Type_id_CardType",   model.Type_id_CardType),
                new SqlParameter("@User_id",            model.User_id),
                new SqlParameter("@User_UserName",      model.User_UserName)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Card 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_Card);
                }
            }
            Lebi_Card 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_Card", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Esempio n. 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Card model)
 {
     D_Lebi_Card.Instance.Update(model);
 }
Esempio n. 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Card model)
 {
     return(D_Lebi_Card.Instance.Add(model));
 }
Esempio n. 5
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Card SafeBindForm(Lebi_Card model)
 {
     return(D_Lebi_Card.Instance.SafeBindForm(model));
 }
Esempio n. 6
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Card ReaderBind(IDataReader dataReader)
        {
            Lebi_Card model = new Lebi_Card();
            object    ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["CardOrder_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CardOrder_id = Convert.ToInt32(ojb);
            }
            model.Code      = dataReader["Code"].ToString();
            model.IndexCode = dataReader["IndexCode"].ToString();
            ojb             = dataReader["IsCanOtherUse"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsCanOtherUse = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IsPayOnce"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsPayOnce = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Money"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Money = (decimal)ojb;
            }
            ojb = dataReader["Money_Buy"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Money_Buy = (decimal)ojb;
            }
            ojb = dataReader["Money_Last"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Money_Last = (decimal)ojb;
            }
            ojb = dataReader["Money_Used"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Money_Used = (decimal)ojb;
            }
            ojb = dataReader["number"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.number = Convert.ToInt32(ojb);
            }
            model.Order_Code   = dataReader["Order_Code"].ToString();
            model.Order_id     = dataReader["Order_id"].ToString();
            model.Password     = dataReader["Password"].ToString();
            model.Pro_Type_ids = dataReader["Pro_Type_ids"].ToString();
            model.Remark       = dataReader["Remark"].ToString();
            ojb = dataReader["Time_Add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Add = (DateTime)ojb;
            }
            ojb = dataReader["Time_Begin"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Begin = (DateTime)ojb;
            }
            ojb = dataReader["Time_End"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_End = (DateTime)ojb;
            }
            ojb = dataReader["Type_id_CardStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_CardStatus = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Type_id_CardType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_CardType = Convert.ToInt32(ojb);
            }
            ojb = dataReader["User_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_id = Convert.ToInt32(ojb);
            }
            model.User_UserName = dataReader["User_UserName"].ToString();
            return(model);
        }
Esempio n. 7
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Card SafeBindForm(Lebi_Card model)
 {
     if (HttpContext.Current.Request["CardOrder_id"] != null)
     {
         model.CardOrder_id = LB.Tools.RequestTool.RequestInt("CardOrder_id", 0);
     }
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = LB.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["IndexCode"] != null)
     {
         model.IndexCode = LB.Tools.RequestTool.RequestSafeString("IndexCode");
     }
     if (HttpContext.Current.Request["IsCanOtherUse"] != null)
     {
         model.IsCanOtherUse = LB.Tools.RequestTool.RequestInt("IsCanOtherUse", 0);
     }
     if (HttpContext.Current.Request["IsPayOnce"] != null)
     {
         model.IsPayOnce = LB.Tools.RequestTool.RequestInt("IsPayOnce", 0);
     }
     if (HttpContext.Current.Request["Money"] != null)
     {
         model.Money = LB.Tools.RequestTool.RequestDecimal("Money", 0);
     }
     if (HttpContext.Current.Request["Money_Buy"] != null)
     {
         model.Money_Buy = LB.Tools.RequestTool.RequestDecimal("Money_Buy", 0);
     }
     if (HttpContext.Current.Request["Money_Last"] != null)
     {
         model.Money_Last = LB.Tools.RequestTool.RequestDecimal("Money_Last", 0);
     }
     if (HttpContext.Current.Request["Money_Used"] != null)
     {
         model.Money_Used = LB.Tools.RequestTool.RequestDecimal("Money_Used", 0);
     }
     if (HttpContext.Current.Request["number"] != null)
     {
         model.number = LB.Tools.RequestTool.RequestInt("number", 0);
     }
     if (HttpContext.Current.Request["Order_Code"] != null)
     {
         model.Order_Code = LB.Tools.RequestTool.RequestSafeString("Order_Code");
     }
     if (HttpContext.Current.Request["Order_id"] != null)
     {
         model.Order_id = LB.Tools.RequestTool.RequestSafeString("Order_id");
     }
     if (HttpContext.Current.Request["Password"] != null)
     {
         model.Password = LB.Tools.RequestTool.RequestSafeString("Password");
     }
     if (HttpContext.Current.Request["Pro_Type_ids"] != null)
     {
         model.Pro_Type_ids = LB.Tools.RequestTool.RequestSafeString("Pro_Type_ids");
     }
     if (HttpContext.Current.Request["Remark"] != null)
     {
         model.Remark = LB.Tools.RequestTool.RequestSafeString("Remark");
     }
     if (HttpContext.Current.Request["Time_Add"] != null)
     {
         model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Time_Begin"] != null)
     {
         model.Time_Begin = LB.Tools.RequestTool.RequestTime("Time_Begin", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Time_End"] != null)
     {
         model.Time_End = LB.Tools.RequestTool.RequestTime("Time_End", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Type_id_CardStatus"] != null)
     {
         model.Type_id_CardStatus = LB.Tools.RequestTool.RequestInt("Type_id_CardStatus", 0);
     }
     if (HttpContext.Current.Request["Type_id_CardType"] != null)
     {
         model.Type_id_CardType = LB.Tools.RequestTool.RequestInt("Type_id_CardType", 0);
     }
     if (HttpContext.Current.Request["User_id"] != null)
     {
         model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0);
     }
     if (HttpContext.Current.Request["User_UserName"] != null)
     {
         model.User_UserName = LB.Tools.RequestTool.RequestSafeString("User_UserName");
     }
     return(model);
 }
Esempio n. 8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Card model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",CardOrder_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("CardOrder_id") + "= @CardOrder_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "= @Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IndexCode,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IndexCode") + "= @IndexCode");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsCanOtherUse,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCanOtherUse") + "= @IsCanOtherUse");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsPayOnce,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPayOnce") + "= @IsPayOnce");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Money,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Money") + "= @Money");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Money_Buy,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Money_Buy") + "= @Money_Buy");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Money_Last,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Money_Last") + "= @Money_Last");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Money_Used,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Money_Used") + "= @Money_Used");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",number,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("number") + "= @number");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Order_Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Code") + "= @Order_Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Order_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_id") + "= @Order_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Password,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Password") + "= @Password");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Pro_Type_ids,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Pro_Type_ids") + "= @Pro_Type_ids");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Remark,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "= @Remark");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Begin,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Begin") + "= @Time_Begin");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_End,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_End") + "= @Time_End");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_CardStatus,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_CardStatus") + "= @Type_id_CardStatus");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_CardType,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_CardType") + "= @Type_id_CardType");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + "= @User_UserName");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                 model.id),
                new SqlParameter("@CardOrder_id",       model.CardOrder_id),
                new SqlParameter("@Code",               model.Code),
                new SqlParameter("@IndexCode",          model.IndexCode),
                new SqlParameter("@IsCanOtherUse",      model.IsCanOtherUse),
                new SqlParameter("@IsPayOnce",          model.IsPayOnce),
                new SqlParameter("@Money",              model.Money),
                new SqlParameter("@Money_Buy",          model.Money_Buy),
                new SqlParameter("@Money_Last",         model.Money_Last),
                new SqlParameter("@Money_Used",         model.Money_Used),
                new SqlParameter("@number",             model.number),
                new SqlParameter("@Order_Code",         model.Order_Code),
                new SqlParameter("@Order_id",           model.Order_id),
                new SqlParameter("@Password",           model.Password),
                new SqlParameter("@Pro_Type_ids",       model.Pro_Type_ids),
                new SqlParameter("@Remark",             model.Remark),
                new SqlParameter("@Time_Add",           model.Time_Add),
                new SqlParameter("@Time_Begin",         model.Time_Begin),
                new SqlParameter("@Time_End",           model.Time_End),
                new SqlParameter("@Type_id_CardStatus", model.Type_id_CardStatus),
                new SqlParameter("@Type_id_CardType",   model.Type_id_CardType),
                new SqlParameter("@User_id",            model.User_id),
                new SqlParameter("@User_UserName",      model.User_UserName)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }