Beispiel #1
0
        public void handler(IResponder responder)
        {
            Trade trade = new Trade();

            trade.Shopid = SJSRequest.GetInt("Shopid", 0);
            trade.Tradename = SJSRequest.GetString("Tradename");
            trade.Tradevalue = SJSRequest.GetFloat("Tradevalue", 0);

            if (trade.Shopid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            if (string.IsNullOrEmpty(trade.Tradename))
            {
                responder.WriteErroredMsg("菜单名称不能为空!");
                return;
            }

            int rlt = TradeManager.AddTrade(trade);

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

            responder.WriteSuccessedMsg("新增菜单成功!");
        }
Beispiel #2
0
        public int AddTrade(Trade trade)
        {
            string cmdText = "INSERT INTO Trade(shopid,tradename,tradevalue)VALUES(@shopid,@tradename,@tradevalue);SELECT @@identity";

            DbParameter[] cmdParameters = {
                                                DbHelper.MakeInParam("@shopid", (DbType)SqlDbType.Int, 0, trade.Shopid)/**/,
                                                DbHelper.MakeInParam("@tradename", (DbType)SqlDbType.NChar, 20, trade.Tradename)/**/,
                                                DbHelper.MakeInParam("@tradevalue", (DbType)SqlDbType.Decimal, 0, trade.Tradevalue)/**/
                                          };

            string s = DbHelper.ExecuteScalar(CommandType.Text, cmdText, cmdParameters).ToString();
            int i = (string.IsNullOrEmpty(s) ? 0 : int.Parse(s));
            return i;
        }

        public int AddTrade(Trade trade, DbTransaction trans)
        {
            string cmdText = "INSERT INTO Trade(shopid,tradename,tradevalue)VALUES(@shopid,@tradename,@tradevalue);SELECT @@identity";

            DbParameter[] cmdParameters = {
                                                DbHelper.MakeInParam("@shopid", (DbType)SqlDbType.Int, 0, trade.Shopid)/**/,
                                                DbHelper.MakeInParam("@tradename", (DbType)SqlDbType.NChar, 20, trade.Tradename)/**/,
                                                DbHelper.MakeInParam("@tradevalue", (DbType)SqlDbType.Decimal, 0, trade.Tradevalue)/**/
                                          };

            string s = DbHelper.ExecuteScalar(trans, CommandType.Text, cmdText, cmdParameters).ToString();
            int i = (string.IsNullOrEmpty(s) ? 0 : int.Parse(s));
            return i;
        }
Beispiel #3
0
 public static int AddTrade(Trade trade, DbTransaction trans)
 {
     return DatabaseProvider.GetInstance().AddTrade(trade, trans);
 }
Beispiel #4
0
 /// <summary>
 /// 添加方法
 /// </summary>
 public static int AddTrade(Trade trade)
 {
     return DatabaseProvider.GetInstance().AddTrade(trade);
 }
Beispiel #5
0
 /// <summary>
 /// 修改方法
 /// </summary>
 public static int UpdateTrade(Trade trade)
 {
     return DatabaseProvider.GetInstance().UpdateTrade(trade);
 }
Beispiel #6
0
        public static Trade GetTrade(IDataReader reader)
        {
            Trade model = new Trade();

            model.Id = (reader["Id"] is DBNull ? Convert.ToInt32("0") : Convert.ToInt32(reader["Id"]));
            model.Shopid = (reader["Shopid"] is DBNull ? Convert.ToInt32("0") : Convert.ToInt32(reader["Shopid"]));
            model.Tradename = reader["Tradename"].ToString();
            model.Tradevalue = (reader["Tradevalue"] is DBNull ? Convert.ToDouble("0") : Convert.ToDouble(reader["Tradevalue"]));

            return model;
        }
Beispiel #7
0
        public int UpdateTrade(Trade trade)
        {
            string cmdText = "UPDATE Trade SET shopid=@shopid, tradename=@tradename, tradevalue=@tradevalue WHERE id=@id";

            DbParameter[] cmdParameters = {

                                                DbHelper.MakeInParam("@id", (DbType)SqlDbType.Int, 0, trade.Id)/**/,
                                                DbHelper.MakeInParam("@shopid", (DbType)SqlDbType.Int, 0, trade.Shopid)/**/,
                                                DbHelper.MakeInParam("@tradename", (DbType)SqlDbType.NChar, 20, trade.Tradename)/**/,
                                                DbHelper.MakeInParam("@tradevalue", (DbType)SqlDbType.Decimal, 0, trade.Tradevalue)/**/
                                          };

            return DbHelper.ExecuteNonQuery(CommandType.Text, cmdText, cmdParameters);
        }