public static string DeleteSysMenuGroup(string menugp_id, string user_id, string RequestID) { try { //Security Check if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "delete")) { throw new Exception("No Access."); } LINQ_SystemDataContext dc = new LINQ_SystemDataContext(); SYS_MenuGroup the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).FirstOrDefault(); if (the_record == null) { return("Error ~ We can't find"); } the_record.Active = false; the_record.ModifiedOn = DateTime.Now; the_record.ModifiedBy = user_id; the_record.LastAction = Guid.NewGuid().ToString(); dc.SubmitChanges(); return("Success~"); } catch (ChangeConflictException ex) { return("Error~" + ex.Message); } }
public static string SaveSysMenuGroup(string menugp_id, string user_id, string menu_gpcode, string menu_gpname, string menu_gpseq, string RequestID) { try { LINQ_SystemDataContext dc = new LINQ_SystemDataContext(); SYS_MenuGroup the_record = new SYS_MenuGroup(); if (menugp_id == "" || menugp_id == null) { the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).FirstOrDefault(); if (the_record == null) { //Security Check if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create")) { throw new Exception("No Access."); } the_record = new SYS_MenuGroup() { CreatedBy = user_id, CreatedOn = DateTime.Now, Active = true, MenuGroupID = Guid.NewGuid().ToString(), LastAction = Guid.NewGuid().ToString() }; dc.SYS_MenuGroups.InsertOnSubmit(the_record); } } else { //Security Check if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update")) { throw new Exception("No Access."); } the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).FirstOrDefault(); if (the_record == null) { throw new Exception("System cannot find the record"); } } the_record.ModifiedBy = user_id; the_record.ModifiedOn = DateTime.Now; the_record.LastAction = Guid.NewGuid().ToString(); the_record.MenuGroupCode = menu_gpcode; the_record.MenuGroupName = menu_gpname; the_record.MenuGroupSeq = Convert.ToInt32(menu_gpseq.ToString()); #region update the log SYS_MenuGroup log_obj = dc.GetChangeSet().Updates.OfType <SYS_MenuGroup>().FirstOrDefault(); if (log_obj != null) { if (Controller_SystemLog.WirteUpdateLog(dc.SYS_MenuGroups.GetModifiedMembers(log_obj).ToList(), the_record.MenuGroupID, RequestID) == false) { //Error fail to log. } } #endregion dc.SubmitChanges(); return("Success~" + the_record.MenuGroupName); } catch (Exception ex) { return("Error~" + ex.Message); } }