private void BindRoomCategory() { Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]); var result = AccSvc.GetRoomDetails(Accomodation_ID, Guid.Empty); ddlRoomCategory.DataSource = (from r in result where r.IsActive select new { r.Accommodation_RoomInfo_Id, r.RoomCategory }).ToList(); ddlRoomCategory.DataTextField = "RoomCategory"; ddlRoomCategory.DataValueField = "Accommodation_RoomInfo_Id"; ddlRoomCategory.DataBind(); }
private void fillcategories(DropDownList obj) { var result = AccSvc.GetRoomDetails(Accomodation_ID, Guid.Empty); obj.DataSource = (from r in result where r.IsActive == true select r).ToList(); obj.DataTextField = "RoomCategory"; obj.DataValueField = "Accommodation_RoomInfo_Id"; obj.DataBind(); }
protected void frmRoomInfo_ItemCommand(object sender, FormViewCommandEventArgs e) { // get form controls TextBox txtRoomCategory = (TextBox)frmRoomInfo.FindControl("txtRoomCategory"); TextBox txtRoomName = (TextBox)frmRoomInfo.FindControl("txtRoomName"); TextBox txtNumberOfRooms = (TextBox)frmRoomInfo.FindControl("txtNumberOfRooms"); TextBox txtRoomDescription = (TextBox)frmRoomInfo.FindControl("txtRoomDescription"); TextBox txtFloorName = (TextBox)frmRoomInfo.FindControl("txtFloorName"); TextBox txtFloorNumber = (TextBox)frmRoomInfo.FindControl("txtFloorNumber"); TextBox txtRoomView = (TextBox)frmRoomInfo.FindControl("txtRoomView"); TextBox txtRoomDecor = (TextBox)frmRoomInfo.FindControl("txtRoomDecor"); TextBox txtInterconnectRooms = (TextBox)frmRoomInfo.FindControl("txtInterconnectRooms"); DropDownList ddlCompanyRoomCategory = (DropDownList)frmRoomInfo.FindControl("ddlCompanyRoomCategory"); DropDownList ddlBedType = (DropDownList)frmRoomInfo.FindControl("ddlBedType"); DropDownList ddlBathRoomType = (DropDownList)frmRoomInfo.FindControl("ddlBathRoomType"); DropDownList ddlSmoking = (DropDownList)frmRoomInfo.FindControl("ddlSmoking"); TextBox txtRoomSize = (TextBox)frmRoomInfo.FindControl("txtRoomSize"); TextBox txtRoomInfo_Id = (TextBox)frmRoomInfo.FindControl("txtRoomInfo_Id"); bool bsmoking; if (ddlSmoking.SelectedItem.Text == "Yes") { bsmoking = true; } else { bsmoking = false; }; if (e.CommandName.ToString() == "Add") { Accomodation_RoomInfo_ID = Guid.NewGuid(); txtRoomInfo_Id.Text = Accomodation_RoomInfo_ID.ToString(); TLGX_Consumer.MDMSVC.DC_Accommodation_RoomInfo newObj = new MDMSVC.DC_Accommodation_RoomInfo { Accommodation_Id = Guid.Parse(Request.QueryString["Hotel_Id"]), Accommodation_RoomInfo_Id = Accomodation_RoomInfo_ID, BathRoomType = ddlBathRoomType.SelectedIndex != 0 ? ddlBathRoomType.SelectedItem.Text.Trim() : string.Empty, BedType = ddlBedType.SelectedIndex != 0 ? ddlBedType.SelectedItem.Text.Trim() : string.Empty, Category = txtRoomCategory.Text.Trim(), CompanyRoomCategory = ddlCompanyRoomCategory.SelectedIndex != 0 ? ddlCompanyRoomCategory.SelectedItem.Text.Trim() : string.Empty, Create_Date = DateTime.Now, Create_User = System.Web.HttpContext.Current.User.Identity.Name, FloorName = txtFloorName.Text.Trim(), FloorNumber = txtFloorNumber.Text.Trim(), RoomCategory = txtRoomCategory.Text.Trim(), RoomDecor = txtRoomDecor.Text.Trim(), RoomName = txtRoomName.Text.Trim(), RoomSize = txtRoomSize.Text.Trim(), RoomView = txtRoomView.Text.Trim(), Smoking = bsmoking, Description = txtRoomDescription.Text.Trim(), IsActive = true }; if (!string.IsNullOrWhiteSpace(txtNumberOfRooms.Text.Trim())) { newObj.NoOfRooms = int.Parse(txtNumberOfRooms.Text.Trim()); } if (!string.IsNullOrWhiteSpace(txtInterconnectRooms.Text.Trim())) { newObj.NoOfInterconnectingRooms = int.Parse(txtInterconnectRooms.Text.Trim()); } if (AccSvc.AddRoom(newObj)) { frmRoomInfo.DataBind(); GetRoomInfoDetails(PageSize, intPageIndex); BootstrapAlert.BootstrapAlertMessage(dvMsg, "RoomInfo has been added successfully", BootstrapAlertType.Success); } else { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning); } } else if (e.CommandName.ToString() == "Save") { Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]); Guid myRow_Id = Guid.Parse(grdRoomTypes.SelectedDataKey.Value.ToString()); Accomodation_RoomInfo_ID = myRow_Id; var result = AccSvc.GetRoomDetails(Accomodation_ID, myRow_Id); txtRoomInfo_Id.Text = myRow_Id.ToString(); if (result.Count > 0) { TLGX_Consumer.MDMSVC.DC_Accommodation_RoomInfo newObj = new MDMSVC.DC_Accommodation_RoomInfo { Accommodation_Id = Guid.Parse(Request.QueryString["Hotel_Id"]), Accommodation_RoomInfo_Id = myRow_Id, BathRoomType = ddlBathRoomType.SelectedIndex != 0 ? ddlBathRoomType.SelectedItem.Text.Trim() : string.Empty, BedType = ddlBedType.SelectedIndex != 0 ? ddlBedType.SelectedItem.Text.Trim() : string.Empty, Category = txtRoomCategory.Text.Trim(), CompanyRoomCategory = ddlCompanyRoomCategory.SelectedIndex != 0 ? ddlCompanyRoomCategory.SelectedItem.Text.Trim() : string.Empty, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name, FloorName = txtFloorName.Text.Trim(), FloorNumber = txtFloorNumber.Text.Trim(), RoomCategory = txtRoomCategory.Text.Trim(), RoomDecor = txtRoomDecor.Text.Trim(), RoomName = txtRoomName.Text.Trim(), RoomSize = txtRoomSize.Text.Trim(), RoomView = txtRoomView.Text.Trim(), Smoking = bsmoking, Description = txtRoomDescription.Text.Trim(), IsActive = true }; if (!string.IsNullOrWhiteSpace(txtNumberOfRooms.Text.Trim())) { newObj.NoOfRooms = int.Parse(txtNumberOfRooms.Text.Trim()); } if (!string.IsNullOrWhiteSpace(txtInterconnectRooms.Text.Trim())) { newObj.NoOfInterconnectingRooms = int.Parse(txtInterconnectRooms.Text.Trim()); } if (AccSvc.UpdateRoom(newObj)) { Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]); frmRoomInfo.ChangeMode(FormViewMode.Insert); frmRoomInfo.DataBind(); GetRoomInfoDetails(PageSize, intPageIndex); BootstrapAlert.BootstrapAlertMessage(dvMsg, "RoomInfo has been Updated successfully", BootstrapAlertType.Success); } else { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning); } } } }