protected void btnSave_Click(object sender, EventArgs e) { var user = AspNetSecurityHelper.currentAppUser; if (user != null) { UniversityManager _UniversityManager = new UniversityManager(); SSAManager _SSAManager = new SSAManager(); DAL.Entity.University obj = _UniversityManager.GetUniversity(queryStringId); if (obj == null) { obj = new DAL.Entity.University(); } obj.Name = txtUniversity.Text; int i = 0; if (obj.Id == 0) { obj.CreatedBy = user.UserName; obj.CreatedDate = DateTime.Now; obj.DeletedFlag = false; i = _UniversityManager.AddUniversity(obj); Operation = (String)GetGlobalResourceObject("HCMResource", "Add"); btnSave.Visible = false; } else { obj.LastUpdatedBy = user.UserName; obj.LastUpdatedDate = DateTime.Now; i = _UniversityManager.UpdateUniversity(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("/"); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { string un = AspNetSecurityHelper.GetCurrentUserName; UniversityManager _UniversityManager = new UniversityManager(); if (e.CommandName == "DeleteUpdate") { string Id = e.CommandArgument.ToString(); int id = 0; if (int.TryParse(Id, out id)) { bool chk = _UniversityManager.CheckCanDeleted(id); if (chk) { string operation = (String)GetGlobalResourceObject("HCMResource", "Delete"); int i = 0;//_UniversityManager.DeleteUniversity(id); DAL.Entity.University obj = _UniversityManager.GetUniversity(id); if (obj != null) { obj.DeletedFlag = true; obj.LastUpdatedBy = un; obj.LastUpdatedDate = DateTime.Now; i = _UniversityManager.UpdateUniversity(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() { if (!String.IsNullOrEmpty(queryStringIdStr)) { UniversityManager _UniversityManager = new UniversityManager(); var obj = _UniversityManager.GetUniversity(queryStringId); if (obj != null) { txtUniversity.Text = obj.Name; Operation = (String)GetGlobalResourceObject("HCMResource", "UpdateExisting"); } else { Operation = (String)GetGlobalResourceObject("HCMResource", "AddNew"); } } else { Operation = (String)GetGlobalResourceObject("HCMResource", "AddNew"); } }