コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (tbQuantity.Text != "")
            {
                Model.dao.RoomDao        RD  = new Model.dao.RoomDao();
                Model.dao.CustomerDao    CD  = new Model.dao.CustomerDao();
                Model.dao.ServiceDao     SD  = new Model.dao.ServiceDao();
                Model.dao.SrvOrderDao    SOD = new Model.dao.SrvOrderDao();
                Model.dao.OrderDetailDao ODD = new Model.dao.OrderDetailDao();


                Model.entity.SRVORDER    order       = new Model.entity.SRVORDER();
                Model.entity.ORDERDETAIL orderdetail = new Model.entity.ORDERDETAIL();

                order.CUSID         = CD.GetID(RD.GetIDCard(RoomName));
                order.SRVID         = SD.GetID(boxService.Text);
                order.ROOMID        = RD.GetID(RoomName);
                order.QUANTITY      = int.Parse(tbQuantity.Text);
                order.NOTE          = tbNote.Text;
                order.PAYMENTSTATUS = false;

                if (SOD.Add(order))
                {
                    DateTime now = DateTime.Now;

                    orderdetail.ORDERID  = SOD.GetInsertedSrvOrderId();
                    orderdetail.DISCOUNT = 0; //// warning
                    orderdetail.EMPID    = empid;
                    orderdetail.date     = now.ToString("dd/MM/yyyy HH:mm:ss");
                    orderdetail.PRICE    = SD.GetPrice(boxService.Text);

                    if (ODD.Add(orderdetail))
                    {
                        MessageBox.Show("Order Successfully !");
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Failed To Order !");
                }
            }
            else
            {
                MessageBox.Show("Please Enter Quantity!");
            }
        }
コード例 #2
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     Model.dao.ServiceDao     sd  = new Model.dao.ServiceDao();
     Model.dao.RoomDao        RD  = new Model.dao.RoomDao();
     Model.dao.CustomerDao    CD  = new Model.dao.CustomerDao();
     Model.dao.OrderDetailDao odd = new Model.dao.OrderDetailDao();
     Model.dao.SrvOrderDao    sod = new Model.dao.SrvOrderDao();
     if (CD.CheckCus(tbIDCard.Text))
     {
         if (CheckEmpty())
         {
             Model.entity.SRVORDER order = new Model.entity.SRVORDER();
             order.CUSID  = CD.GetID(tbIDCard.Text);
             order.ROOMID = RD.GetID(RoomName);
             if (sd.CheckServiceName(2, RoomName))
             {
                 order.SRVID = sd.GetServiceId(RoomName);
             }
             else
             {
                 Model.entity.SERVICE s = new Model.entity.SERVICE();
                 s.NAME   = RD.GetSrvName(RoomName);
                 s.TYPE   = "Room";
                 s.PRICE  = RD.GetPrice(RoomName);
                 s.STATUS = "Active";
                 if (sd.Add(s))
                 {
                     order.SRVID = sd.GetServiceId(RoomName);
                 }
             }
             order.QUANTITY      = 1;
             order.PAYMENTSTATUS = false;
             if (sod.Add(order))
             {
                 DateTime now = DateTime.Now;
                 Model.entity.ORDERDETAIL orderdetail = new Model.entity.ORDERDETAIL();
                 orderdetail.date     = now.ToString("dd/MM/yyyy HH:mm:ss");
                 orderdetail.DISCOUNT = 0;
                 orderdetail.EMPID    = empid;
                 orderdetail.PRICE    = RD.GetPrice(RoomName);
                 orderdetail.ORDERID  = sod.GetInsertedSrvOrderId();
                 if (odd.Add(orderdetail))
                 {
                     if (Status == "Booked")
                     {
                         Model.dao.BookingDao BD = new Model.dao.BookingDao();
                         BD.ChangeBookingStatus(CD.GetID(tbIDCard.Text), RD.GetID(RoomName));
                     }
                     RD.DisableRoom(4, RoomName);
                     MessageBox.Show("Check In Successfully!");
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Failed To Check In!");
                 }
             }
             else
             {
                 MessageBox.Show("Failed To Check In!");
             }
         }
     }
     else
     {
         if (CheckEmpty())
         {
             Model.entity.CUSTOMER c = new Model.entity.CUSTOMER();
             c.IDCARD      = tbIDCard.Text;
             c.NAME        = tbCusName.Text;
             c.AGE         = int.Parse(tbCusAge.Text);
             c.PHONENUMBER = tbCusPhone.Text;
             c.ADDRESS     = tbCusAddress.Text;
             if (CD.Add(c))
             {
                 Model.entity.SRVORDER order = new Model.entity.SRVORDER();
                 order.CUSID  = CD.GetID(tbIDCard.Text);
                 order.ROOMID = RD.GetID(RoomName);
                 if (sd.CheckServiceName(2, RoomName))
                 {
                     order.SRVID = sd.GetServiceId(RoomName);
                 }
                 else
                 {
                     Model.entity.SERVICE s = new Model.entity.SERVICE();
                     s.NAME   = RD.GetSrvName(RoomName);
                     s.TYPE   = "Room";
                     s.PRICE  = RD.GetPrice(RoomName);
                     s.STATUS = "Active";
                     if (sd.Add(s))
                     {
                         order.SRVID = sd.GetServiceId(RoomName);
                     }
                 }
                 order.QUANTITY      = 1;
                 order.PAYMENTSTATUS = false;
                 if (sod.Add(order))
                 {
                     DateTime now = DateTime.Now;
                     Model.entity.ORDERDETAIL orderdetail = new Model.entity.ORDERDETAIL();
                     orderdetail.date     = now.ToString("dd/MM/yyyy HH:mm:ss");
                     orderdetail.DISCOUNT = 0;
                     orderdetail.EMPID    = empid;
                     orderdetail.PRICE    = RD.GetPrice(RoomName);
                     orderdetail.ORDERID  = sod.GetInsertedSrvOrderId();
                     if (odd.Add(orderdetail))
                     {
                         RD.DisableRoom(4, RoomName);
                         MessageBox.Show("Check In Successfully!");
                         this.Close();
                     }
                     else
                     {
                         MessageBox.Show("Failed To Check In!");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Failed To Check In!");
                 }
             }
             else
             {
                 MessageBox.Show("Failed To Add Customer!");
             }
         }
     }
 }