/// <summary>
        /// Init values
        /// </summary>
        protected override void DoInit()
        {
            try
            {
                Hashtable tmp = new Hashtable();
                for (int i = 0; i < 24; i++)
                {
                    drpHourFrom.Items.Add(new ListItem(Func.ParseString(i).PadLeft(2, '0'), Func.ParseString(i).PadLeft(2, '0')));
                    drpHourTo.Items.Add(new ListItem(Func.ParseString(i).PadLeft(2, '0'), Func.ParseString(i).PadLeft(2, '0')));
                }
                drpHourFrom.Items.FindByValue(DateTime.Now.AddHours(-1).ToString("hh")).Selected = true;
                drpHourTo.Items.FindByValue(DateTime.Now.AddHours(1).ToString("hh")).Selected = true;

                BD_RoomBookingData data = new BD_RoomBookingData();
                ITransaction tran = factory.GetLoadObject(data, hidId.Value);
                Execute(tran);
                if (!HasError)
                {
                    //Get Data
                    data = (BD_RoomBookingData)tran.Result;
                    lnbCustomerId.Text = data.CustomerId;

                    lblBookingDate.Text = Func.FormatDMY(data.BookingDate);
                    drpHourFrom.SelectedValue = data.BookingHourFrom.PadLeft(2, '0');
                    drpHourTo.SelectedValue = data.BookingHourTo.PadLeft(2, '0');
                    drpMinuteFrom.Value = data.BookingMinuteFrom.PadLeft(2, '0');
                    drpMinuteTo.Value = data.BookingMinuteTo.PadLeft(2, '0');

                    txtPriceVND.Text = Func.ParseString(Func.ParseDouble(data.PriceVND));
                    txtPriceUSD.Text = data.PriceUSD;
                    txtVat.Text = data.VAT;
                    chkBookingType.Checked = (data.BookingType == "1" ? true : false);

                    txtContractNo.Text = data.ContractNo;
                    txtRate.Text = Func.ParseString(Func.ParseDouble(data.Rate));
                    txtRateDate.Text = data.RateDate;

                    float hour = Func.ParseInt(data.BookingHourTo) - Func.ParseInt(data.BookingHourFrom);
                    int hourOdd = Func.ParseInt(data.BookingMinuteTo) - Func.ParseInt(data.BookingMinuteFrom);
                    if (hourOdd < 0)
                    {
                        hour--;
                    }
                    else
                    {
                        hour += Func.ParseFloat(hourOdd) / 60;
                    }

                    //lblSumVND.Text = Func.ParseString((long)(Func.ParseFloat(data.PriceVND) * hour) + (long)(Func.ParseFloat(data.PriceVND) * hour * Func.ParseFloat(data.VAT) / 100));
                    //lblSumUSD.Text = Func.ParseString(Func.ParseFloat(data.PriceUSD) * hour) + Func.ParseString(Func.ParseFloat(data.PriceUSD) * hour * Func.ParseFloat(data.VAT) / 100);
                    txtComment.Text = data.Comment;

                    if ("1".Equals(data.Status))
                    {
                        btnConfirm.Visible = false;
                        divPaid.Visible = true;
                    }
                    else
                    {
                        divPaid.Visible = false;
                    }
                }

                BD_RoomData dataR = new BD_RoomData();
                ITransaction tranR = factory.GetLoadObject(dataR, data.RoomId);
                Execute(tranR);
                if (!HasError)
                {
                    //Get Data
                    dataR = (BD_RoomData)tranR.Result;
                    lblName.Text = dataR.Name;
                    lblComment.Text = dataR.Comment;

                    lblRegional.Text = dataR.Regional;
                    lblFloor.Text = dataR.Floor;
                    lblArea.Text = dataR.Area;

                    lblHourManagerPriceVND.Text = dataR.HourRentPriceVND;
                    lblHourManagerPriceUSD.Text = dataR.HourRentPriceUSD;
                    lblVat.Text = data.VAT;

                }

                //string sql = " SELECT sum(PriceVND*Mount+PriceVND*Mount*VAT/100) VND,sum(PriceUSD*Mount+PriceUSD*Mount*VAT/100) USD";
                //sql += " FROM [BD_RoomBookingService]";
                //sql += " WHERE (ID IS NOT NULL) and DelFlag <> 1 and BookingId = '" + hidId.Value + "'";

                //DataTable dt = DbHelper.GetDataTable(sql);
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    lblSumServiceVND.Text = Func.ParseString(dt.Rows[i]["VND"]);
                //    lblSumServiceUSD.Text = Func.ParseString(dt.Rows[i]["USD"]);
                //}
                //lblSumPriceUSD.Text = "" + (Func.ParseFloat(lblSumUSD.Text) + Func.ParseFloat(lblSumServiceUSD.Text));
                //lblSumPriceVND.Text = "" + (Func.ParseDouble(lblSumVND.Text) + Func.ParseDouble(lblSumServiceVND.Text));

                //sql = " SELECT sum(MoneyUSD) USD,sum(MoneyVND) VND ";
                //sql += " FROM [Payment]";
                //sql += " WHERE (ID IS NOT NULL) and DelFlag <> 1 and BookingId = '" + hidId.Value + "'";

                //dt = DbHelper.GetDataTable(sql);
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    lblPaidUSD.Text = Func.ParseString(dt.Rows[i]["VND"]);
                //    lblPaidVND.Text = Func.ParseString(dt.Rows[i]["USD"]);
                //}
                //txtPaidUSD.Text = "" + (Func.ParseFloat(lblSumPriceUSD.Text) - Func.ParseFloat(lblPaidUSD.Text));
                //txtPaidVND.Text = "" + (Func.ParseDouble(lblSumPriceVND.Text) - Func.ParseDouble(lblPaidVND.Text));

                string sql = " SELECT LastPriceVND VND,LastPriceUSD USD";
                sql += " FROM [PaymentBooking]";
                sql += " WHERE BookingId = '" + hidId.Value + "'";

                DataTable dt = DbHelper.GetDataTable(sql);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    lblSumVND.Text = Func.ParseString(Func.ParseDouble(dt.Rows[i]["VND"]));
                    lblSumUSD.Text = Func.ParseString(dt.Rows[i]["USD"]);
                }

                //lblSumVND.Text = Func.ParseString((long)(Func.ParseFloat(data.PriceVND) * hour) + (long)(Func.ParseFloat(data.PriceVND) * hour * Func.ParseFloat(data.VAT) / 100));
                //lblSumUSD.Text = Func.ParseString(Func.ParseFloat(data.PriceUSD) * hour) + Func.ParseString(Func.ParseFloat(data.PriceUSD) * hour * Func.ParseFloat(data.VAT) / 100);
                sql = " SELECT sum(LastPriceVND) VND,sum(LastPriceUSD) USD";
                sql += " FROM [PaymentBookingService]";
                sql += " WHERE BookingId = '" + hidId.Value + "'";

                dt = DbHelper.GetDataTable(sql);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    lblSumServiceVND.Text = Func.ParseString(Func.ParseFloat(dt.Rows[i]["VND"]));
                    lblSumServiceUSD.Text = Func.ParseString(dt.Rows[i]["USD"]);
                }

                lblSumPriceUSD.Text = "" + (Func.ParseFloat(lblSumUSD.Text) + Func.ParseFloat(lblSumServiceUSD.Text));
                lblSumPriceVND.Text = "" + (Func.ParseDouble(lblSumVND.Text) + Func.ParseDouble(lblSumServiceVND.Text));

                sql = " SELECT sum(MoneyUSD) USD,sum(MoneyVND) VND ";
                sql += " FROM [Payment]";
                sql += " WHERE (ID IS NOT NULL) and DelFlag <> 1 and BookingId = '" + hidId.Value + "'";

                dt = DbHelper.GetDataTable(sql);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    lblPaidUSD.Text = Func.ParseString(Func.ParseFloat(dt.Rows[i]["USD"]));
                    lblPaidVND.Text = Func.ParseString(Func.ParseDouble(dt.Rows[i]["VND"]));
                }
                txtPaidUSD.Text = "" + (Func.ParseFloat(lblSumPriceUSD.Text) - Func.ParseFloat(lblPaidUSD.Text));
                txtPaidVND.Text = "" + (Func.ParseDouble(lblSumPriceVND.Text) - Func.ParseDouble(lblPaidVND.Text));
                ShowData();

                string tmpPaid = DbHelper.GetScalar("Select count(*) from Payment Where BookingId = '" + hidId.Value + "' and DelFlag = '0' and PaymentType = '8'");
                if ("1".Equals(tmpPaid))
                {
                    btnPaid.Visible = false;
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            //return tmp;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            mvMessage.CheckRequired(txtPriceVND, "Phí thuê(giờ)(VND): Danh mục phải nhập");
            mvMessage.CheckRequired(txtPriceUSD, "Phí thuê(giờ)(USD): Danh mục phải nhập");

            int from = Func.ParseInt(drpHourFrom.SelectedValue + drpMinuteFrom.Value);
            int to = Func.ParseInt(drpHourTo.SelectedValue + drpMinuteTo.Value);

            if (from >= to)
            {
                mvMessage.AddError("Thời gian đặt phòng không hợp lệ");
                return;
            }

            if (!mvMessage.IsValid) return;
            //Get and Insert Data
            BD_RoomBookingData data = new BD_RoomBookingData();
            ITransaction tran = factory.GetLoadObject(data, hidId.Value);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_RoomBookingData)tran.Result;

                data.BookingDate = Func.FormatYYYYmmdd(lblBookingDate.Text.Trim());
                data.BookingHourFrom = drpHourFrom.SelectedValue;
                data.BookingHourTo = drpHourTo.SelectedValue;

                data.BookingMinuteFrom = drpMinuteFrom.Value;
                data.BookingMinuteTo = drpMinuteTo.Value;

                data.RentHourFrom = drpHourFrom.SelectedValue;
                data.RentHourTo = drpHourTo.SelectedValue;

                data.RentMinuteFrom = drpMinuteFrom.Value;
                data.RentMinuteTo = drpMinuteTo.Value;

                data.PriceVND = txtPriceVND.Text.Trim().Replace(',', '.');
                data.PriceUSD = txtPriceUSD.Text.Trim().Replace(',', '.');

                data.Status = "1";//2 la Huy; 0 la dat.

                float hour = Func.ParseInt(data.BookingHourTo) - Func.ParseInt(data.BookingHourFrom);
                int hourOdd = Func.ParseInt(data.BookingMinuteTo) - Func.ParseInt(data.BookingMinuteFrom);
                if (hourOdd < 0)
                {
                    hour--;
                }
                else
                {
                    hour += Func.ParseFloat(hourOdd) / 60;
                }

                data.Hour = Func.ParseString(hour);
                data.Comment = txtComment.Text.Trim();
                data.VAT = txtVat.Text.Trim();

                data.ModifiedBy = Page.User.Identity.Name;
                data.CreatedBy = Page.User.Identity.Name;
                data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = "0";

                tran = factory.GetUpdateObject(data);
                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(addSuccess);
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(addUnSuccess);
                }
            }
        }
        protected void btnPaid_Click(object sender, EventArgs e)
        {
            //string exchangetype = (rdoUSD.Checked == true) ? "0" : "1";
            //string money = (rdoUSD.Checked == true) ? txtPaidUSD.Text : txtPaidVND.Text;
            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "", "PopUp('../../Customer/PaymentBooking.aspx?paymenttype=8&id=" + lnbCustomerId.Text + "&yearmonth=" + Func.FormatYYYYmmdd(lblBookingDate.Text).Substring(0, 6) + "&exchangetype=" + exchangetype + "&money=" + money + "&bookingid=" + hidId.Value + "',600,600,'PaymentBooking', true);", true);
            try
            {
                BD_RoomBookingData data = new BD_RoomBookingData();
                ITransaction tran = factory.GetLoadObject(data, hidId.Value);
                Execute(tran);
                if (!HasError)
                {
                    //Get Data
                    data = (BD_RoomBookingData)tran.Result;

                    data.ContractNo = txtContractNo.Text.Trim();
                    data.Rate = txtRate.Text.Trim();
                    data.RateDate = Func.Formatymdhms(txtRateDate.Text);
                    data.PaidMoneyType = rdoUSD.Checked == true ? "0" : "1";

                    data.ModifiedBy = Page.User.Identity.Name;
                    data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");

                    tran = factory.GetUpdateObject(data);
                    Execute(tran);

                    if (!HasError)
                    {
                        OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                        mvMessage.SetCompleteMessage(addSuccess);
                    }
                    else
                    {
                        OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                        mvMessage.AddError(addUnSuccess);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            try
            {
                PaymentData data = new PaymentData();
                ITransaction tran = factory.GetInsertObject(data);
                data.ModifiedBy = Page.User.Identity.Name;
                data.CreatedBy = Page.User.Identity.Name;
                data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = "0";

                data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]);
                data.CustomerId = lnbCustomerId.Text;
                data.PaymentDate = Func.FormatYYYYmmdd(txtContractDate.Text.Trim().Substring(0, 10));
                data.YearMonth = data.PaymentDate.Substring(0, 6);
                data.PaymentType = "8";
                data.PaidType = rdoUSD.Checked == true ? "0" : "1";
                data.Paymenter = txtPaymenter.Text.Trim();
                data.Receiver = txtReceiver.Text.Trim();
                data.MoneyUSD = (rdoUSD.Checked == true) ? txtPriceUSD.Text.Replace(",", ".") : "0";
                data.MoneyVND = (rdoVND.Checked == true) ? txtPriceVND.Text.Replace(",", ".") : "0";
                data.Comment = txtComment.Text.Trim();
                data.BookingId = hidId.Value;

                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(addSuccess);
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(addUnSuccess);
                }
            }
            catch (Exception ex)
            { }
        }
        //protected void txtCustomerId_OnTextChanged(object sender, EventArgs e)
        //{
        //    lblCustomerName.Text = DbHelper.GetScalar("Select Name from Customer Where BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' and CustomerId = '" + txtCustomerId.Text + "'");
        //}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (!checkData()) return;

            int from = Func.ParseInt(drpHourFrom.SelectedValue + drpMinuteFrom.Value);
            int to = Func.ParseInt(drpHourTo.SelectedValue + drpMinuteTo.Value);

            if (Func.ParseDate(txtBookingDate.Text).CompareTo(DateTime.Now) < 0)
            {
                mvMessage.AddError("Ngày đặt phòng không hợp lệ");
                return;
            }

            if (from >= to)
            {
                mvMessage.AddError("Thời gian đặt phòng không hợp lệ");
                return;
            }

            if (!mvMessage.IsValid) return;

            //Get and Insert Data
            BD_RoomBookingData data = new BD_RoomBookingData();
            ITransaction tran = factory.GetInsertObject(data);
            data.CustomerId = drpCustomerId.SelectedValue;
            data.BookingDate = Func.FormatYYYYmmdd(txtBookingDate.Text.Trim());
            data.BookingHourFrom = drpHourFrom.SelectedValue;
            data.BookingHourTo = drpHourTo.SelectedValue;

            data.BookingMinuteFrom = drpMinuteFrom.Value;
            data.BookingMinuteTo = drpMinuteTo.Value;

            data.PriceVND = txtPriceVND.Text.Trim().Replace(',', '.');
            data.PriceUSD = txtPriceUSD.Text.Trim().Replace(',', '.');
            data.Comment = txtComment.Text.Trim();
            data.RoomId = hidId.Value;
            data.VAT = txtVAT.Text.Trim().Replace(',', '.');

            data.ModifiedBy = Page.User.Identity.Name;
            data.CreatedBy = Page.User.Identity.Name;
            data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
            data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
            data.DelFlag = "0";
            data.Status = "0";
            data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]);

            data.BookingType = (chkBookingType.Checked == true ? "1" : "0");
            Execute(tran);

            if (!HasError)
            {
                OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                mvMessage.SetCompleteMessage(addSuccess);
                ShowData();
            }
            else
            {
                OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                mvMessage.AddError(addUnSuccess);
            }
        }
        /// <summary>
        /// Update
        /// </summary>
        private void DeleteData(string id)
        {
            BD_RoomBookingData data = new BD_RoomBookingData();
            ITransaction tran = factory.GetLoadObject(data, id);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_RoomBookingData)tran.Result;
                data.PriceVND = data.PriceVND.Replace(',', '.');
                data.PriceUSD = data.PriceVND.Replace(',', '.');

                data.ModifiedBy = Page.User.Identity.Name;
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = "1";

                tran = factory.GetUpdateObject(data);

                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, deleteSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(deleteSuccess);
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, deleteUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(deleteUnSuccess);
                }
            }
        }
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string command = e.CommandName;
            string colName = string.Empty;
            if (command.StartsWith("Sort"))
            {
                if (string.Compare(command, "SortID") == 0)
                {
                    colName = "ID";
                }
                else if (string.Compare(command, "SortName") == 0)
                {
                    colName = "Name";
                }
                else if (string.Compare(command, "SortModifiedBy") == 0)
                {
                    colName = "ModifiedBy";
                }
                else if (string.Compare(command, "SortModified") == 0)
                {
                    colName = "Modified";
                }

                if (colName == ListSortExpression)
                {
                    ListSortDirection = (ListSortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending);
                }
                else
                {
                    ListSortDirection = SortDirection.Descending;
                }
                ListSortExpression = colName;
                pager.CurrentPageIndex = 0;
                ShowData();
            }
            else if (command.Equals("Delete"))
            {
                BD_RoomBookingData data = new BD_RoomBookingData();
                ITransaction tran = factory.GetLoadObject(data, Func.ParseString(e.CommandArgument));
                Execute(tran);
                if (!HasError)
                {
                    //Get Data
                    data = (BD_RoomBookingData)tran.Result;
                    data.DelFlag = "1";
                    data.PriceUSD = data.PriceUSD.Replace(",", ".");
                    tran = factory.GetUpdateObject(data);

                    Execute(tran);

                    if (!HasError)
                    {
                        OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, deleteSuccess, Page.User.Identity.Name);
                        mvMessage.SetCompleteMessage(deleteSuccess);
                    }
                    else
                    {
                        OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, deleteUnSuccess, Page.User.Identity.Name);
                        mvMessage.AddError(deleteUnSuccess);
                    }
                }
            }
            else if (command.Equals("Confirm"))
            {
                Response.Redirect(editConfirmPageName + ".aspx?id=" + e.CommandArgument);
            }
            else if (command.Equals("Delete"))
            {
                DeleteData("" + e.CommandArgument);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            BD_RoomBookingData data = new BD_RoomBookingData();
            ITransaction tran = factory.GetLoadObject(data, hidId.Value);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_RoomBookingData)tran.Result;

                data.PriceVND = txtPriceVND.Text.Trim().Replace(".", "").Replace(",", ".");
                data.PriceUSD = txtPriceUSD.Text.Trim().Replace(".", "").Replace(",", ".");

                data.Status = "2";//2 la Huy; 0 la dat; 1 là OK

                data.Hour = data.Hour.Replace(".", "").Replace(",", ".");
                data.Comment = txtComment.Text.Trim();
                data.VAT = txtVat.Text.Trim().Replace(".", "").Replace(",", ".");
                data.HourExtraPriceUSD = "0";
                data.HourExtraPriceVND = "0";

                data.ModifiedBy = Page.User.Identity.Name;
                data.CreatedBy = Page.User.Identity.Name;
                data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = "1";

                data.OtherFee01 = "0";
                data.OtherFee02 = "0";

                data.Rate = data.Rate.Replace(".", "").Replace(",", ".");

                tran = factory.GetUpdateObject(data);
                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(addSuccess);

                    btnConfirm.Visible = false;
                    btnDelete.Visible = false;
                    btnView.Visible = false;
                    btnPaid.Visible = false;
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(addUnSuccess);
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            mvMessage.CheckRequired(txtContractDate, "Ngày xuất HĐ : Danh mục phải nhập");
            mvMessage.CheckRequired(txtContractNo, "Hợp đồng số : Danh mục phải nhập");
            mvMessage.CheckRequired(txtRate, "Tỉ giá quy đổi USD->VND : Danh mục phải nhập");
            mvMessage.CheckRequired(txtRateDate, "Thời gian quy đổi: Danh mục phải nhập");
            //mvMessage.CheckRequired(txtPaymenter, " Đại diện Khách Hàng : Danh mục phải nhập");
            //mvMessage.CheckRequired(txtReceiver, "Đại diện Tòa nhà : Danh mục phải nhập");

            int from = Func.ParseInt(drpHourFrom.SelectedValue + drpMinuteFrom.Value);
            int to = Func.ParseInt(drpHourTo.SelectedValue + drpMinuteTo.Value);

            if (from >= to)
            {
                mvMessage.AddError("Thời gian đặt phòng không hợp lệ");
                return;
            }

            if (!mvMessage.IsValid) return;
            //Get and Insert Data
            BD_RoomBookingData data = new BD_RoomBookingData();
            ITransaction tran = factory.GetLoadObject(data, hidId.Value);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_RoomBookingData)tran.Result;

                data.BookingDate = Func.FormatYYYYmmdd(lblBookingDate.Text.Trim());
                data.BookingHourFrom = drpHourFrom.SelectedValue;
                data.BookingHourTo = drpHourTo.SelectedValue;

                data.BookingMinuteFrom = drpMinuteFrom.Value;
                data.BookingMinuteTo = drpMinuteTo.Value;

                data.RentHourFrom = drpHourFrom.SelectedValue;
                data.RentHourTo = drpHourTo.SelectedValue;

                data.RentMinuteFrom = drpMinuteFrom.Value;
                data.RentMinuteTo = drpMinuteTo.Value;

                data.PriceVND = txtPriceVND.Text.Trim().Replace(".", "").Replace(",", ".");
                data.PriceUSD = txtPriceUSD.Text.Trim().Replace(".", "").Replace(",", ".");

                data.Status = "1";//2 la Huy; 0 la dat; 1 là OK

                float hour = Func.ParseInt(data.BookingHourTo) - Func.ParseInt(data.BookingHourFrom);
                int hourOdd = Func.ParseInt(data.BookingMinuteTo) - Func.ParseInt(data.BookingMinuteFrom);
                if (hourOdd < 0)
                {
                    hour--;
                }
                else
                {
                    hour += Func.ParseFloat(hourOdd) / 60;
                }

                data.Hour = Func.ParseString(hour).Replace(".", "").Replace(",", ".");
                data.Comment = txtComment.Text.Trim();
                data.VAT = txtVat.Text.Trim().Replace(".", "").Replace(",", ".");
                data.HourExtraPriceUSD = "0";
                data.HourExtraPriceVND = "0";

                data.ModifiedBy = Page.User.Identity.Name;
                data.CreatedBy = Page.User.Identity.Name;
                data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = "0";

                data.OtherFee01 = "0";
                data.OtherFee02 = "0";

                data.ContractDate = Func.FormatYYYYmmdd(txtContractDate.Text.Trim());
                data.ContractNo = txtContractNo.Text;
                data.Rate = txtRate.Text.Replace(".", "").Replace(",", ".");
                data.RateDate = Func.FormatYYYYmmdd(txtRateDate.Text.Trim());

                tran = factory.GetUpdateObject(data);
                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(addSuccess);

                    btnConfirm.Visible = false;
                    btnDelete.Visible = false;
                    btnView.Visible = true;
                    btnPaid.Visible = true;
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(addUnSuccess);
                }
            }
        }