Exemple #1
0
        public int AddBooking(Booking booking)
        {
            string cmdText = "INSERT INTO Booking(uid,realname,bookingname,bookingtime,isbooking,issettle,haserror)VALUES(@uid,@realname,@bookingname,@bookingtime,@isbooking,@issettle,@haserror);SELECT @@identity";

            DbParameter[] cmdParameters = {
                                                DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 0, booking.Uid)/**/,
                                                DbHelper.MakeInParam("@realname", (DbType)SqlDbType.NChar, 10, booking.Realname)/**/,
                                                DbHelper.MakeInParam("@bookingname", (DbType)SqlDbType.NChar, 50, booking.Bookingname)/**/,
                                                DbHelper.MakeInParam("@bookingtime", (DbType)SqlDbType.DateTime, 0, booking.Bookingtime)/**/,
                                                DbHelper.MakeInParam("@isbooking", (DbType)SqlDbType.Bit, 0, booking.Isbooking)/**/,
                                                DbHelper.MakeInParam("@issettle", (DbType)SqlDbType.Bit, 0, booking.Issettle)/**/,
                                                DbHelper.MakeInParam("@haserror", (DbType)SqlDbType.Bit, 0, booking.Haserror)/**/
                                          };

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

        public int DelBooking(int id)
        {
            string cmdText = "DELETE FROM Booking WHERE id=@id";

            DbParameter[] cmdParameters = {
                                                DbHelper.MakeInParam("@id", (DbType)SqlDbType.Int, 0, id)/**/
                                          };

            return DbHelper.ExecuteNonQuery(CommandType.Text, cmdText, cmdParameters);
        }
        public void handler(IResponder responder)
        {
            Booking booking = new Booking();
            booking.Bookingname = SJSRequest.GetString("Bookingname").Trim();
            DateTime dt = DateTime.Now;
            string dtStr = SJSRequest.GetString("Bookingtime");
            if (string.IsNullOrEmpty(dtStr) == false)
            {
                dt = Convert.ToDateTime(dtStr);
                dt = dt.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);
            }
            booking.Bookingtime = dt;// DateTime.UtcNow;
            booking.Isbooking = true;
            booking.Uid = PageUtils.AccountID;
            booking.Realname = PageUtils.RealName;
            booking.Issettle = false;
            booking.Haserror = false;

            if (string.IsNullOrEmpty(booking.Bookingname))
            {
                responder.WriteErroredMsg("预订名称不能为空!");
                return;
            }

            booking.Bookingname += "(" + booking.Bookingtime.Month + "-" + booking.Bookingtime.Day + ")";

            int rlt = BookingManager.AddBooking(booking);

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

            responder.WriteSuccessedMsg("新建预订成功!");
        }
Exemple #3
0
 /// <summary>
 /// 修改方法
 /// </summary>
 public static int UpdateBooking(Booking booking)
 {
     return DatabaseProvider.GetInstance().UpdateBooking(booking);
 }
Exemple #4
0
 /// <summary>
 /// 添加方法
 /// </summary>
 public static int AddBooking(Booking booking)
 {
     return DatabaseProvider.GetInstance().AddBooking(booking);
 }
Exemple #5
0
        public static Booking GetBooking(IDataReader reader)
        {
            Booking model = new Booking();

            model.Id = (reader["Id"] is DBNull ? Convert.ToInt32("0") : Convert.ToInt32(reader["Id"]));
            model.Uid = (reader["Uid"] is DBNull ? Convert.ToInt32("0") : Convert.ToInt32(reader["Uid"]));
            model.Realname = reader["Realname"].ToString();
            model.Bookingname = reader["Bookingname"].ToString();
            model.Bookingtime = (reader["Bookingtime"] is DBNull ? Convert.ToDateTime("1900-01-01") : Convert.ToDateTime(reader["Bookingtime"]));
            model.Isbooking = (reader["Isbooking"] is DBNull ? Convert.ToBoolean("false") : Convert.ToBoolean(reader["Isbooking"]));
            model.Issettle = (reader["Issettle"] is DBNull ? Convert.ToBoolean("false") : Convert.ToBoolean(reader["Issettle"]));
            model.Haserror = (reader["Haserror"] is DBNull ? Convert.ToBoolean("false") : Convert.ToBoolean(reader["Haserror"]));

            return model;
        }