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; }
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("新增店铺成功!"); }
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; }
public static int AddShop(Shop shop, DbTransaction trans) { return DatabaseProvider.GetInstance().AddShop(shop, trans); }
/// <summary> /// 添加方法 /// </summary> public static int AddShop(Shop shop) { return DatabaseProvider.GetInstance().AddShop(shop); }
/// <summary> /// 修改方法 /// </summary> public static int UpdateShop(Shop shop) { return DatabaseProvider.GetInstance().UpdateShop(shop); }