Exemplo n.º 1
0
 //=======================================================
 //Author: LinhTing
 //Function : Update Room
 //=======================================================
 public int Update(Rooms Rooms)
 {
     try
     {
         aDatabaseDA.Rooms.AddOrUpdate(Rooms);
         return aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("RoomBO.Update :" + ex.Message));
     }
 }
Exemplo n.º 2
0
 public List<RoomExtStatusEN> GetListUsingRooms(DateTime Now)
 {
     try
     {
         List<RoomExtStatusEN> aListTemp = new List<RoomExtStatusEN>();
         RoomsBO aRoomsBO = new RoomsBO();
         Rooms aRooms = new Rooms();
         aListTemp = aRoomsBO.GetListStatusRoom(Now).Where(p => p.RoomStatus == 3).ToList();
         return aListTemp;
     }
     catch (Exception ex)
     {
         throw new Exception("UsingServiceTask.GetListUsingRooms\n" + ex.ToString());
     }
 }
Exemplo n.º 3
0
 //hiennv
 public List<RoomExtStatusEN> GetListUsingRooms_ByCode(DateTime Now ,string code)
 {
     try
     {
         List<RoomExtStatusEN> aListTemp = new List<RoomExtStatusEN>();
         RoomsBO aRoomsBO = new RoomsBO();
         Rooms aRooms = new Rooms();
         if (String.IsNullOrEmpty(code) == true)
         {
             aListTemp = aRoomsBO.GetListStatusRoom(Now).Where(p => p.RoomStatus == 3).ToList();
         }
         else
         {
             aListTemp = aRoomsBO.GetListStatusRoom(Now).Where(p => p.RoomStatus == 3).Where(p => p.Code == code).ToList();
         }
         return aListTemp;
     }
     catch (Exception ex)
     {
         throw new Exception("UsingServiceTask.GetListUsingRooms_ByCode\n" + ex.ToString());
     }
 }
        private void btnAddRoom_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateData() == true)
                {
                    List<Rooms> aListRoomTemp = aRoomsBO.Select_All();
                    Rooms aRoom = new Rooms();
                    aRoom.Sku = txtSku.Text;
                    aRoom.Bed1 = !String.IsNullOrEmpty(txtBed1.Text) ? Convert.ToInt32(txtBed1.Text) : 0;
                    aRoom.Bed2 = !String.IsNullOrEmpty(txtBed2.Text) ? Convert.ToInt32(txtBed2.Text) : 0;
                    aRoom.Disable = bool.Parse(cbbDisable.Text);
                    aRoom.Status = int.Parse(cbbStatus.Text);
                    aRoom.Type = Convert.ToInt32(lueRoomType.EditValue);
                    aRoom.Image = (Byte[])new ImageConverter().ConvertTo(pbxImage.Image, typeof(Byte[]));

                    TimeSpan Codespan = new TimeSpan(DateTime.Now.Ticks);
                    string b = Math.Floor(Codespan.TotalSeconds).ToString();

                    for (int i = 1; i <= 2; i++)
                    {
                        switch (i)
                        {
                            case 1:
                                Rooms a1 = aListRoomTemp.Find(p => p.Sku == txtSku.Text & p.IDLang == 1);
                                if (a1 == null)
                                {
                                    aRoom.CostRef = String.IsNullOrEmpty(txtCostRef1.Text) == true ? 0 : Decimal.Parse(txtCostRef1.Text);

                                    aRoom.CostUnit = txtCostUnit1.Text;
                                    aRoom.IDLang = 1;
                                    aRoom.Info = txtInfo1.Text;
                                    aRoom.Intro = txtIntro1.Text;
                                    aRoom.Code = b;
                                    aRoomsBO.Insert(aRoom);
                                }
                                else
                                {
                                    MessageBox.Show("Mã phòng này đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                break;
                            case 2:
                                Rooms a2 = aListRoomTemp.Find(p => p.Sku == txtSku.Text & p.IDLang == 2);
                                if (a2 == null)
                                {
                                    aRoom.CostRef = String.IsNullOrEmpty(txtCostRef1.Text) == true ? 0 : Decimal.Parse(txtCostRef1.Text);
                                    aRoom.CostUnit = txtCostUnit2.Text;
                                    aRoom.IDLang = 2;
                                    aRoom.Info = txtInfo2.Text;
                                    aRoom.Intro = txtIntro2.Text;
                                    aRoom.Code = b;
                                    aRoomsBO.Insert(aRoom);
                                }
                                else
                                {
                                    MessageBox.Show("Mã phòng này đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                break;

                        }

                    }

                    MessageBox.Show("Thêm phòng thành công");
                    this.Close();
                    if (this.afrmLst_Rooms != null)
                    {
                        this.afrmLst_Rooms.ReloadData();
                        if(this.afrmLst_Rooms.afrmMain !=null)
                        {
                            this.afrmLst_Rooms.afrmMain.ReloadData();
                        }
                    }
                    if(this.afrmMain !=null)
                    {
                        this.afrmMain.ReloadData();
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_Rooms.btnAddRoom_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ResetFormWhenTimeChange()
        {
            if (aBookingRs.CustomerType == 1)
            {
                lblCustomerType.Text = "Khách nhà nước";
            }
            else if (aBookingRs.CustomerType == 2)
            {
                lblCustomerType.Text = "Cty ngoài";
            }
            else if (aBookingRs.CustomerType == 3)
            {
                lblCustomerType.Text = "Khách lẻ";
            }
            else if (aBookingRs.CustomerType == 4)
            {
                lblCustomerType.Text = "Khách vãng lai";
            }

            CustomersBO aCustomersBO = new CustomersBO();
            CustomerInfoEN aCustomers = new CustomerInfoEN();
            aCustomers = new CustomerInfoEN (aCustomersBO.Select_ByID(aBookingRs.IDCustomer));

            lblCustomer.Text = aCustomers.Name;
            lblTel.Text = aCustomers.Tel;

            CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
            CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingRs.IDCustomerGroup);
            lblGroup.Text = aCustomerGroups.Name;

            CompaniesBO aCompaniesBO = new CompaniesBO();
            lblCompany.Text = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany).Name;

            // Fill All Customer

            dgvAvailableCustomers.DataSource = ConvertListCustomer ((new CustomersBO()).Select_All());

            lueRooms.Properties.DataSource = this.GetAvaiableRoom();
            lueRooms.Properties.ValueMember = "Code";
            lueRooms.Properties.DisplayMember = "Sku";

            RoomsBO aRoomsBO = new RoomsBO();
            Rooms aRooms = new Rooms();
            aRooms = aRoomsBO.Select_ByCodeRoom(this.aBookingRoom.CodeRoom, 1);

            lueRooms.Properties.NullText = aRooms.Sku;
            lueRooms.SelectedText = aRooms.Sku;
            lueRooms.EditValue = aRooms.Code;

            BookingRoomsMembersBO aBookingRoomsMembersBO = new BookingRoomsMembersBO();
            List<BookingRoomsMembers> aListBookingRoomsMembers = aBookingRoomsMembersBO.Select_ByIDBookingRoom (this.aBookingRoom.ID);

            dgvSelectCustomers.DataSource = GetCustomers(aListBookingRoomsMembers);
        }
        private void InitForm()
        {
            // Kiem tra xem phong dang o che do checkIn hay book phong
            if (this.aBookingRoom.Status < 3)
            {
                dtpCheckIn.Text = aBookingRoom.CheckInPlan.ToString();

                dtpCheckOut.Text = aBookingRoom.CheckOutPlan.ToString();
            }
            else if (this.aBookingRoom.Status == 3)  // Phong da checkIn
            {
                dtpCheckIn.Text = DateTime.Now.ToString();
                dtpCheckOut.Text = aBookingRoom.CheckOutPlan.ToString();
            }

            if (aBookingRs.CustomerType == 1)
            {
                lblCustomerType.Text = "Khách nhà nước";
            }
            else if (aBookingRs.CustomerType == 2)
            {
                lblCustomerType.Text = "Cty ngoài";
            }
            else if (aBookingRs.CustomerType == 3)
            {
                lblCustomerType.Text = "Khách lẻ";
            }
            else if (aBookingRs.CustomerType == 4)
            {
                lblCustomerType.Text = "Khách vãng lai";
            }

            CustomersBO aCustomersBO = new CustomersBO();
            CustomerInfoEN aCustomers = new CustomerInfoEN();
            aCustomers = new CustomerInfoEN (aCustomersBO.Select_ByID(aBookingRs.IDCustomer));

            lblCustomer.Text = aCustomers.Name;
            lblTel.Text = aCustomers.Tel;

            CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
            CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingRs.IDCustomerGroup);
            lblGroup.Text = aCustomerGroups.Name;

            CompaniesBO aCompaniesBO = new CompaniesBO();
            lblCompany.Text = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany).Name;

            // Fill All Customer

            dgvAvailableCustomers.DataSource = ConvertListCustomer ((new CustomersBO()).Select_All());

            lueRooms.Properties.DataSource = this.GetAvaiableRoom();
            lueRooms.Properties.ValueMember = "Code";
            lueRooms.Properties.DisplayMember = "Sku";

            RoomsBO aRoomsBO = new RoomsBO();
            Rooms aRooms = new Rooms();
            aRooms = aRoomsBO.Select_ByCodeRoom(this.aBookingRoom.CodeRoom, 1);

            lueRooms.Properties.NullText = aRooms.Sku;
            lueRooms.SelectedText = aRooms.Sku;
            lueRooms.EditValue = aRooms.Code;

            BookingRoomsMembersBO aBookingRoomsMembersBO = new BookingRoomsMembersBO();
            List<BookingRoomsMembers> aListBookingRoomsMembers = aBookingRoomsMembersBO.Select_ByIDBookingRoom (this.aBookingRoom.ID);

            dgvSelectCustomers.DataSource = GetCustomers(aListBookingRoomsMembers);

            //this.aChangeRoomEn.InsertItemChangeRooms()
        }
        public List<Rooms> GetListAvailableRooms(DateTime From, DateTime To, int Lang)
        {
            try
            {

                List<sp_Rooms_GetAvailable_ByTime_ByLang_Result> aListTemp = new List<sp_Rooms_GetAvailable_ByTime_ByLang_Result>();
                aListTemp = aDatabaseDA.sp_Rooms_GetAvailable_ByTime_ByLang(From, To, Lang).ToList();

                List<Rooms> aListReturn = new List<Rooms>();
                Rooms aRooms;

                for (int i = 0; i < aListTemp.Count; i++)
                {
                    aRooms = new Rooms();
                    aRooms.ID = aListTemp[i].ID;
                    aRooms.Sku = aListTemp[i].Sku;
                    aRooms.Image = aListTemp[i].Image;
                    aRooms.Bed1 = aListTemp[i].Bed1;
                    aRooms.Bed2 = aListTemp[i].Bed2;
                    aRooms.Intro = aListTemp[i].Intro;
                    aRooms.Info = aListTemp[i].Info;
                    aRooms.CostRef = aListTemp[i].CostRef;
                    aRooms.CostUnit = aListTemp[i].CostUnit;
                    aRooms.Type = aListTemp[i].Type;
                    aRooms.Status = aListTemp[i].Status;
                    aRooms.Disable = aListTemp[i].Disable;
                    aRooms.Code = aListTemp[i].Code;
                    aRooms.IDLang = aListTemp[i].IDLang;
                    aListReturn.Add(aRooms);
                }

                return aListReturn;
            }
            catch (Exception ex)
            {

                throw new Exception("ReceptionTaskBO.CheckInGoverment\n" + ex.ToString());
            }
        }