Exemple #1
0
        public int AddShop(Shop shop, DbTransaction trans)
        {
            string cmdText = "INSERT INTO Shop(shopname,phone)VALUES(@shop,@phone);SELECT @@identity";

            DbParameter[] cmdParameters = {
                                                DbHelper.MakeInParam("@shop", (DbType)SqlDbType.NChar, 20, shop.Shopname)/**/,
                                                DbHelper.MakeInParam("@phone", (DbType)SqlDbType.NChar, 20, shop.Phone)/**/
                                          };

            string s = DbHelper.ExecuteScalar(trans, CommandType.Text, cmdText, cmdParameters).ToString();
            int i = (string.IsNullOrEmpty(s) ? 0 : int.Parse(s));
            return i;
        }
Exemple #2
0
        public void handler(IResponder responder)
        {
            Shop shop = new Shop();

            shop.Shopname = SJSRequest.GetString("Shopname");
            shop.Phone = SJSRequest.GetString("Phone");

            if (string.IsNullOrEmpty(shop.Shopname))
            {
                responder.WriteErroredMsg("店铺名称不能为空!");
                return;
            }

            int rlt = ShopManager.AddShop(shop);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("新增店铺失败,数据库写入不成功!");
                return;
            }

            responder.WriteSuccessedMsg("新增店铺成功!");
        }
Exemple #3
0
        public static Shop GetShop(IDataReader reader)
        {
            Shop model = new Shop();

            model.Id = (reader["Id"] is DBNull ? Convert.ToInt32("0") : Convert.ToInt32(reader["Id"]));
            model.Shopname = reader["shopname"].ToString();
            model.Phone = reader["Phone"].ToString();

            return model;
        }
Exemple #4
0
 public static int AddShop(Shop shop, DbTransaction trans)
 {
     return DatabaseProvider.GetInstance().AddShop(shop, trans);
 }
Exemple #5
0
 /// <summary>
 /// 添加方法
 /// </summary>
 public static int AddShop(Shop shop)
 {
     return DatabaseProvider.GetInstance().AddShop(shop);
 }
Exemple #6
0
 /// <summary>
 /// 修改方法
 /// </summary>
 public static int UpdateShop(Shop shop)
 {
     return DatabaseProvider.GetInstance().UpdateShop(shop);
 }