/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param> private void BindGrid(bool addRow, bool deleteRow) { string hhid = Session["HH_ID"].ToString(); PermanentStructureBLL PermanentStructureBLLobj = new PermanentStructureBLL(); grdPermanentBuilding.DataSource = PermanentStructureBLLobj.GetPermanentStructure(hhid); grdPermanentBuilding.DataBind(); }
/// <summary> /// to assign values to dropdownlist /// </summary> private void GetOccupantstatus() { PermanentStructureBLL BLLobj = new PermanentStructureBLL(); occupantstatusDropDownList.DataSource = BLLobj.GetOccupantstatus(); occupantstatusDropDownList.DataTextField = "OCCUPANTSTATUS"; occupantstatusDropDownList.DataValueField = "OCCUPANTSTATUSID"; occupantstatusDropDownList.DataBind(); occupantstatusDropDownList.Items.Insert(0, new ListItem("--Select--", "0")); }
/// <summary> /// To get the occupant status /// </summary> private void GetOccupantStatus() { PermanentStructureBLL BLLobj = new PermanentStructureBLL(); ddlOccupantStatus.DataSource = BLLobj.GetOccupantstatus(); ddlOccupantStatus.DataTextField = "OCCUPANTSTATUS"; ddlOccupantStatus.DataValueField = "OCCUPANTSTATUSID"; ddlOccupantStatus.DataBind(); //OccupationBLL BLLobj = new OccupationBLL(); //ddlOccupantStatus.DataSource = BLLobj.GetOccupation(); //ddlOccupantStatus.DataTextField = "OccupationName"; //ddlOccupantStatus.DataValueField = "OccupationID"; //ddlOccupantStatus.DataBind(); }
/// <summary> /// To save the data into database /// </summary> private void SaveData() { int count = 0; if (perstructIDTextBox.Text.ToString().Trim() == string.Empty) { PermanentStructureBLL BLLobj = new PermanentStructureBLL(); PermanentStructureBO PermanentStructureobj = new PermanentStructureBO(); string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); try { PermanentStructureobj.HouseholdID = Convert.ToInt32(hhid); PermanentStructureobj.StructureTypeID = Convert.ToInt32(ddlBuidingType.SelectedValue); if (otherSpecifyTextBox.Text != string.Empty) { PermanentStructureobj.OtherStructureType = otherSpecifyTextBox.Text; } else { PermanentStructureobj.OtherStructureType = ""; } PermanentStructureobj.RoofID = Convert.ToInt32(ddlRoofMaterial.SelectedValue); PermanentStructureobj.WallID = Convert.ToInt32(ddlWallsMaterial.SelectedValue); PermanentStructureobj.FloorID = Convert.ToInt32(ddlFloorMaterial.SelectedValue); PermanentStructureobj.WindowID = Convert.ToInt32(ddlWindowsMaterial.SelectedValue); PermanentStructureobj.RoofConditionID = Convert.ToInt32(ddlRoofCondition.SelectedValue); PermanentStructureobj.WallConditionID = Convert.ToInt32(ddlWallsCondition.SelectedValue); PermanentStructureobj.FloorConditionID = Convert.ToInt32(ddlFloorCondition.SelectedValue); PermanentStructureobj.WindowConditionID = Convert.ToInt32(ddlWindowsCondition.SelectedValue); if (RbtnSelf.Checked == true || (RbtnSelf.Checked == false && RbtnOther.Checked == false)) { PermanentStructureobj.Owner = "Self"; } else if (RbtnOther.Checked == true) { PermanentStructureobj.Owner = "Others"; PermanentStructureobj.OwnerName = txtbxOther.Text; } if (RdbtnSelfoccupied.Checked == true || (RdbtnSelfoccupied.Checked == false && RdbtnOccupantOther.Checked == false)) { PermanentStructureobj.Occupant = "Self"; } else if (RdbtnOccupantOther.Checked == true) { PermanentStructureobj.Occupant = "Others"; PermanentStructureobj.OtherOccupantName = txtbxOccupantOther.Text; } PermanentStructureobj.OccupantStatusID = Convert.ToInt32(ddlOccupantStatus.SelectedValue.ToString()); if (txtbxEnterStatus.Text != string.Empty) { PermanentStructureobj.OtherOccupantStatus = txtbxEnterStatus.Text; } else { PermanentStructureobj.OtherOccupantStatus = ""; } if (txtbxLength.Text != string.Empty) { PermanentStructureobj.DimensionLength = Convert.ToDecimal(txtbxLength.Text); } else { PermanentStructureobj.DimensionLength = Convert.ToDecimal(0); } if (txtbxWidth.Text != string.Empty) { PermanentStructureobj.DimensionWidth = Convert.ToDecimal(txtbxWidth.Text); } else { PermanentStructureobj.DimensionWidth = Convert.ToDecimal(0); } if (txtbxNoofrooms.Text != string.Empty) { PermanentStructureobj.NoOfRooms = Convert.ToInt32(txtbxNoofrooms.Text); } else { PermanentStructureobj.NoOfRooms = 0; } if (txtbxSurfaceArea.Text != string.Empty) { PermanentStructureobj.SurfaceArea = Convert.ToDecimal(txtbxSurfaceArea.Text); } else { PermanentStructureobj.SurfaceArea = 0; } if (txtbxDepreciatedValue.Text.Trim() != string.Empty) { PermanentStructureobj.DepreciatedValue = Convert.ToDecimal(txtbxDepreciatedValue.Text); } else { PermanentStructureobj.DepreciatedValue = 0; } PermanentStructureobj.ReplacementValue = Convert.ToDecimal(txtbxReplacementValue.Text); if (txtbxComments.Text != string.Empty) { if (txtbxComments.Text.Length > 1000) { PermanentStructureobj.AdditionalComments = txtbxComments.Text.Substring(0, 1000); } else { PermanentStructureobj.AdditionalComments = txtbxComments.Text; } } else { PermanentStructureobj.AdditionalComments = ""; } if (photoFileUpload.HasFile) { byte[] fileBytes = photoFileUpload.FileBytes; if (fileBytes != null) { PermanentStructureobj.Photo = fileBytes; } } PermanentStructureobj.StructureType = ddlStructureType.SelectedValue.ToString(); PermanentStructureobj.IsDeleted = "False"; PermanentStructureobj.CreatedBy = Convert.ToInt32(uID); PermanentStructureBLL PBLLobject = new PermanentStructureBLL(); count = PBLLobject.Insert(PermanentStructureobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "ShowSaveMessage('');", true); Clear(); BindGrid(true, true); } catch (Exception ex) { throw ex; } finally { BLLobj = null; } } else if (perstructIDTextBox.Text.ToString().Trim() != string.Empty) { PermanentStructureBLL BLLobj = new PermanentStructureBLL(); string hhid = Session["HH_ID"].ToString(); string uID = Session["USER_ID"].ToString(); try { if (photoFileUpload.HasFile) { PermanentStructureBO PermanentStructureobj1 = new PermanentStructureBO(); byte[] fileBytes = photoFileUpload.FileBytes; PermanentStructureobj1.PermanentStructureID = Convert.ToInt32(perstructIDTextBox.Text); PermanentStructureobj1.HouseholdID = Convert.ToInt32(hhid); PermanentStructureobj1.UpdatedBy = Convert.ToInt32(uID); PermanentStructureobj1.Photo = fileBytes; PermanentStructureBLL BLLobj1 = new PermanentStructureBLL(); count = BLLobj1.Updatephoto(PermanentStructureobj1); } PermanentStructureBO PermanentStructureobj = new PermanentStructureBO(); PermanentStructureobj.HouseholdID = Convert.ToInt32(hhid); PermanentStructureobj.PermanentStructureID = Convert.ToInt32(perstructIDTextBox.Text); PermanentStructureobj.StructureTypeID = Convert.ToInt32(ddlBuidingType.SelectedValue); if (otherSpecifyTextBox.Text != string.Empty) { PermanentStructureobj.OtherStructureType = otherSpecifyTextBox.Text; } else { PermanentStructureobj.OtherStructureType = ""; } PermanentStructureobj.RoofID = Convert.ToInt32(ddlRoofMaterial.SelectedValue); PermanentStructureobj.WallID = Convert.ToInt32(ddlWallsMaterial.SelectedValue); PermanentStructureobj.FloorID = Convert.ToInt32(ddlFloorMaterial.SelectedValue); PermanentStructureobj.WindowID = Convert.ToInt32(ddlWindowsMaterial.SelectedValue); PermanentStructureobj.RoofConditionID = Convert.ToInt32(ddlRoofCondition.SelectedValue); PermanentStructureobj.WallConditionID = Convert.ToInt32(ddlWallsCondition.SelectedValue); PermanentStructureobj.FloorConditionID = Convert.ToInt32(ddlFloorCondition.SelectedValue); PermanentStructureobj.WindowConditionID = Convert.ToInt32(ddlWindowsCondition.SelectedValue); if (RbtnSelf.Checked == true) { PermanentStructureobj.Owner = RbtnSelf.Text; //RbtnOther.Checked = false; } else if (RbtnOther.Checked == true) { PermanentStructureobj.Owner = RbtnOther.Text; PermanentStructureobj.OwnerName = txtbxOther.Text; //RbtnSelf.Checked = false; } if (RdbtnSelfoccupied.Checked == true) { PermanentStructureobj.Occupant = RdbtnSelfoccupied.Text; //RdbtnOccupantOther.Checked = false; } else if (RdbtnOccupantOther.Checked == true) { PermanentStructureobj.Occupant = RdbtnOccupantOther.Text; PermanentStructureobj.OtherOccupantName = txtbxOccupantOther.Text.Trim(); //RdbtnSelfoccupied.Checked = false; } PermanentStructureobj.OccupantStatusID = Convert.ToInt32(ddlOccupantStatus.SelectedValue.ToString()); if (txtbxEnterStatus.Text != string.Empty) { PermanentStructureobj.OtherOccupantStatus = txtbxEnterStatus.Text; } else { PermanentStructureobj.OtherOccupantStatus = ""; } PermanentStructureobj.DimensionLength = Convert.ToDecimal(txtbxLength.Text); PermanentStructureobj.DimensionWidth = Convert.ToDecimal(txtbxWidth.Text); if (txtbxNoofrooms.Text != string.Empty) { PermanentStructureobj.NoOfRooms = Convert.ToInt32(txtbxNoofrooms.Text); } else { PermanentStructureobj.NoOfRooms = 0; } if (txtbxSurfaceArea.Text != string.Empty) { PermanentStructureobj.SurfaceArea = Convert.ToDecimal(txtbxSurfaceArea.Text); } else { PermanentStructureobj.SurfaceArea = 0; } PermanentStructureobj.DepreciatedValue = Convert.ToDecimal(txtbxDepreciatedValue.Text); PermanentStructureobj.ReplacementValue = Convert.ToDecimal(txtbxReplacementValue.Text); if (txtbxComments.Text != string.Empty) { if (txtbxComments.Text.Length > 1000) { PermanentStructureobj.AdditionalComments = txtbxComments.Text.Substring(0, 1000); } else { PermanentStructureobj.AdditionalComments = txtbxComments.Text; } } else { PermanentStructureobj.AdditionalComments = ""; } PermanentStructureobj.StructureType = ddlStructureType.SelectedValue.ToString(); PermanentStructureobj.IsDeleted = "False"; PermanentStructureobj.CreatedBy = Convert.ToInt32(uID); PermanentStructureBLL PBLLobj = new PermanentStructureBLL(); count = PBLLobj.Update(PermanentStructureobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "ShowUpdateMessage('');", true); Clear(); BindGrid(true, true); SetUpdateMode(false); } catch (Exception ex) { throw ex; } finally { BLLobj = null; } } }
/// <summary> /// To fetch details and assign to textbox /// </summary> private void GetData() { PermanentStructureBLL PermanentStructureBLLobj = new PermanentStructureBLL(); int STRUCTUREID = 0; if (ViewState["PERM_STRUCTUREID"] != null) { STRUCTUREID = Convert.ToInt32(ViewState["PERM_STRUCTUREID"]); } PermanentStructureBO BOobj = new PermanentStructureBO(); BOobj = PermanentStructureBLLobj.GetSTRUCTUREID(STRUCTUREID); perstructIDTextBox.Text = BOobj.PermanentStructureID.ToString(); //byte[] papPhotoBytes = (byte[])BOobj.Photo; // System.IO.MemoryStream objImage = (System.IO.MemoryStream)(RetrieveImage(BOobj.Photo as byte[])); // photoImage.ImageUrl = objImage.ToString(); ddlBuidingType.ClearSelection(); if (ddlBuidingType.Items.FindByValue(BOobj.StructureTypeID.ToString()) != null) { ddlBuidingType.Items.FindByValue(BOobj.StructureTypeID.ToString()).Selected = true; } otherSpecifyTextBox.Text = BOobj.OtherStructureType.ToString(); ddlRoofMaterial.ClearSelection(); if (ddlRoofMaterial.Items.FindByValue(BOobj.RoofID.ToString()) != null) { ddlRoofMaterial.Items.FindByValue(BOobj.RoofID.ToString()).Selected = true; } ddlWallsMaterial.ClearSelection(); if (ddlWallsMaterial.Items.FindByValue(BOobj.WallID.ToString()) != null) { ddlWallsMaterial.Items.FindByValue(BOobj.WallID.ToString()).Selected = true; } ddlFloorMaterial.ClearSelection(); if (ddlFloorMaterial.Items.FindByValue(BOobj.FloorID.ToString()) != null) { ddlFloorMaterial.Items.FindByValue(BOobj.FloorID.ToString()).Selected = true; } ddlWindowsMaterial.ClearSelection(); if (ddlWindowsMaterial.Items.FindByValue(BOobj.WindowID.ToString()) != null) { ddlWindowsMaterial.Items.FindByValue(BOobj.WindowID.ToString()).Selected = true; } ddlRoofCondition.ClearSelection(); if (ddlRoofCondition.Items.FindByValue(BOobj.RoofConditionID.ToString()) != null) { ddlRoofCondition.Items.FindByValue(BOobj.RoofConditionID.ToString()).Selected = true; } ddlWallsCondition.ClearSelection(); if (ddlWallsCondition.Items.FindByValue(BOobj.WallConditionID.ToString()) != null) { ddlWallsCondition.Items.FindByValue(BOobj.WallConditionID.ToString()).Selected = true; } ddlFloorCondition.ClearSelection(); if (ddlFloorCondition.Items.FindByValue(BOobj.FloorConditionID.ToString()) != null) { ddlFloorCondition.Items.FindByValue(BOobj.FloorConditionID.ToString()).Selected = true; } ddlWindowsCondition.ClearSelection(); if (ddlWindowsCondition.Items.FindByValue(BOobj.WindowConditionID.ToString()) != null) { ddlWindowsCondition.Items.FindByValue(BOobj.WindowConditionID.ToString()).Selected = true; } if (BOobj.Owner == "Self") { RbtnSelf.Checked = true; ScriptManager.RegisterStartupScript(this, this.GetType(), "OnClick123", "EnableDisableOtherOwner(0);", true); } else { RbtnOther.Checked = true; txtbxOther.Text = BOobj.OwnerName.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "OnClick43", "EnableDisableOtherOwner(1);", true); } if (BOobj.Occupant == "Self") { RdbtnSelfoccupied.Checked = true; ScriptManager.RegisterStartupScript(this, this.GetType(), "OnClick21", "EnableDisableOtherOccupant(0);", true); } else { RdbtnOccupantOther.Checked = true; ScriptManager.RegisterStartupScript(this, this.GetType(), "OnClick67", "EnableDisableOtherOccupant(1);", true); txtbxOccupantOther.Text = BOobj.OtherOccupantName; } ddlOccupantStatus.ClearSelection(); if (ddlOccupantStatus.Items.FindByValue(BOobj.OccupantStatusID.ToString()) != null) { ddlOccupantStatus.Items.FindByValue(BOobj.OccupantStatusID.ToString()).Selected = true; } txtbxEnterStatus.Text = BOobj.OtherOccupantStatus.ToString(); txtbxLength.Text = BOobj.DimensionLength.ToString(); txtbxWidth.Text = BOobj.DimensionWidth.ToString(); txtbxNoofrooms.Text = BOobj.NoOfRooms.ToString(); decimal j = Convert.ToDecimal(BOobj.DimensionLength.ToString()); decimal k = Convert.ToDecimal(BOobj.DimensionWidth.ToString()); decimal res = j * k; txtbxSurfaceArea.Text = Convert.ToString(res);//BOobj.SurfaceArea.ToString(); ddlStructureType.ClearSelection(); if (ddlStructureType.Items.FindByValue(BOobj.StructureType.ToString()) != null) { ddlStructureType.Items.FindByValue(BOobj.StructureType.ToString()).Selected = true; } txtbxDepreciatedValue.Text = BOobj.DepreciatedValue.ToString(); txtbxReplacementValue.Text = BOobj.ReplacementValue.ToString(); txtbxComments.Text = BOobj.AdditionalComments.ToString(); if (txtbxDepreciatedValue.Text.Trim().Length > 0 && txtbxReplacementValue.Text.Trim().Length > 0) { txtbxReplacementUplift.Text = (Convert.ToDouble(txtbxDepreciatedValue.Text.Trim()) - Convert.ToDouble(txtbxReplacementValue.Text.Trim())).ToString(); } //txtNeighbrID.Text = Neighbourobj.PAP_NEIGHBOURID1.ToString(); //txtNeibrName.Text = Neighbourobj.TRN_PAP_NEIGHBOURNAme1.ToString(); //ddldirectionDropDownList.SelectedItem.Text = Neighbourobj.DIRECTION1.ToString(); }
/// <summary> /// To delete the data from database /// </summary> /// <param name="structurId"></param> private void DeletePermanentStruct(string structurId) { PermanentStructureBLL PermanentStructureBLLobj = new PermanentStructureBLL(); PermanentStructureBLLobj.DeletePermanentStruct(structurId); }