Example #1
0
        public void UpdateRoomBillingEntries(DateTime period, int clientId, int roomId, int accountId, decimal entries)
        {
            RoomBilling rb = Session.Query <RoomBilling>().FirstOrDefault(x => x.Period == period && x.ClientID == clientId && x.RoomID == roomId && x.AccountID == accountId);

            if (rb == null)
            {
                throw new Exception($"Cannot find RoomBilling record for Period = #{period:yyyy-MM-dd}#, ClientID = {clientId}, RoomID = {roomId}, AccountID = {accountId}");
            }

            rb.Entries = entries;

            RoomBillingUserApportionData appData = Session.Query <RoomBillingUserApportionData>().FirstOrDefault(x => x.Period == period && x.Client.ClientID == clientId && x.Room.RoomID == roomId && x.Account.AccountID == accountId);

            if (appData == null)
            {
                appData = new RoomBillingUserApportionData()
                {
                    Client     = Require <Client>(rb.ClientID),
                    Account    = Require <Account>(rb.AccountID),
                    Room       = Require <Room>(rb.RoomID),
                    Period     = period,
                    ChargeDays = 0,
                    Entries    = 0
                };

                Session.Save(appData);
            }
            else
            {
                appData.Entries = entries;
                Session.Update(appData);
            }
        }
        public static IRoomBilling CreateRoomBillingItem(bool isTemp)
        {
            IRoomBilling result;

            if (isTemp)
            {
                result = new RoomBillingTemp();
            }
            else
            {
                result = new RoomBilling();
            }

            return(result);
        }
Example #3
0
        protected void Button_Click(object sender, EventArgs e)
        {
            var button = sender as Button;

            if (button == null)
                return;

            var commandName = button.CommandName;

            if (string.IsNullOrEmpty(commandName))
                return;

            switch (commandName.ToLower())
            {
                case "update":
                    {
                        //Update data
                        var roomBilling = new RoomBilling
                        {
                            RoomId = Id,
                            UserId = TextHelper.ToInteger(ddl_patients.SelectedValue),
                            RoomBillingEquipments = GetRoomBillingEquipments(),
                        };

                        var isRoomVacant = _objRoomBilling.IsRoomVacant(Id);

                        if (!isRoomVacant)
                            roomBilling.RoomBillingId = _objRoomBilling.GetIdByRoomId(Id);

                        if (isRoomVacant ? _objRoomBilling.Insert(roomBilling) : UpdateRoom(roomBilling))
                        {
                            //Redirect
                            Redirect("~/Admin/Room/");
                        }
                    }
                    break;

                case "checkout":
                    {
                        var userId = TextHelper.ToInteger(ddl_patients.SelectedValue);

                        //Load user billing address
                        LoadUserAddresses(userId);

                        //Disable additional equipments
                        SetAdditionalEquipmentTextbox(false);

                        //Disable Checkout button
                        btn_checkout.Enabled = false;

                        //Disable Update Button
                        btn_update.Enabled = false;

                        //Disable dropdownlist
                        ddl_patients.Enabled = false;

                        pnl_address.Visible = true;

                        up_address.Update();
                    }
                    break;

                case "newbill":
                    {
                        using (var transactionScope = new TransactionScope())
                        {
                            var userId = TextHelper.ToInteger(ddl_patients.SelectedValue);

                            if (userId == null || userId <= 0)
                                return;

                            var userBillingAddress = new UserBillingAddress
                            {
                                FullName = txt_fullname.Text,
                                AddressLine1 = txt_address1.Text,
                                AddressLine2 = txt_address2.Text,
                                City = txt_city.Text,
                                State = txt_state.Text,
                                CountryId = TextHelper.ToInteger(ddl_country.SelectedValue),
                                PostalCode = txt_postalcode.Text,
                                PhoneNumber = txt_phone.Text,
                                UserId = (int)userId
                            };

                            int addressId;

                            if (!_objUserBillingAddress.Insert(userBillingAddress, out addressId))
                                return;

                            //Get room billing Id
                            var roomBillingId = _objRoomBilling.GetIdByRoomId(Id);

                            //return if room billing id does not exist
                            if (roomBillingId <= 0)
                                return;

                            int checkOutId;

                            if (!_objRoomBilling.CheckOutRoom(Id, addressId, out checkOutId))
                                return;

                            transactionScope.Complete();

                            Response.Redirect(string.Format("ViewBill.aspx?id={0}", checkOutId));
                        }

                    }
                    break;

                case "existingbill":
                    {
                        var addressId = TextHelper.ToInteger(button.CommandArgument);

                        if (addressId == null)
                            return;

                        int checkOutId;

                        if (!_objRoomBilling.CheckOutRoom(Id, (int)addressId, out checkOutId))
                            return;

                        Response.Redirect(string.Format("ViewBill.aspx?id={0}", checkOutId));
                    }
                    break;

                case "cancel":

                        //Disable additional equipments
                        SetAdditionalEquipmentTextbox(true);

                        //Disable Checkout button
                        btn_checkout.Enabled = true;

                        //Disable Update Button
                        btn_update.Enabled = true;

                        //Disable dropdownlist
                        ddl_patients.Enabled = true;

                        pnl_address.Visible = false;

                        up_address.Update();
                    break;
            }
        }
Example #4
0
        private void RoomsServices(int idCus)
        {
            button3.Visible = true;
            panel4.Visible  = true;
            panel5.Visible  = true;
            total           = 0;
            ShowInforCus();
            BoxRooms.Visible = true;
            foreach (Control item in BoxRooms.Controls)
            {
                BoxRooms.Controls.Remove(item);
            }

            var BillCus = managerHotel.Bills.Where(x => x.id_cus == idCus).FirstOrDefault();

            idBill             = BillCus.id;
            labelDateFrom.Text = BillCus.dateFrom;
            labelDateTo.Text   = BillCus.dateTo;
            labelPrepay.Text   = double.Parse(BillCus.Prepay.ToString()).ToString("#,###", cull.NumberFormat);
            valPrepay          = (int)BillCus.Prepay;
            InterBilled(BillCus.id);
            //lấy ngày bắt đầu và kết thúc để tính tiền
            DateTime start     = Convert.ToDateTime(BillCus.dateFrom);
            DateTime end       = Convert.ToDateTime(BillCus.dateTo);
            TimeSpan rangeDate = end - start;

            var BillDetailRoom = managerHotel.Details_Bills.Where(x => x.id_bill == BillCus.id).Select(x => x.id_room);
            int number         = 0;
            int tam            = 0;

            foreach (int idR in BillDetailRoom)
            {
                if (tam != idR)
                {
                    tam = idR;
                    number++;
                    //Details_Bill id = (Details_Bill) idR;
                    var      room = managerHotel.Rooms.Where(x => x.id == idR).FirstOrDefault();
                    GroupBox gb   = new GroupBox();
                    gb         = RoomBilling.Clone();
                    gb.Text    = "Phòng " + room.name;
                    gb.Visible = true;
                    gb.Name    = RoomBilling.Name + number;
                    BoxRooms.Controls.Add(gb);
                    gb.Height           = 350;
                    RoomBilling.Visible = false;

                    Label l = new Label();
                    l.Text      = "Danh sách Dịch Vụ";
                    l.ForeColor = Color.FromArgb(240, 171, 38);
                    l.Location  = new Point(20, 50);
                    gb.Controls.Add(l);

                    DataGridView dataSer = new DataGridView();
                    dataSer.Size            = new Size(569, 150);
                    dataSer.Anchor          = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                    dataSer.Location        = new Point(20, 80);
                    dataSer.ColumnCount     = 5;
                    dataSer.Columns[0].Name = "id";
                    dataSer.Columns[1].Name = "STT";
                    dataSer.Columns[2].Name = "Tên Dịch vụ";
                    dataSer.Columns[3].Name = "Giá";
                    dataSer.Columns[4].Name = "Khuyến Mại";

                    dataSer.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    dataSer.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    dataSer.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    dataSer.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    dataSer.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                    dataSer.Columns[0].Visible = false;

                    var   detaiBill = managerHotel.Details_Bills.Where(x => x.id_bill == BillCus.id && x.id_room == Convert.ToInt32(idR));
                    int   num       = 0;
                    float totalSer  = 0;
                    foreach (var ser in detaiBill)
                    {
                        num++;
                        var      service = managerHotel.Servicers.Where(x => x.id == ser.id_ser).FirstOrDefault();
                        string[] row     = new string[] { service.id.ToString(), num.ToString(), service.name, service.price.ToString(), service.sale.ToString() };
                        dataSer.Rows.Add(row);

                        totalSer = totalSer + (float)(service.price - service.sale);
                    }

                    float totalRoom = (float)(totalSer + room.Types_Room.moneys);
                    total += totalRoom;
                    Label titleTotalSer = new Label();
                    titleTotalSer.Text      = "Tổng tiền dịch vụ :";
                    titleTotalSer.ForeColor = Color.FromArgb(240, 171, 38);
                    titleTotalSer.Font      = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
                    titleTotalSer.Location  = new Point(20, 260);
                    titleTotalSer.AutoSize  = true;

                    var info = System.Globalization.CultureInfo.GetCultureInfo("vi-VN");
                    System.Globalization.CultureInfo cul = System.Globalization.CultureInfo.GetCultureInfo("vi-VN");

                    Label TextTotalSer = new Label();
                    TextTotalSer.Text      = totalSer.ToString("#,###", cul.NumberFormat) + "VND";
                    TextTotalSer.ForeColor = Color.FromArgb(145, 149, 153);
                    TextTotalSer.Font      = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
                    TextTotalSer.Location  = new Point(210, 260);
                    TextTotalSer.AutoSize  = true;

                    Label titlePriceRoom = new Label();
                    titlePriceRoom.Text      = "Tiền phòng :";
                    titlePriceRoom.ForeColor = Color.FromArgb(240, 171, 38);
                    titlePriceRoom.Font      = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
                    titlePriceRoom.Location  = new Point(20, 300);
                    titlePriceRoom.AutoSize  = true;

                    Label textPriceRoom = new Label();
                    textPriceRoom.Text      = room.Types_Room.moneys.ToString("#,###", cul.NumberFormat) + "VND";
                    textPriceRoom.ForeColor = Color.FromArgb(145, 149, 153);
                    textPriceRoom.Font      = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
                    textPriceRoom.Location  = new Point(210, 300);
                    textPriceRoom.AutoSize  = true;

                    Label titleTotalRoom = new Label();
                    titleTotalRoom.Text      = "Tổng tiền Phòng :";
                    titleTotalRoom.ForeColor = Color.FromArgb(240, 171, 38);
                    titleTotalRoom.Font      = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
                    titleTotalRoom.Location  = new Point(370, 300);
                    titleTotalRoom.AutoSize  = true;

                    Label textTotalRoom = new Label();
                    textTotalRoom.Text      = totalRoom.ToString("#,###", cul.NumberFormat) + "VND";
                    textTotalRoom.ForeColor = Color.FromArgb(145, 149, 153);
                    textTotalRoom.Font      = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
                    textTotalRoom.Location  = new Point(520, 300);
                    textTotalRoom.AutoSize  = true;

                    gb.Controls.Add(titleTotalSer);
                    gb.Controls.Add(titlePriceRoom);
                    gb.Controls.Add(titleTotalRoom);
                    gb.Controls.Add(textTotalRoom);
                    gb.Controls.Add(textPriceRoom);
                    gb.Controls.Add(TextTotalSer);

                    gb.Controls.Add(dataSer);
                }
            }
            total = total * rangeDate.Days;
            string outPay = (BillCus.Prepay - total).ToString();

            labelOutPay.Text = double.Parse(outPay.ToString()).ToString("#,###", cull.NumberFormat);


            labelTotal.Text = double.Parse(total.ToString()).ToString("#,###", cull.NumberFormat);
        }
Example #5
0
        private bool UpdateRoom(RoomBilling roomBilling)
        {
            if (roomBilling.RoomBillingId <= 0)
                return false;

            using (var transactionScope = new TransactionScope())
            {
                //Delete all room billing equipment
                if (!_objRoomBillingEquipment.DeleteByRoomBillingId(roomBilling.RoomBillingId))
                    return false;

                //Delete Room Billing
                if (!_objRoomBilling.Delete(roomBilling.RoomBillingId))
                    return false;

                //Re-insert new updated data
                if (!_objRoomBilling.Insert(roomBilling))
                    return false;

                transactionScope.Complete();

                return true;
            }
        }