Exemplo n.º 1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.lblException.Text = "";
     this.lblResult.Text    = "";
     try
     {
         if (btnSave.Text == "Save")
         {
             Hotel_InfoEntity entity = BuiltEntity();
             long             i      = Hotel_InfoService.GetService().Add(entity);
             if (i > 0)
             {
                 SuccessMessage = "Information Saved Successfully";
                 LoadEntity(new Hotel_InfoEntity {
                     Hotel_ID = i
                 });
             }
         }
         else
         {
             Hotel_InfoEntity entity = BuiltEntity();
             long             i      = Hotel_InfoService.GetService().Update(entity);
             if (i > 0)
             {
                 SuccessMessage = "Information Updated Successfully";
                 LoadEntity(new Hotel_InfoEntity {
                     Hotel_ID = entity.Hotel_ID
                 });
             }
         }
     }
     catch (Exception ex)
     {
         Error = ex.Message;
     }
 }
Exemplo n.º 2
0
        private void LoadEntity(Hotel_InfoEntity entity)
        {
            try
            {
                Hotel_InfoEntity objEntity = Hotel_InfoService.GetService().GetAll(entity).FirstOrDefault();

                ClearControlStates(pnlForm);

                if (objEntity != null && objEntity.Hotel_ID != null && objEntity.Hotel_ID > 0)
                {
                    GlobalClass.HotelID = (long)objEntity.Hotel_ID;
                    txtHotelName.Text   = objEntity.Hotel_Name;
                    hdnHotelID.Value    = objEntity.Hotel_ID.ToString();
                    if (objEntity.Hotel_Type_ID.HasValue)
                    {
                        ddlHotelType.Text = objEntity.Hotel_Type_ID.ToString();
                    }
                    if (objEntity.Number_Of_Floor.HasValue)
                    {
                        txtNumberOfFloor.Text = objEntity.Number_Of_Floor.ToString();
                    }
                    txtFace.Text          = objEntity.Face;
                    txtSpecification.Text = objEntity.Specification;
                    if (objEntity.Is_Swimming_Pool.HasValue)
                    {
                        chkIsSwimming.Checked = (bool)objEntity.Is_Swimming_Pool;
                    }
                    if (objEntity.Is_Bar_Lounge.HasValue)
                    {
                        chkIsBarLounge.Checked = (bool)objEntity.Is_Bar_Lounge;
                    }
                    if (objEntity.Is_Gym_Spa.HasValue)
                    {
                        chkIsGymSpa.Checked = (bool)objEntity.Is_Gym_Spa;
                    }
                    if (objEntity.Is_Internat_Access.HasValue)
                    {
                        chkIsInternat.Checked = (bool)objEntity.Is_Internat_Access;
                    }
                    if (objEntity.Is_Resturant.HasValue)
                    {
                        chkIsRestaurant.Checked = (bool)objEntity.Is_Resturant;
                    }
                    if (objEntity.Is_Travel_Assistance.HasValue)
                    {
                        chkIsTravel.Checked = (bool)objEntity.Is_Travel_Assistance;
                    }
                    if (objEntity.Is_Car_Parking.HasValue)
                    {
                        chkIsCarParking.Checked = (bool)objEntity.Is_Car_Parking;
                    }
                    if (objEntity.Is_Medical_Services.HasValue)
                    {
                        chkIsMedicalServices.Checked = (bool)objEntity.Is_Medical_Services;
                    }
                    if (objEntity.Is_Currencey_Exchange.HasValue)
                    {
                        chkIsCurrencyExchange.Checked = (bool)objEntity.Is_Currencey_Exchange;
                    }
                    if (objEntity.Is_Express_Checkin_Checkout.HasValue)
                    {
                        chkIsExpressCheckinCheckout.Checked = (bool)objEntity.Is_Express_Checkin_Checkout;
                    }
                    if (objEntity.Confreence_Room_ID.HasValue)
                    {
                        ddlConferenceRoom.SelectedValue = objEntity.Confreence_Room_ID.ToString();
                    }
                    if (objEntity.Current_Discount.HasValue)
                    {
                        txtCurrentDiscount.Text = objEntity.Current_Discount.ToString();
                    }
                    if (objEntity.Service_Charge.HasValue)
                    {
                        txtServiceCharge.Text = objEntity.Service_Charge.ToString();
                    }
                    txtIndoor.Text  = objEntity.Indoor_Facility;
                    txtOutdoor.Text = objEntity.Outdoor_Facility;
                    txtAddress.Text = objEntity.Address;
                    if (objEntity.City_ID.HasValue)
                    {
                        ddlCity.SelectedValue = objEntity.City_ID.ToString();
                    }
                    if (objEntity.Country_ID.HasValue)
                    {
                        ddlCountry.SelectedValue = objEntity.Country_ID.ToString();
                    }
                    if (objEntity.Star_Rating.HasValue)
                    {
                        rblStarRating.SelectedValue = objEntity.Star_Rating.ToString();
                    }

                    txtCheckInTime.Text  = objEntity.Check_In_Time.HasValue ? ((DateTime)objEntity.Check_In_Time).ToString("HH:mm") : "";
                    txtCheckOutTime.Text = objEntity.Check_Out_Time.HasValue ? ((DateTime)objEntity.Check_Out_Time).ToString("HH:mm") : "";

                    if (!string.IsNullOrEmpty(objEntity.Full_Picture_Small_1))
                    {
                        txtFull_Picture_Small_1.Text     = objEntity.Full_Picture_Small_1;
                        imgFull_Picture_Small_1.ImageUrl = "../../" + objEntity.Full_Picture_Small_1;
                    }
                    else
                    {
                        imgFull_Picture_Small_1.ImageUrl = "~/Images/default.jpg";
                    }

                    if (!string.IsNullOrEmpty(objEntity.Full_Picture_Small_2))
                    {
                        txtFull_Picture_Small_2.Text     = objEntity.Full_Picture_Small_2;
                        imgFull_Picture_Small_2.ImageUrl = "../../" + objEntity.Full_Picture_Small_2;
                    }
                    else
                    {
                        imgFull_Picture_Small_2.ImageUrl = "~/Images/default.jpg";
                    }

                    if (!string.IsNullOrEmpty(objEntity.Full_Picture_Small_3))
                    {
                        txtFull_Picture_Small_3.Text     = objEntity.Full_Picture_Small_3;
                        imgFull_Picture_Small_3.ImageUrl = "../../" + objEntity.Full_Picture_Small_3;
                    }
                    else
                    {
                        imgFull_Picture_Small_3.ImageUrl = "~/Images/default.jpg";
                    }

                    if (!string.IsNullOrEmpty(objEntity.Full_Picture_Small_4))
                    {
                        txtFull_Picture_Small_4.Text     = objEntity.Full_Picture_Small_4;
                        imgFull_Picture_Small_4.ImageUrl = "../../" + objEntity.Full_Picture_Small_4;
                    }
                    else
                    {
                        imgFull_Picture_Small_4.ImageUrl = "~/Images/default.jpg";
                    }

                    txtLatitude.Text  = objEntity.Latitude;
                    txtLongitude.Text = objEntity.Longitude;

                    btnSave.Text          = "Update";
                    btnSave.OnClientClick = "javascript:return validateSubmit('Do you want to update this information?');";
                    this.CheckButtonPermission(null, btnSave, null);
                }
                else
                {
                    imgFull_Picture_Small_1.ImageUrl = "~/Images/default.jpg";
                    imgFull_Picture_Small_2.ImageUrl = "~/Images/default.jpg";
                    imgFull_Picture_Small_3.ImageUrl = "~/Images/default.jpg";
                    imgFull_Picture_Small_4.ImageUrl = "~/Images/default.jpg";
                    rblStarRating.SelectedValue      = "0";
                    GlobalClass.HotelID = -99;

                    btnSave.Text          = "Save";
                    btnSave.OnClientClick = "javascript:return validateSubmit('Do you want to save this information?');";
                    this.CheckButtonPermission(btnSave, null, null);
                }
            }
            catch (Exception ex)
            {
                Error = ex.Message;
            }
        }