/// <summary> /// Getfencedatarow /// </summary> private void Getfencedatarow() { FenceBLL fenceBLLobj = new FenceBLL(); int Pap_fenceid = 0; if (ViewState["PAP_FENCEID"] != null) { Pap_fenceid = Convert.ToInt32(ViewState["PAP_FENCEID"]); } FenceBO FenceBOobj = new FenceBO(); FenceBOobj = fenceBLLobj.Getfencedatarow(Pap_fenceid); fenceDropDownList.ClearSelection(); if (fenceDropDownList.Items.FindByValue(FenceBOobj.Fenceid.ToString()) != null) { fenceDropDownList.Items.FindByValue(FenceBOobj.Fenceid.ToString()).Selected = true; } lengthTextBox.Text = FenceBOobj.Fen_dimen_length.ToString(); heightTextBox.Text = FenceBOobj.Fen_dimen_height.ToString(); surfaceareaTextBox.Text = (FenceBOobj.Fen_dimen_length * FenceBOobj.Fen_dimen_height).ToString(); depreciatedvalueTextBox.Text = FenceBOobj.Depreciatedvalue.ToString(); }
/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void BindGrid() { FenceBLL fenceBLLobj = new FenceBLL(); grdFence.DataSource = fenceBLLobj.GetFencedata(Convert.ToInt32(Session["HH_ID"])); grdFence.DataBind(); }
/// <summary> /// to assign values to dropdownlist /// </summary> private void GetFenceDescription() { FenceBLL FenceBLLobj = new FenceBLL(); fenceDropDownList.DataSource = FenceBLLobj.GetFencedescription(); fenceDropDownList.DataTextField = "Fencedescription"; fenceDropDownList.DataValueField = "Fenceid"; fenceDropDownList.DataBind(); fenceDropDownList.Items.Insert(0, "--Select--"); }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["PAP_FENCEID"] = e.CommandArgument; Getfencedatarow(); popupData(); SetUpdateMode(true); // lnkViewPhoto.Visible = true; } else if (e.CommandName == "DeleteRow") { int Pap_fenceid = Convert.ToInt32(e.CommandArgument); FenceBLL fenceBLLobj = new FenceBLL(); fenceBLLobj.Delete(Pap_fenceid); BindGrid(); SetUpdateMode(false); clearfields(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Data deleted successfully');", true); } }
/// <summary> /// To save details todatabase /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { int count = 0; FenceBLL fenceBLLobj = new FenceBLL(); FenceBO FenceBOobj = null; if (Convert.ToInt32(ViewState["PAP_FENCEID"]) > 0) { // update try { string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); FenceBOobj = new FenceBO(); FenceBOobj.Pap_fenceid = Convert.ToInt32(ViewState["PAP_FENCEID"]); FenceBOobj.Fenceid = Convert.ToInt32(fenceDropDownList.SelectedItem.Value); if (lengthTextBox.Text != string.Empty) { FenceBOobj.Fen_dimen_length = Convert.ToDecimal(lengthTextBox.Text); } else { FenceBOobj.Fen_dimen_length = Convert.ToDecimal(0); } if (heightTextBox.Text != string.Empty) { FenceBOobj.Fen_dimen_height = Convert.ToDecimal(heightTextBox.Text); } else { FenceBOobj.Fen_dimen_height = Convert.ToDecimal(0); } if (depreciatedvalueTextBox.Text != string.Empty) { FenceBOobj.Depreciatedvalue = Convert.ToDecimal(depreciatedvalueTextBox.Text); } else { FenceBOobj.Depreciatedvalue = 0; } // FenceBOobj.Fen_dimen_length = Convert.ToInt32(lengthTextBox.Text.ToString().Trim()); // FenceBOobj.Fen_dimen_height = Convert.ToInt32(widthTextBox.Text.ToString().Trim()); // FenceBOobj.Depreciatedvalue = Convert.ToInt32(depreciatedvalueTextBox.Text.ToString().Trim()); FenceBOobj.CreatedBy = Convert.ToInt32(Session["USER_ID"]); FenceBOobj.HouseholdID = Convert.ToInt32(hhid); if (photoFileUpload.HasFile) { byte[] fileBytes = photoFileUpload.FileBytes; FenceBOobj.Photo = fileBytes; } FenceBLL fenceupdateBLLobj = new FenceBLL(); count = fenceupdateBLLobj.EditFence(FenceBOobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "ShowUpdateMessage('');", true); clearfields(); BindGrid(); SetUpdateMode(false); } catch (Exception ex) { throw ex; } finally { fenceBLLobj = null; } } else { // insert try { string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); FenceBOobj = new FenceBO(); FenceBOobj.Pap_fenceid = Convert.ToInt32(ViewState["PAP_FENCEID"]); FenceBOobj.Fenceid = Convert.ToInt32(fenceDropDownList.SelectedValue); if (lengthTextBox.Text != string.Empty) { FenceBOobj.Fen_dimen_length = Convert.ToDecimal(lengthTextBox.Text); } else { FenceBOobj.Fen_dimen_length = Convert.ToDecimal(0); } if (heightTextBox.Text != string.Empty) { FenceBOobj.Fen_dimen_height = Convert.ToDecimal(heightTextBox.Text); } else { FenceBOobj.Fen_dimen_height = Convert.ToDecimal(0); } if (depreciatedvalueTextBox.Text != string.Empty) { FenceBOobj.Depreciatedvalue = Convert.ToDecimal(depreciatedvalueTextBox.Text); } else { FenceBOobj.Depreciatedvalue = 0; } // FenceBOobj.Fen_dimen_length = Convert.ToInt32(lengthTextBox.Text.ToString().Trim()); // FenceBOobj.Fen_dimen_height = Convert.ToInt32(widthTextBox.Text.ToString().Trim()); // FenceBOobj.Depreciatedvalue = Convert.ToInt32(depreciatedvalueTextBox.Text.ToString().Trim()); FenceBOobj.CreatedBy = Convert.ToInt32(uID); FenceBOobj.HouseholdID = Convert.ToInt32(hhid); if (photoFileUpload.HasFile) { byte[] fileBytes = photoFileUpload.FileBytes; FenceBOobj.Photo = fileBytes; } FenceBLL fencesaveBLLobj = new FenceBLL(); count = fencesaveBLLobj.Insert(FenceBOobj); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "ShowSaveMessage('');", true); clearfields(); BindGrid(); SetUpdateMode(false); } catch (Exception ex) { throw ex; } finally { fenceBLLobj = null; } } ChangeRequestStatusFence(); projectFrozen(); }