Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.shop GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from " + databaseprefix + "shop ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.shop model = new Model.shop();
            DataSet    ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["linkman"] != null && ds.Tables[0].Rows[0]["linkman"].ToString() != "")
                {
                    model.linkman = ds.Tables[0].Rows[0]["linkman"].ToString();
                }
                if (ds.Tables[0].Rows[0]["shop_name"] != null && ds.Tables[0].Rows[0]["shop_name"].ToString() != "")
                {
                    model.shop_name = ds.Tables[0].Rows[0]["shop_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["address"] != null && ds.Tables[0].Rows[0]["address"].ToString() != "")
                {
                    model.address = ds.Tables[0].Rows[0]["address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["telphone"] != null && ds.Tables[0].Rows[0]["telphone"].ToString() != "")
                {
                    model.telphone = ds.Tables[0].Rows[0]["telphone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["city"] != null && ds.Tables[0].Rows[0]["city"].ToString() != "")
                {
                    model.city = ds.Tables[0].Rows[0]["city"].ToString();
                }

                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        private void ShowInfo(int _id)
        {
            BLL.shop   bll   = new BLL.shop();
            Model.shop model = bll.GetModel(_id);

            txtShopName.Text = model.shop_name;
            txtTelphone.Text = model.telphone;

            txtAddress.Text = model.address;
            txtLinkman.Text = model.linkman;
            txtCity.Text    = model.city;
        }
Beispiel #3
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.shop   bll   = new BLL.shop();
            Model.shop model = bll.GetModel(_id);
            model.address = txtAddress.Text.Trim();;

            model.shop_name = txtShopName.Text.Trim();
            model.telphone  = txtTelphone.Text.Trim();
            model.city      = txtCity.Text.Trim();
            model.linkman   = txtLinkman.Text.Trim();
            if (bll.Update(model))
            {
                result = true;
            }

            return(result);
        }
Beispiel #4
0
        private bool DoAdd()
        {
            bool result = false;

            Model.shop  model     = new Model.shop();
            BLL.shop    bll       = new BLL.shop();
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            model.address   = txtAddress.Text.Trim();;
            model.user_id   = userModel.id;
            model.shop_name = txtShopName.Text.Trim();
            model.telphone  = txtTelphone.Text.Trim();
            model.city      = txtCity.Text.Trim();
            model.linkman   = txtLinkman.Text.Trim();
            if (bll.Add(model) > 0)
            {
                result = true;
            }
            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.shop model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "shop set ");
            strSql.Append("address=@address,");
            strSql.Append("telphone=@telphone,");
            strSql.Append("user_id=@user_id,");
            strSql.Append("shop_name=@shop_name,");
            strSql.Append("city=@city,");
            strSql.Append("linkman=@linkman");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@address",   SqlDbType.NVarChar, 255),
                new SqlParameter("@telphone",  SqlDbType.NVarChar, 100),
                new SqlParameter("@user_id",   SqlDbType.Int,       10),
                new SqlParameter("@shop_name", SqlDbType.NVarChar,  50),
                new SqlParameter("@city",      SqlDbType.NVarChar,  50),
                new SqlParameter("@linkman",   SqlDbType.NVarChar,  20),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.address;
            parameters[1].Value = model.telphone;
            parameters[2].Value = model.user_id;
            parameters[3].Value = model.shop_name;
            parameters[4].Value = model.city;
            parameters[5].Value = model.linkman;
            parameters[6].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.shop model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "shop(");
            strSql.Append("address,telphone,user_id,shop_name,city,linkman)");
            strSql.Append(" values (");
            strSql.Append("@address,@telphone,@user_id,@shop_name,@city,@linkman)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@address",   SqlDbType.NVarChar, 255),
                new SqlParameter("@telphone",  SqlDbType.NVarChar, 100),
                new SqlParameter("@user_id",   SqlDbType.Int,       10),
                new SqlParameter("@shop_name", SqlDbType.NVarChar,  50),
                new SqlParameter("@city",      SqlDbType.NVarChar,  50),
                new SqlParameter("@linkman",   SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.address;
            parameters[1].Value = model.telphone;
            parameters[2].Value = model.user_id;
            parameters[3].Value = model.shop_name;
            parameters[4].Value = model.city;

            parameters[5].Value = model.linkman;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.shop model)
 {
     return(dal.Update(model));
 }
Beispiel #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.shop model)
 {
     return(dal.Add(model));
 }