public static ReturnObject deleteEnrollment(string current) { lan_enroll page_object = new lan_enroll(); DBConnection db_connection = new DBConnection(); ReturnObject return_object = new ReturnObject(); Hashtable enrollment_data = new Hashtable(); string enroll_id = string.Empty; if (HttpContext.Current.Session["username"] == null) { // HttpContext.Current.Response.Redirect("~/logout.aspx", true); return_object = page_object.DoLogout(); } else { try { JObject current_data = JObject.Parse(current); enroll_id = current_data["Enrollid"].ToString(); enrollment_data.Add("Mode", "D"); enrollment_data.Add("enrollid", enroll_id); db_connection.ExecuteStoredProcedureWithHashtable_WithoutReturn("ManipulateEnrollement", enrollment_data); return_object.status = "success"; return_object.return_data = "Enrollment deleted successfully!"; } catch (Exception ex) { Logger.LogException(ex, page, "DELETE_ENROLLMENT"); return_object.status = "error"; return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support."; } } return(return_object); }
public static ReturnObject editEnrollment(string current) { lan_enroll page_object = new lan_enroll(); DBConnection db_connection = new DBConnection(); ReturnObject return_object = new ReturnObject(); string enroll_id = string.Empty; string pin_number = string.Empty; string employee_id = string.Empty; string employee_name = string.Empty; long card_id = 0; int input_mifare = 0; if (HttpContext.Current.Session["username"] == null) { // HttpContext.Current.Response.Redirect("~/logout.aspx", true); return_object = page_object.DoLogout(); } else { try { JObject current_data = JObject.Parse(current); enroll_id = current_data["Enrollid"].ToString(); card_id = Convert.ToInt64(current_data["cardid"]); pin_number = current_data["pin"].ToString(); employee_id = current_data["Empid"].ToString(); employee_name = current_data["Name"].ToString(); input_mifare = Convert.ToInt32(current_data["input_mifare"]); if (db_connection.GetRecordCount("select count(*) from Enrollmaster where Enrollid = '" + enroll_id + "' and Empid != '" + employee_id + "' ") > 0) { return_object.status = "error"; return_object.return_data = "Enrollment ID already exists. Please try again with a different Enrollment ID"; } else if (db_connection.GetRecordCount("select count(*) from Enrollmaster where Cardid = '" + card_id + "' and Empid != '" + employee_id + "' ") > 0) { return_object.status = "error"; return_object.return_data = "Card ID has been taken. Please try again with a different Card ID"; } else { page_object.updateDatabase("U", enroll_id, card_id, pin_number, employee_id, employee_name, input_mifare); return_object.status = "success"; return_object.return_data = "Enrollment details edited successfully!"; } } catch (Exception ex) { Logger.LogException(ex, page, "EDIT_ENROLLMENT"); return_object.status = "error"; return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support."; } finally { page_object.Dispose(); } } return(return_object); }