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/GovernmentWaterBodyData.aspx", true); } else if (CommandName == "delete") { ALRD_GovernmentWaterBodyDataEntity entity = new ALRD_GovernmentWaterBodyDataEntity { COMPID = Value }; long i = ALRD_GovernmentWaterBodyDataService.GetService().Delete(entity); LoadEntityList(new ALRD_GovernmentWaterBodyDataEntity()); SuccessMessage = "Information Deleted Successfully"; } } } catch (Exception ex) { Error = ex.Message; } }
private void LoadEntityList(ALRD_GovernmentWaterBodyDataEntity entity) { try { if (entity.PageSize < 0) { entity.PageSize = 10; } if (entity.SortExpression == string.Empty) { entity.SortExpression = "OrgName ASC"; } LocalEntityList = ALRD_GovernmentWaterBodyDataService.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 btnSave_Click(object sender, EventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { if (btnSave.Text == "Save") { ALRD_GovernmentWaterBodyDataEntity entity = BuiltEntity(); long i = ALRD_GovernmentWaterBodyDataService.GetService().Add(entity); if (i > 0) { SuccessMessage = "Information Saved Successfully"; LoadEntity(new ALRD_GovernmentWaterBodyDataEntity { COMPID = i }); } } else { ALRD_GovernmentWaterBodyDataEntity entity = BuiltEntity(); long i = ALRD_GovernmentWaterBodyDataService.GetService().Update(entity); if (i > 0) { SuccessMessage = "Information Updated Successfully"; LoadEntity(new ALRD_GovernmentWaterBodyDataEntity { COMPID = entity.COMPID }); } } DateTime currentDate = DateTime.Now; ddlYear.SelectedValue = currentDate.Year.ToString(); ddlMonth.SelectedValue = currentDate.Month.ToString(); } catch (Exception ex) { Error = ex.Message; } }
private void LoadEntity(ALRD_GovernmentWaterBodyDataEntity entity) { try { ALRD_GovernmentWaterBodyDataEntity objEntity = ALRD_GovernmentWaterBodyDataService.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.NoOfWaterBody20Under.HasValue) { txtNoOfWaterBody20Under.Text = objEntity.NoOfWaterBody20Under.ToString(); } if (objEntity.NoOfWaterBody20Over.HasValue) { txtNoOfWaterBody20Over.Text = objEntity.NoOfWaterBody20Over.ToString(); } if (objEntity.AreaOfWaterbody20Under.HasValue) { txtAreaOfWaterbody20Under.Text = objEntity.AreaOfWaterbody20Under.ToString(); } if (objEntity.AreaOfWaterbody20Over.HasValue) { txtAreaOfWaterbody20Over.Text = objEntity.AreaOfWaterbody20Over.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; } }