Ejemplo n.º 1
0
        // 上传新订单
        private void SubmitNewOrder()
        {
            StatementTable order = new StatementTable()             // 创建订单对象
            {
                IDCard        = txt_IDcard.Text,
                PaymentMethod = cbox_payWay.Text,
                CheckInTime   = (DateTime)dtpicker_begin.Value,
                CheckoutTime  = (DateTime)dtpicker_leave.Value,
                Room          = new RoomSchedules
                {
                    Floor      = Dgv_RoomList.SelectedCells[1].Value.ToString().Trim(),
                    RoomNumber = Dgv_RoomList.SelectedCells[0].Value.ToString().Trim(),
                    RoomType   = GetRoomStatus(Dgv_RoomList.SelectedCells[2].Value.ToString().Trim()),
                    RoomStatus = new RoomStatus {
                        No = 2, StatusName = "占用"
                    }
                },
                Status = new OrderStatusTable {
                    Number = frm == null ? 2 : 1, State = frm == null ? "开始" : "未开始"
                },
                OperationManager = Cun.ID,
                TotalConsumption = (double)Dgv_RoomList.SelectedCells[1].Value * double.Parse(Discount.Text),
                Days             = 1
            };

            orderManager.AddOrderRecord(order);                     // 向数据库添加本次订单记录
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据订单状态查询指定记录
        /// </summary>
        /// <param name="dataTable">订单记录表</param>
        /// <param name="order">要查询的订单条件</param>
        /// <returns>返回满足条件的订单记录</returns>
        public DataTable CompareStatementStatus(DataTable dataTable, StatementTable order)
        {
            // 查询满足指定状态的订单记录
            var table = dataTable.AsEnumerable().Where(r => r["Status"].Equals(order.Status.Number));

            return(table.CopyToDataTable());                             // 返回得到的记录
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据订单身份证查询指定记录
        /// </summary>
        /// <param name="dataTable">订单记录表</param>
        /// <param name="order">要查询的订单条件</param>
        /// <returns>返回满足条件的订单记录</returns>
        public DataTable CompareStatementIDCard(DataTable dataTable, StatementTable order)
        {
            // 根据指定身份证查询订单记录
            var table = dataTable.AsEnumerable().Where(r => r["IDCard"].Equals(order.IDCard));

            return(table.CopyToDataTable());                             // 返回得到的记录
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据订单状态查询指定记录
        /// </summary>
        /// <param name="dataTable">订单记录表</param>
        /// <param name="order">要查询的订单条件</param>
        /// <returns>返回满足条件的订单记录</returns>
        public DataTable CompareStatementStatus(DataTable dataTable, StatementTable order)
        {
            // 查询满足指定状态的订单记录
            var table = from row in dataTable.AsEnumerable()
                        where row["Status"].Equals(order.Status.Number)
                        select row;

            return(table.CopyToDataTable());                             // 返回得到的记录
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据订单身份证查询指定记录
        /// </summary>
        /// <param name="dataTable">订单记录表</param>
        /// <param name="order">要查询的订单条件</param>
        /// <returns>返回满足条件的订单记录</returns>
        public DataTable CompareStatementIDCard(DataTable dataTable, StatementTable order)
        {
            // 根据指定身份证查询订单记录
            var table = from row in dataTable.AsEnumerable()
                        where row["IDCard"].Equals(order.IDCard)
                        select row;

            return(table.CopyToDataTable());                             // 返回得到的记录
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据订单编号查询指定记录
        /// </summary>
        /// <param name="dataTable">订单记录表</param>
        /// <param name="order">要查询的订单条件</param>
        /// <returns>返回满足条件的订单记录</returns>
        public DataTable CompareStatementNo(DataTable dataTable, StatementTable order)
        {
            // 根据指定订单编号查询记录
            var table = from row in dataTable.AsEnumerable()
                        where row["OrderNumber"].ToString().Trim().Equals(order.OrderNumber.ToString())
                        select row;

            return(table.CopyToDataTable());                             // 返回得到的记录
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 删除指定的订单记录
 /// </summary>
 /// <param name="order">要删除的订单信息</param>
 public void DeleteOrderRecord(StatementTable order)
 {
     // 遍历系统临时数据库搜索满足条件的记录
     foreach (DataRow row in HotelData.Data.Tables["StatementTable"].Rows)
     {
         // 根据订单编号删除记录
         if (order.OrderNumber.Equals(row["OrderNumber"].ToString().Trim()))
         {
             HotelData.Data.Tables["StatementTable"].Rows.Remove(row);
             break;
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 添加需要的订单记录
 /// </summary>
 /// <param name="order">需要添加的订单记录</param>
 public void AddOrderRecord(StatementTable order)
 {
     if (order.OrderNumber != null)                              // 判断记录是否满足条件
     {
         DataRow row = HotelData.Data.Tables["StatementTable"].NewRow();
         row["OrderNumber"]      = order.OrderNumber;
         row["IDCard"]           = order.IDCard;
         row["TotalConsumption"] = order.TotalConsumption;
         row["PaymentMethod"]    = order.PaymentMethod;
         row["CheckInTime"]      = order.CheckInTime.ToString();
         row["CheckoutTime"]     = order.CheckoutTime.ToString();
         row["OperationManaer"]  = order.OperationManager;
         row["Status"]           = order.Status.Number;
         row["RoomNumber"]       = order.Room.RoomNumber;
         HotelData.Data.Tables["StatementTable"].Rows.Add(row);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 搜索满足条件或全部的订单信息
        /// </summary>
        /// <param name="order">查询的订单信息</param>
        /// <returns>返回满足条件的订单列表</returns>
        public DataTable SeekOrderRecord(StatementTable order)
        {
            DataTable table = HotelData.Data.Tables["StatementTable"];  // 创建临时数据表获取所有订单记录

            // 根据指定的条件执行相应的查询方式
            if (order.OrderNumber != null)                              // 是否根据编号查询订单
            {
                CompareStatementNo(table, order);
            }
            else if (order.IDCard != null)                              // 是否根据身份证查询订单
            {
                CompareStatementIDCard(table, order);
            }
            else if (order.Status != null)                              // 是否根据订单状态查询订单
            {
                CompareStatementStatus(table, order);
            }
            return(table);                                               // 返回得到的订单记录
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 修改指定的订单记录 (修改时必须传入订单的所有信息)
 /// </summary>
 /// <param name="order">要修改的订单信息</param>
 public void AmendOrderRecord(StatementTable order)
 {
     // 遍历系统临时数据库搜索满足条件的记录
     foreach (DataRow row in HotelData.Data.Tables["StatementTable"].Rows)
     {
         // 根据订单编号修改指定的记录
         if (order.OrderNumber.Equals(row["OrderNumber"].ToString().Trim()))
         {
             row["IDCard"]           = order.IDCard;
             row["TotalConsumption"] = order.TotalConsumption;
             row["PaymentMethod"]    = order.PaymentMethod;
             row["CheckInTime"]      = order.CheckInTime.ToString();
             row["CheckoutTime"]     = order.CheckoutTime.ToString();
             row["OperationManaer"]  = order.OperationManager;
             row["Status"]           = order.Status.Number;
             row["RoomNumber"]       = order.Room.RoomNumber;
             break;
         }
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 添加需要的订单记录
 /// </summary>
 /// <param name="order">需要添加的订单记录</param>
 public void AddOrderRecord(StatementTable order)
 {
     service.AddOrderRecord(order);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 删除指定的订单记录
 /// </summary>
 /// <param name="order">要删除的订单信息</param>
 public void DeleteOrderRecord(StatementTable order)
 {
     service.DeleteOrderRecord(order);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 确定按钮,同时修改用户表,订单表,房间表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button2_Click(object sender, EventArgs e)
        {
            UserManager um = new UserManager();//用户表修改

            DataTable dt = um.CompareUserIDCard(dgvUser.SelectedRows[0].Cells[10].Value.ToString());
            UserTable ut = new UserTable();

            ut.Age    = int.Parse(dt.Rows[0]["Age"].ToString());
            ut.Gender = dt.Rows[0]["Gender"].ToString();
            ut.IDCard = dt.Rows[0]["IDCard"].ToString();
            ut.Member = new MembershipTable()
            {
                MemberNumber = int.Parse(dt.Rows[0]["Member"].ToString())
            };
            ut.TelephoneNumber = dt.Rows[0]["TelephoneNumber"].ToString();
            ut.UserName        = dt.Rows[0]["UserName"].ToString();
            if (cbFuKuan.Text == "余额支付")
            {
                ut.Balance = double.Parse(txtLing.Text) < 0 ? 0 : double.Parse(txtLing.Text);
            }

            RoomManager rm = new RoomManager();//房间表修改

            RoomSchedules rs = new RoomSchedules();

            rs.Floor      = dgvUser.SelectedRows[0].Cells[11].Value.ToString();
            rs.RoomNumber = dgvUser.SelectedRows[0].Cells[1].Value.ToString();
            rs.RoomType   = new RoomTypeTable()
            {
                No = int.Parse(dgvUser.SelectedRows[0].Cells[12].Value.ToString())
            };
            rs.RoomStatus = new RoomStatus()
            {
                No         = 1,
                StatusName = "空闲"
            };


            OrderManager om = new OrderManager();//订单表修改
            DataTable    ad = om.SeekOrderRecord(new StatementTable()
            {
                OrderNumber = dgvUser.SelectedRows[0].Cells[0].Value.ToString().Trim()
            });

            StatementTable st = new StatementTable();

            for (int i = 0; i < ad.Rows.Count; i++)
            {
                if (ad.Rows[i]["OrderNumber"].ToString().Trim() == dgvUser.SelectedRows[0].Cells[0].Value.ToString().Trim())
                {
                    st = new StatementTable()
                    {
                        CheckInTime      = DateTime.Parse(ad.Rows[i]["CheckInTime"].ToString()),
                        CheckoutTime     = DateTime.Now,
                        IDCard           = ad.Rows[i]["IDCard"].ToString(),
                        OperationManager = int.Parse(ad.Rows[i]["OperationManaer"].ToString()),
                        OrderNumber      = ad.Rows[i]["OrderNumber"].ToString(),
                        PaymentMethod    = cbFuKuan.Text,
                        Room             = new RoomSchedules()
                        {
                            RoomNumber = ad.Rows[i]["RoomNumber"].ToString()
                        },
                        TotalConsumption = double.Parse(txtYinFu.Text),
                        Status           = new OrderStatusTable()
                        {
                            Number = 3,
                            State  = "结束"
                        }
                    };
                    break;
                }
            }

            //集中修改三张表
            um.AmendUserRecord(ut);
            om.AmendOrderRecord(st);
            rm.RoomUpdate(rs.RoomNumber, rs);

            //打印订单
            string path = string.Format("{0}.txt", dgvUser.Rows[0].Cells[0].Value.ToString().Trim());

            using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine("* **************************");
                sw.WriteLine("租房客人:{0}", dgvUser.Rows [0].Cells [2].Value.ToString().Trim());
                sw.WriteLine("所住房间:{0}", dgvUser.Rows [0].Cells [1].Value.ToString().Trim());
                sw.WriteLine("入住时间:{0}", dgvUser.Rows [0].Cells [4].Value.ToString().Trim());
                sw.WriteLine("结账时间:{0}", dgvUser.Rows [0].Cells [5].Value.ToString().Trim());
                sw.WriteLine("付款方式:{0}", dgvUser.Rows [0].Cells [7].Value.ToString().Trim());
                sw.WriteLine("应付金额:{0}", dgvUser.Rows [0].Cells [6].Value.ToString().Trim());
                sw.WriteLine("实付金额:{0}", dgvUser.Rows [0].Cells [9].Value.ToString().Trim());
                sw.WriteLine("折扣:{0}", dgvUser.Rows [0].Cells [8].Value.ToString().Trim());
                sw.WriteLine("* **************************");
                sw.Close();
            }

            dgvRoom.DataSource = stm.Statement(txtRoomName.Text.Trim());
            dgvUser.DataSource = null;

            txtLing.Text    = "";
            txtDingDan.Text = "";
            txtYinFu.Text   = "";
            txtZon.Text     = "";
            cbFuKuan.Text   = "";
            txtZon.Enabled  = false;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// 搜索满足条件或全部的订单信息
 /// </summary>
 /// <param name="order">查询的订单信息</param>
 /// <returns>返回满足条件的订单列表</returns>
 public DataTable SeekOrderRecord(StatementTable statement)
 {
     return(service.SeekOrderRecord(statement));
 }