private void LoadEntityList(ALRD_GovernmentForestryBodyDataEntity entity) { try { if (entity.PageSize < 0) { entity.PageSize = 10; } if (entity.SortExpression == string.Empty) { entity.SortExpression = "OrgName ASC"; } LocalEntityList = ALRD_GovernmentForestryBodyDataService.GetService().GetAll(entity).ToList(); if (LocalEntityList != null && LocalEntityList.Count > 0) { lsvUserList.DataSource = LocalEntityList; lsvUserList.DataBind(); } else { lsvUserList.DataSource = null; lsvUserList.DataBind(); } } catch (Exception ex) { Error = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { this.CheckFormPermission(this.FormID); LoadCombo(); SearchEntity = new ALRD_GovernmentForestryBodyDataEntity(); //if (Request.QueryString["hid"] != null && !string.IsNullOrEmpty(Request.QueryString["hid"].ToString())) if (GlobalClass.GovtInfoID > 0) { SearchEntity.COMPID = GlobalClass.GovtInfoID; } else { SearchEntity.COMPID = -99; } LoadEntity(SearchEntity); } } catch (Exception ex) { Error = ex.Message; } }
protected void lsvUserList_ItemCommand(object sender, ListViewCommandEventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { string CommandName = e.CommandName.ToString(); string CommandArgument = e.CommandArgument.ToString(); if (CommandArgument.ToString() != "") { long Value = long.Parse(CommandArgument.ToString()); if (CommandName == "edit") { GlobalClass.GovtInfoID = Value; Response.Redirect("~/Pages/Admin/GovernmentForestryBodyData.aspx", true); } else if (CommandName == "delete") { ALRD_GovernmentForestryBodyDataEntity entity = new ALRD_GovernmentForestryBodyDataEntity { COMPID = Value }; long i = ALRD_GovernmentForestryBodyDataService.GetService().Delete(entity); LoadEntityList(new ALRD_GovernmentForestryBodyDataEntity()); SuccessMessage = "Information Deleted Successfully"; } } } catch (Exception ex) { Error = ex.Message; } }
long IALRD_GovernmentForestryBodyDataDao.Add(ALRD_GovernmentForestryBodyDataEntity entity) { long returnCode = -99; const string SP = "alrd_governmentforestrybodydata_Insert"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { FillParameters(entity, cmd, Database); //FillSequrityParameters(securityCapsule, cmd, OparationType.Save, Database); AddOutputParameter(cmd); try { returnCode = Database.ExecuteNonQuery(cmd); // GetReturnCodeFromParameter(cmd); if (returnCode == 1) { returnCode = Convert.ToInt64(cmd.Parameters["@RETURN_KEY"].Value); } else { returnCode = -99; } } catch (Exception ex) { throw GetDataAccessException(ex, SourceOfException("Add")); } } return(returnCode); }
long IALRD_GovernmentForestryBodyDataDao.Update(ALRD_GovernmentForestryBodyDataEntity entity, bool isPertial = false) { long returnCode = -99; string SP; if (!isPertial) { SP = "alrd_governmentforestrybodydata_Update"; } else { SP = "alrd_governmentforestrybodydata_PertialUpdate"; } using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { FillParameters(entity, cmd, Database); //FillSequrityParameters(securityCapsule, cmd, OparationType.Update, Database); AddOutputParameter(cmd); try { returnCode = Database.ExecuteNonQuery(cmd); } catch (Exception ex) { throw GetDataAccessException(ex, SourceOfException("Update")); } } return(returnCode); }
protected void btnFilter_Click(object sender, EventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { SearchEntity = BuiltEntity(); LoadEntityList(SearchEntity); } catch (Exception ex) { Error = ex.Message; } }
private ALRD_GovernmentForestryBodyDataEntity BuiltEntity(ALRD_GovernmentForestryBodyDataEntity entity = null) { try { if (entity == null) { entity = new ALRD_GovernmentForestryBodyDataEntity(); } entity.COMPID = hdnCOMPID.Value.Trim() != string.Empty ? long.Parse(hdnCOMPID.Value.Trim()) : (long?)null; entity.CollCollectionYear = ddlYear.SelectedIndex > 0 ? long.Parse(ddlYear.SelectedValue) : (long?)null; entity.CollectionMonth = ddlMonth.SelectedIndex > 0 ? long.Parse(ddlMonth.SelectedValue) : (long?)null; entity.DivisionID = ddlDivision.SelectedIndex > 0 ? long.Parse(ddlDivision.SelectedValue) : (long?)null; entity.DistrictID = ddlDistrict.SelectedIndex > 0 ? long.Parse(ddlDistrict.SelectedValue) : (long?)null; entity.UpazilaID = ddlUpazilla.SelectedIndex > 0 ? long.Parse(ddlUpazilla.SelectedValue) : (long?)null; entity.Remarks = txtRemarks.Text != string.Empty ? txtRemarks.Text.Trim() : string.Empty; entity.TotalCurtailedAreaWoodlot = txtTotalCurtailedAreaWoodlot.Text.Trim() != string.Empty ? decimal.Parse(txtTotalCurtailedAreaWoodlot.Text.Trim()) : (decimal?)null; entity.TotalCurtailedAreaAgri = txtTotalCurtailedAreaAgri.Text.Trim() != string.Empty ? decimal.Parse(txtTotalCurtailedAreaAgri.Text.Trim()) : (decimal?)null; entity.TotalCurtailedAreaStrip = txtTotalCurtailedAreaStrip.Text.Trim() != string.Empty ? decimal.Parse(txtTotalCurtailedAreaStrip.Text.Trim()) : (decimal?)null; entity.NoOfBeneficiary = txtNoOfBeneficiary.Text.Trim() != string.Empty ? decimal.Parse(txtNoOfBeneficiary.Text.Trim()) : (decimal?)null; entity.MoneyDistributed = txtMoneyDistributed.Text.Trim() != string.Empty ? decimal.Parse(txtMoneyDistributed.Text.Trim()) : (decimal?)null; if (entity.COMPID.HasValue) { entity.UpdatedBy = GlobalClass.UserID; entity.UpdatedOn = DateTime.Now; entity.CreatedBy = hdnCreatedBy.Value.Trim() != string.Empty ? long.Parse(hdnCreatedBy.Value.Trim()) : (long?)null; entity.CreatedOn = GetDateFromString(hdnCreatedOn.Value.Trim()); } else { entity.CreatedBy = GlobalClass.UserID; entity.CreatedOn = DateTime.Now; } } catch (Exception ex) { throw ex; } return(entity); }
private ALRD_GovernmentForestryBodyDataEntity BuiltEntity(ALRD_GovernmentForestryBodyDataEntity entity = null) { try { if (entity == null) { entity = new ALRD_GovernmentForestryBodyDataEntity(); } entity.DivisionID = ddlDivision.SelectedIndex > 0 ? long.Parse(ddlDivision.SelectedValue) : (long?)null; entity.DistrictID = ddlDistrict.SelectedIndex > 0 ? long.Parse(ddlDistrict.SelectedValue) : (long?)null; entity.UpazilaID = ddlUpazilla.SelectedIndex > 0 ? long.Parse(ddlUpazilla.SelectedValue) : (long?)null; entity.CollCollectionYear = ddlYear.SelectedIndex > 0 ? long.Parse(ddlYear.SelectedValue) : (long?)null; entity.CollectionMonth = ddlMonth.SelectedIndex > 0 ? long.Parse(ddlMonth.SelectedValue) : (long?)null; } catch (Exception ex) { throw ex; } return(entity); }
protected void btnSave_Click(object sender, EventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { if (btnSave.Text == "Save") { ALRD_GovernmentForestryBodyDataEntity entity = BuiltEntity(); long i = ALRD_GovernmentForestryBodyDataService.GetService().Add(entity); if (i > 0) { SuccessMessage = "Information Saved Successfully"; LoadEntity(new ALRD_GovernmentForestryBodyDataEntity { COMPID = i }); } } else { ALRD_GovernmentForestryBodyDataEntity entity = BuiltEntity(); long i = ALRD_GovernmentForestryBodyDataService.GetService().Update(entity); if (i > 0) { SuccessMessage = "Information Updated Successfully"; LoadEntity(new ALRD_GovernmentForestryBodyDataEntity { COMPID = entity.COMPID }); } } DateTime currentDate = DateTime.Now; ddlYear.SelectedValue = currentDate.Year.ToString(); ddlMonth.SelectedValue = currentDate.Month.ToString(); } catch (Exception ex) { Error = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { GlobalClass.GovtInfoID = -99; this.CheckFormPermission(this.FormID); this.CheckButtonPermission(null, null, null, lnkAddNew); LoadCombo(); SearchEntity = new ALRD_GovernmentForestryBodyDataEntity(); SearchEntity.CurrentPage = 1; SearchEntity.PageSize = 10; LoadEntityList(SearchEntity); } } catch (Exception ex) { Error = ex.Message; } }
private void LoadEntity(ALRD_GovernmentForestryBodyDataEntity entity) { try { ALRD_GovernmentForestryBodyDataEntity objEntity = ALRD_GovernmentForestryBodyDataService.GetService().GetAll(entity).FirstOrDefault(); ClearControlStates(pnlForm); if (objEntity != null && objEntity.COMPID != null && objEntity.COMPID > 0) { GlobalClass.FormUserID = (long)objEntity.COMPID; hdnCOMPID.Value = objEntity.COMPID.ToString(); if (objEntity.CollCollectionYear.HasValue) { ddlYear.SelectedValue = objEntity.CollCollectionYear.ToString(); } if (objEntity.CollectionMonth.HasValue) { ddlMonth.SelectedValue = objEntity.CollectionMonth.ToString(); } if (objEntity.DivisionID.HasValue) { ddlDivision.SelectedValue = objEntity.DivisionID.ToString(); } ddlDivision_SelectedIndexChanged(null, null); if (objEntity.DistrictID.HasValue && ddlDistrict.Items.FindByValue(objEntity.DistrictID.ToString()) != null) { ddlDistrict.SelectedValue = objEntity.DistrictID.ToString(); } ddlDistrict_SelectedIndexChanged(null, null); if (objEntity.UpazilaID.HasValue && ddlUpazilla.Items.FindByValue(objEntity.UpazilaID.ToString()) != null) { ddlUpazilla.SelectedValue = objEntity.UpazilaID.ToString(); } txtRemarks.Text = objEntity.Remarks; if (objEntity.TotalCurtailedAreaWoodlot.HasValue) { txtTotalCurtailedAreaWoodlot.Text = objEntity.TotalCurtailedAreaWoodlot.ToString(); } if (objEntity.TotalCurtailedAreaAgri.HasValue) { txtTotalCurtailedAreaAgri.Text = objEntity.TotalCurtailedAreaAgri.ToString(); } if (objEntity.TotalCurtailedAreaStrip.HasValue) { txtTotalCurtailedAreaStrip.Text = objEntity.TotalCurtailedAreaStrip.ToString(); } if (objEntity.NoOfBeneficiary.HasValue) { txtNoOfBeneficiary.Text = objEntity.NoOfBeneficiary.ToString(); } if (objEntity.MoneyDistributed.HasValue) { txtMoneyDistributed.Text = objEntity.MoneyDistributed.ToString(); } if (objEntity.CreatedBy.HasValue) { hdnCreatedBy.Value = objEntity.CreatedBy.ToString(); } hdnCreatedOn.Value = GetStringFromDate(objEntity.CreatedOn); btnSave.Text = "Update"; btnSave.OnClientClick = "javascript:return validateSubmit('Do you want to update this information?');"; this.CheckButtonPermission(null, btnSave, null); } else { GlobalClass.FormUserID = -99; btnSave.Text = "Save"; btnSave.OnClientClick = "javascript:return validateSubmit('Do you want to save this information?');"; this.CheckButtonPermission(btnSave, null, null); DateTime currentDate = DateTime.Now; ddlYear.SelectedValue = currentDate.Year.ToString(); ddlMonth.SelectedValue = currentDate.Month.ToString(); } } catch (Exception ex) { Error = ex.Message; } }
public static void FillParameters(ALRD_GovernmentForestryBodyDataEntity entity, DbCommand cmd, Database Database, bool forDelete = false) { if (entity.COMPID.HasValue) { Database.AddInParameter(cmd, "@COMPID", DbType.Int64, entity.COMPID); } if (forDelete) { return; } if (!(string.IsNullOrEmpty(entity.Remarks))) { Database.AddInParameter(cmd, "@Remarks", DbType.String, entity.Remarks); } if (entity.CollectionMonth.HasValue) { Database.AddInParameter(cmd, "@CollectionMonth", DbType.Int64, entity.CollectionMonth); } if (entity.CollCollectionYear.HasValue) { Database.AddInParameter(cmd, "@CollCollectionYear", DbType.Int64, entity.CollCollectionYear); } if (entity.DivisionID.HasValue) { Database.AddInParameter(cmd, "@DivisionID", DbType.Int64, entity.DivisionID); } if (entity.DistrictID.HasValue) { Database.AddInParameter(cmd, "@DistrictID", DbType.Int64, entity.DistrictID); } if (entity.UpazilaID.HasValue) { Database.AddInParameter(cmd, "@UpazilaID", DbType.Int64, entity.UpazilaID); } if (entity.TotalCurtailedAreaWoodlot.HasValue) { Database.AddInParameter(cmd, "@TotalCurtailedAreaWoodlot", DbType.Decimal, entity.TotalCurtailedAreaWoodlot); } if (entity.TotalCurtailedAreaAgri.HasValue) { Database.AddInParameter(cmd, "@TotalCurtailedAreaAgri", DbType.Decimal, entity.TotalCurtailedAreaAgri); } if (entity.TotalCurtailedAreaStrip.HasValue) { Database.AddInParameter(cmd, "@TotalCurtailedAreaStrip", DbType.Decimal, entity.TotalCurtailedAreaStrip); } if (entity.NoOfBeneficiary.HasValue) { Database.AddInParameter(cmd, "@NoOfBeneficiary", DbType.Decimal, entity.NoOfBeneficiary); } if (entity.MoneyDistributed.HasValue) { Database.AddInParameter(cmd, "@MoneyDistributed", DbType.Decimal, entity.MoneyDistributed); } if (entity.CreatedBy.HasValue) { Database.AddInParameter(cmd, "@CreatedBy", DbType.Int64, entity.CreatedBy); } if (entity.CreatedOn.HasValue) { Database.AddInParameter(cmd, "@CreatedOn", DbType.DateTime, entity.CreatedOn); } if (entity.UpdatedBy.HasValue) { Database.AddInParameter(cmd, "@UpdatedBy", DbType.Int64, entity.UpdatedBy); } if (entity.UpdatedOn.HasValue) { Database.AddInParameter(cmd, "@UpdatedOn", DbType.DateTime, entity.UpdatedOn); } }
IList <ALRD_GovernmentForestryBodyDataEntity> IALRD_GovernmentForestryBodyDataDao.GetAll(ALRD_GovernmentForestryBodyDataEntity entity) { try { const string SP = "alrd_governmentforestrybodydata_GetAll"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddSortExpressionParameter(cmd, entity.SortExpression); FillParameters(entity, cmd, Database); IList <ALRD_GovernmentForestryBodyDataEntity> itemList = new List <ALRD_GovernmentForestryBodyDataEntity>(); using (IDataReader reader = Database.ExecuteReader(cmd)) { while (reader.Read()) { itemList.Add(new ALRD_GovernmentForestryBodyDataEntity(reader)); } } return(itemList); } } catch (Exception ex) { throw GetDataAccessException(ex, SourceOfException("GetAll")); } }