Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Cash 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_Cash);
                }
            }
            Lebi_Cash 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_Cash", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Cash model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("AccountCode") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("AccountName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_UserName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Bank") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("DT_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Fee") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Money") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("PayType") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_SubName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_update") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_CashStatus") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + ")");
            strSql.Append(" values (");
            strSql.Append("@AccountCode,@AccountName,@Admin_id,@Admin_UserName,@Bank,@DT_id,@Fee,@Money,@PayType,@Remark,@Supplier_id,@Supplier_SubName,@Time_add,@Time_update,@Type_id_CashStatus,@User_id,@User_UserName);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AccountCode",        model.AccountCode),
                new SqlParameter("@AccountName",        model.AccountName),
                new SqlParameter("@Admin_id",           model.Admin_id),
                new SqlParameter("@Admin_UserName",     model.Admin_UserName),
                new SqlParameter("@Bank",               model.Bank),
                new SqlParameter("@DT_id",              model.DT_id),
                new SqlParameter("@Fee",                model.Fee),
                new SqlParameter("@Money",              model.Money),
                new SqlParameter("@PayType",            model.PayType),
                new SqlParameter("@Remark",             model.Remark),
                new SqlParameter("@Supplier_id",        model.Supplier_id),
                new SqlParameter("@Supplier_SubName",   model.Supplier_SubName),
                new SqlParameter("@Time_add",           model.Time_add),
                new SqlParameter("@Time_update",        model.Time_update),
                new SqlParameter("@Type_id_CashStatus", model.Type_id_CashStatus),
                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));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Cash model)
 {
     D_Lebi_Cash.Instance.Update(model);
 }
Beispiel #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Cash model)
 {
     return(D_Lebi_Cash.Instance.Add(model));
 }
Beispiel #5
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Cash SafeBindForm(Lebi_Cash model)
 {
     return(D_Lebi_Cash.Instance.SafeBindForm(model));
 }
Beispiel #6
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Cash ReaderBind(IDataReader dataReader)
        {
            Lebi_Cash model = new Lebi_Cash();
            object    ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.AccountCode = dataReader["AccountCode"].ToString();
            model.AccountName = dataReader["AccountName"].ToString();
            ojb = dataReader["Admin_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Admin_id = Convert.ToInt32(ojb);
            }
            model.Admin_UserName = dataReader["Admin_UserName"].ToString();
            model.Bank           = dataReader["Bank"].ToString();
            ojb = dataReader["DT_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DT_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Fee"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Fee = (decimal)ojb;
            }
            ojb = dataReader["Money"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Money = (decimal)ojb;
            }
            model.PayType = dataReader["PayType"].ToString();
            model.Remark  = dataReader["Remark"].ToString();
            ojb           = dataReader["Supplier_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Supplier_id = Convert.ToInt32(ojb);
            }
            model.Supplier_SubName = dataReader["Supplier_SubName"].ToString();
            ojb = dataReader["Time_add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_add = (DateTime)ojb;
            }
            ojb = dataReader["Time_update"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_update = (DateTime)ojb;
            }
            ojb = dataReader["Type_id_CashStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_CashStatus = 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);
        }
Beispiel #7
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Cash SafeBindForm(Lebi_Cash model)
 {
     if (HttpContext.Current.Request["AccountCode"] != null)
     {
         model.AccountCode = LB.Tools.RequestTool.RequestSafeString("AccountCode");
     }
     if (HttpContext.Current.Request["AccountName"] != null)
     {
         model.AccountName = LB.Tools.RequestTool.RequestSafeString("AccountName");
     }
     if (HttpContext.Current.Request["Admin_id"] != null)
     {
         model.Admin_id = LB.Tools.RequestTool.RequestInt("Admin_id", 0);
     }
     if (HttpContext.Current.Request["Admin_UserName"] != null)
     {
         model.Admin_UserName = LB.Tools.RequestTool.RequestSafeString("Admin_UserName");
     }
     if (HttpContext.Current.Request["Bank"] != null)
     {
         model.Bank = LB.Tools.RequestTool.RequestSafeString("Bank");
     }
     if (HttpContext.Current.Request["DT_id"] != null)
     {
         model.DT_id = LB.Tools.RequestTool.RequestInt("DT_id", 0);
     }
     if (HttpContext.Current.Request["Fee"] != null)
     {
         model.Fee = LB.Tools.RequestTool.RequestDecimal("Fee", 0);
     }
     if (HttpContext.Current.Request["Money"] != null)
     {
         model.Money = LB.Tools.RequestTool.RequestDecimal("Money", 0);
     }
     if (HttpContext.Current.Request["PayType"] != null)
     {
         model.PayType = LB.Tools.RequestTool.RequestSafeString("PayType");
     }
     if (HttpContext.Current.Request["Remark"] != null)
     {
         model.Remark = LB.Tools.RequestTool.RequestSafeString("Remark");
     }
     if (HttpContext.Current.Request["Supplier_id"] != null)
     {
         model.Supplier_id = LB.Tools.RequestTool.RequestInt("Supplier_id", 0);
     }
     if (HttpContext.Current.Request["Supplier_SubName"] != null)
     {
         model.Supplier_SubName = LB.Tools.RequestTool.RequestSafeString("Supplier_SubName");
     }
     if (HttpContext.Current.Request["Time_add"] != null)
     {
         model.Time_add = LB.Tools.RequestTool.RequestTime("Time_add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Time_update"] != null)
     {
         model.Time_update = LB.Tools.RequestTool.RequestTime("Time_update", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Type_id_CashStatus"] != null)
     {
         model.Type_id_CashStatus = LB.Tools.RequestTool.RequestInt("Type_id_CashStatus", 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);
 }
Beispiel #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Cash model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",AccountCode,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("AccountCode") + "= @AccountCode");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",AccountName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("AccountName") + "= @AccountName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Admin_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "= @Admin_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Admin_UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_UserName") + "= @Admin_UserName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Bank,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Bank") + "= @Bank");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",DT_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("DT_id") + "= @DT_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Fee,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Fee") + "= @Fee");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Money,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Money") + "= @Money");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",PayType,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("PayType") + "= @PayType");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Remark,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "= @Remark");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "= @Supplier_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_SubName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_SubName") + "= @Supplier_SubName");
            }
            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_update,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_update") + "= @Time_update");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_CashStatus,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_CashStatus") + "= @Type_id_CashStatus");
            }
            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("@AccountCode",        model.AccountCode),
                new SqlParameter("@AccountName",        model.AccountName),
                new SqlParameter("@Admin_id",           model.Admin_id),
                new SqlParameter("@Admin_UserName",     model.Admin_UserName),
                new SqlParameter("@Bank",               model.Bank),
                new SqlParameter("@DT_id",              model.DT_id),
                new SqlParameter("@Fee",                model.Fee),
                new SqlParameter("@Money",              model.Money),
                new SqlParameter("@PayType",            model.PayType),
                new SqlParameter("@Remark",             model.Remark),
                new SqlParameter("@Supplier_id",        model.Supplier_id),
                new SqlParameter("@Supplier_SubName",   model.Supplier_SubName),
                new SqlParameter("@Time_add",           model.Time_add),
                new SqlParameter("@Time_update",        model.Time_update),
                new SqlParameter("@Type_id_CashStatus", model.Type_id_CashStatus),
                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);
        }