Beispiel #1
0
 /// <summary>
 /// 删除一行时执行
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GuestTable_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     SqlDataSource1.DeleteCommand = "SELECT * FROM HOTEL WHERE hID='-1'";
     GuestManager.DeleteGuest(new Guest
     {
         GuestID   = e.Values["gID"].ToString().Trim(),
         GuestName = e.Values["gName"].ToString().Trim(),
         Username  = UsernameLabel.Text
     });
     GuestTable.DataBind();
 }
Beispiel #2
0
        public IHttpActionResult UpdateTable(int id, GuestTable table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _tableManagementService.UpdateTable(id, table);

            return(Ok());
        }
Beispiel #3
0
        public void UpdateTable(int id, GuestTable table)
        {
            //throw new NotImplementedException();

            var newTable = _tableManagementRepository.GetGuestTableById(id);

            newTable.UpdateDate       = DateTime.Now;
            newTable.LastUpdateTime   = DateTime.Now;
            newTable.TableStatus      = table.TableStatus;
            newTable.TableSize        = table.TableSize;
            newTable.MaxSeatsCapacity = table.MaxSeatsCapacity;

            _tableManagementRepository.UpdateTable(id, newTable);
        }
        public void UpdateTable(int id, GuestTable table)
        {
            //throw new NotImplementedException();

            context.GuestTables.Attach(table);

            var entry = context.Entry(table);

            entry.State = EntityState.Modified;

            try
            {
                context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException dbUpdateConcurrencyException)
            {
                var msg = dbUpdateConcurrencyException.Message;
            }
        }
Beispiel #5
0
        public IHttpActionResult AddGuestTable(GuestTable table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //set default values
            //
            table.TableStatus    = "Available";
            table.CreateDate     = DateTime.Now;
            table.UpdateDate     = DateTime.Now;
            table.LastUpdateTime = DateTime.Now;

            _tableManagementService.AddTable(table);


            return(Ok());
        }
Beispiel #6
0
        public void UpdateTableStatus(GuestTable table)
        {
            context.GuestTables.Attach(table);

            var entry = context.Entry(table);

            entry.State = EntityState.Modified;

            try
            {
                context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException dbUpdateConcurrencyException)
            {
                var msg = dbUpdateConcurrencyException.Message;

                throw;
            }
        }
Beispiel #7
0
 /// <summary>
 /// 修改一行时执行
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GuestTable_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     SqlDataSource1.UpdateCommand = "SELECT * FROM HOTEL WHERE hID='-1'";
     if (!Regex.IsMatch(e.NewValues["gID"].ToString(), "\\d{14}"))
     {
         //身份证号不为14位数字
         Response.Write("<script>alert('身份证号不正确!');</script>");
         return;
     }
     GuestManager.UpdateGuset(new Guest
     {
         Username  = UsernameLabel.Text,
         GuestID   = e.OldValues["gID"].ToString().Trim(),
         GuestName = e.OldValues["gName"].ToString()
     }, new Guest
     {
         Username  = UsernameLabel.Text,
         GuestID   = e.NewValues["gID"].ToString().Trim(),
         GuestName = e.NewValues["gName"].ToString()
     });
     GuestTable.DataBind();
 }
Beispiel #8
0
        /// <summary>
        /// 添加旅客按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AddButton_OnClick(object sender, EventArgs e)
        {
            if (GuestName.Text == "" || GuestID.Text == "" ||
                !Regex.IsMatch(GuestID.Text, "\\d{14}"))
            {
                Response.Write("<script>alert('旅客信息不正确!');</script>");
                return;
            }

            try
            {
                GuestManager.AddGuest(new Guest
                {
                    GuestID   = GuestID.Text,
                    GuestName = GuestName.Text.Trim(),
                    Username  = UsernameLabel.Text
                });
            }
            catch
            {
                Response.Write("<script>alert('该旅客已存在!');</script>");
            }
            GuestTable.DataBind();
        }
 public void AddGuestTable(GuestTable table)
 {
     context.GuestTables.Add(table);
     context.SaveChanges();
 }
Beispiel #10
0
 /// <summary>
 /// 取消修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GuestTable_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     GuestTable.EditIndex = -1;
     GuestTable.DataBind();
 }
Beispiel #11
0
 public void AddTable(GuestTable table)
 {
     _tableManagementRepository.AddGuestTable(table);
 }