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

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Address  = dataReader["Address"].ToString();
            model.City     = dataReader["City"].ToString();
            model.Mobile   = dataReader["Mobile"].ToString();
            model.Remark   = dataReader["Remark"].ToString();
            model.SiteName = dataReader["SiteName"].ToString();
            ojb            = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            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);
            }
            model.Tel      = dataReader["Tel"].ToString();
            model.UserName = dataReader["UserName"].ToString();
            model.ZipCode  = dataReader["ZipCode"].ToString();
            return(model);
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Express_Shipper model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Address") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("City") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Mobile") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SiteName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Tel") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ZipCode") + ")");
            strSql.Append(" values (");
            strSql.Append("@Address,@City,@Mobile,@Remark,@SiteName,@Sort,@Status,@Supplier_id,@Tel,@UserName,@ZipCode);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Address",     model.Address),
                new SqlParameter("@City",        model.City),
                new SqlParameter("@Mobile",      model.Mobile),
                new SqlParameter("@Remark",      model.Remark),
                new SqlParameter("@SiteName",    model.SiteName),
                new SqlParameter("@Sort",        model.Sort),
                new SqlParameter("@Status",      model.Status),
                new SqlParameter("@Supplier_id", model.Supplier_id),
                new SqlParameter("@Tel",         model.Tel),
                new SqlParameter("@UserName",    model.UserName),
                new SqlParameter("@ZipCode",     model.ZipCode)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Express_Shipper SafeBindForm(Lebi_Express_Shipper model)
 {
     if (HttpContext.Current.Request["Address"] != null)
     {
         model.Address = LB.Tools.RequestTool.RequestSafeString("Address");
     }
     if (HttpContext.Current.Request["City"] != null)
     {
         model.City = LB.Tools.RequestTool.RequestSafeString("City");
     }
     if (HttpContext.Current.Request["Mobile"] != null)
     {
         model.Mobile = LB.Tools.RequestTool.RequestSafeString("Mobile");
     }
     if (HttpContext.Current.Request["Remark"] != null)
     {
         model.Remark = LB.Tools.RequestTool.RequestSafeString("Remark");
     }
     if (HttpContext.Current.Request["SiteName"] != null)
     {
         model.SiteName = LB.Tools.RequestTool.RequestSafeString("SiteName");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     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["Tel"] != null)
     {
         model.Tel = LB.Tools.RequestTool.RequestSafeString("Tel");
     }
     if (HttpContext.Current.Request["UserName"] != null)
     {
         model.UserName = LB.Tools.RequestTool.RequestSafeString("UserName");
     }
     if (HttpContext.Current.Request["ZipCode"] != null)
     {
         model.ZipCode = LB.Tools.RequestTool.RequestSafeString("ZipCode");
     }
     return(model);
 }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Express_Shipper 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_Shipper);
                }
            }
            Lebi_Express_Shipper 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_Shipper", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
コード例 #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Express_Shipper 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(",City,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("City") + "= @City");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Mobile,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Mobile") + "= @Mobile");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Remark,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "= @Remark");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SiteName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SiteName") + "= @SiteName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            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(",Tel,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Tel") + "= @Tel");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + "= @UserName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",ZipCode,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ZipCode") + "= @ZipCode");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          model.id),
                new SqlParameter("@Address",     model.Address),
                new SqlParameter("@City",        model.City),
                new SqlParameter("@Mobile",      model.Mobile),
                new SqlParameter("@Remark",      model.Remark),
                new SqlParameter("@SiteName",    model.SiteName),
                new SqlParameter("@Sort",        model.Sort),
                new SqlParameter("@Status",      model.Status),
                new SqlParameter("@Supplier_id", model.Supplier_id),
                new SqlParameter("@Tel",         model.Tel),
                new SqlParameter("@UserName",    model.UserName),
                new SqlParameter("@ZipCode",     model.ZipCode)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Express_Shipper model)
 {
     D_Lebi_Express_Shipper.Instance.Update(model);
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Express_Shipper model)
 {
     return(D_Lebi_Express_Shipper.Instance.Add(model));
 }
コード例 #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Express_Shipper SafeBindForm(Lebi_Express_Shipper model)
 {
     return(D_Lebi_Express_Shipper.Instance.SafeBindForm(model));
 }