private void FillData() { if (!String.IsNullOrEmpty(queryStringIdStr)) { ServiceInfoManager _ServiceInfoManager = new ServiceInfoManager(); var obj = _ServiceInfoManager.GetServiceInfo(queryStringId); if (obj != null) { txtTitle.Text = obj.Title; txtDescription.Text = obj.Description.Replace("<br/>", "\r\n"); txtSection.Text = obj.Section; txtAddress.Text = obj.Address.Replace("<br/>", "\r\n"); string lat = obj.Latitude; string lng = obj.Longitude; if (!String.IsNullOrEmpty(lat) && !String.IsNullOrEmpty(lng)) { ucLocation.Lat = lat; ucLocation.Lng = lng; } if (obj.SaudiStudentAssociationId.HasValue) { ddlSSA.Items.FindByValue(obj.SaudiStudentAssociationId.Value.ToString()).Selected = true; } if (obj.ServiceCategoryId.HasValue) { ddlServiceCategory.Items.FindByValue(obj.ServiceCategoryId.Value.ToString()).Selected = true; } Operation = (String)GetGlobalResourceObject("HCMResource", "UpdateExisting"); } else { Operation = (String)GetGlobalResourceObject("HCMResource", "AddNew"); ucLocation.Lat = "36.63209344924568"; ucLocation.Lng = "-101.74928646693019"; ucLocation.Zoom = 5; } } else { Operation = (String)GetGlobalResourceObject("HCMResource", "AddNew"); ucLocation.Lat = "36.63209344924568"; ucLocation.Lng = "-101.74928646693019"; ucLocation.Zoom = 5; } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { string un = AspNetSecurityHelper.GetCurrentUserName; ServiceInfoManager _ServiceInfoManager = new ServiceInfoManager(); if (e.CommandName == "DeleteUpdate") { string Id = e.CommandArgument.ToString(); int id = 0; if (int.TryParse(Id, out id)) { bool chk = _ServiceInfoManager.CheckCanDeleted(id); if (chk) { string operation = (String)GetGlobalResourceObject("HCMResource", "Delete"); int i = 0;//_ServiceInfoManager.DeleteServiceInfo(id); DAL.Entity.ServiceInformation obj = _ServiceInfoManager.GetServiceInfo(id); if (obj != null) { obj.DeletedFlag = true; obj.LastUpdatedBy = un; obj.LastUpdatedDate = DateTime.Now; i = _ServiceInfoManager.UpdateServiceInfo(obj); } if (i != 0) { ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationSuccess"), operation), "", Common.msgType.alertMessageSuccess); } else { ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationError"), operation), "", Common.msgType.alertMessageDanger); } } else { ucAlertMessage.AlertMessage((String)GetGlobalResourceObject("HCMResource", "CantDelete"), "", Common.msgType.alertMessageDanger); } FillData(); } } }
private void FillData() { ServiceDetailsManager _ServiceDetailsManager = new ServiceDetailsManager(); ServiceInfoManager _ServiceInfoManager = new ServiceInfoManager(); SSAManager _SSAManager = new SSAManager(); var user = AspNetSecurityHelper.currentAppUser; if (user != null) { sessionId = queryStringId; var mster = _ServiceInfoManager.GetServiceInfo(queryStringId); var obj = _ServiceDetailsManager.GetAllByServiceInfoId(queryStringId); if (mster != null) { lblSSA.Text = mster.SaudiStudentAssociation.Name; lblServiceInfo.Text = mster.Title; } if (obj != null) { var data = from tbl in obj select new { tbl.Id, tbl.InfoTypeId, tbl.FileExt, InfoType = tbl.InfoType.Name, tbl.InformationContent, svcInfoId = tbl.ServiceInformationId, SSA = tbl.ServiceInformation.SaudiStudentAssociation.Name, SvcInfo = tbl.ServiceInformation.Title }; GridView1.DataSource = data.ToList(); } } GridView1.DataBind(); }
protected void btnSave_Click(object sender, EventArgs e) { var user = AspNetSecurityHelper.currentAppUser; if (user != null) { ServiceInfoManager _ServiceInfoManager = new ServiceInfoManager(); SSAManager _SSAManager = new SSAManager(); DAL.Entity.ServiceInformation obj = _ServiceInfoManager.GetServiceInfo(queryStringId); if (obj == null) { obj = new DAL.Entity.ServiceInformation(); } obj.Title = txtTitle.Text; obj.Description = txtDescription.Text.Replace("\r\n", "<br/>"); obj.Section = txtSection.Text; obj.Address = txtAddress.Text.Replace("\r\n", "<br/>"); string lat = ucLocation.Lat; string lng = ucLocation.Lng; if (!String.IsNullOrEmpty(lat) && !String.IsNullOrEmpty(lng)) { obj.Latitude = lat; obj.Longitude = lng; } int cat = 0; if (int.TryParse(ddlServiceCategory.SelectedValue, out cat) && cat != 0) { obj.ServiceCategoryId = cat; } if (user.UserTypeId == 2) // Supervisor { if (user.UniversityId.HasValue) { var ssa = _SSAManager.GetSSAByUniversityId(user.UniversityId.Value); if (ssa != null) { obj.SaudiStudentAssociationId = ssa.Id; } } } else // Administrator { string SSA = ddlSSA.SelectedValue; int ssa = 0; if (int.TryParse(SSA, out ssa) && ssa != 0) { obj.SaudiStudentAssociationId = ssa; } } int i = 0; if (obj.Id == 0) { obj.CreatedBy = user.UserName; obj.CreatedDate = DateTime.Now; obj.DeletedFlag = false; i = _ServiceInfoManager.AddServiceInfo(obj); Operation = (String)GetGlobalResourceObject("HCMResource", "Add"); btnSave.Visible = false; } else { obj.LastUpdatedBy = user.UserName; obj.LastUpdatedDate = DateTime.Now; i = _ServiceInfoManager.UpdateServiceInfo(obj); Operation = (String)GetGlobalResourceObject("HCMResource", "Update"); } if (i != 0) { ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationSuccess"), Operation), "", Common.msgType.alertMessageSuccess); FillData(); } else { ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationError"), Operation), "", Common.msgType.alertMessageDanger); } } else { Response.Redirect("/"); } }