public static int UpdateT_VCCB_ROLE(int idx, string newROLE_NAME, string newROLE_DESC, string newMODIFY_USR) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { try { T_OE_ROLES row = new T_OE_ROLES(); row = (from c in ctx.T_OE_ROLES where c.ROLE_IDX == idx select c).First(); if (newROLE_NAME != null) { row.ROLE_NAME = newROLE_NAME; } if (newROLE_DESC != null) { row.ROLE_DESC = newROLE_DESC; } if (newMODIFY_USR != null) { row.MODIFY_USERID = newMODIFY_USR; } row.MODIFY_DT = System.DateTime.Now; ctx.SaveChanges(); return(1); } catch (Exception ex) { return(0); } } }
public static int DeleteT_VCCB_ROLE(int idx) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { try { T_OE_ROLES row = new T_OE_ROLES(); row = (from c in ctx.T_OE_ROLES where c.ROLE_IDX == idx select c).First(); ctx.DeleteObject(row); ctx.SaveChanges(); return(1); } catch (Exception ex) { return(0); } } }
//*****************ROLES ********************************** public static int CreateT_OE_ROLES(global::System.String rOLE_NAME, global::System.String rOLE_DESC, global::System.String cREATE_USER = "******") { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { try { T_OE_ROLES r = new T_OE_ROLES(); r.ROLE_NAME = rOLE_NAME; r.ROLE_DESC = rOLE_DESC; r.CREATE_DT = System.DateTime.Now; r.CREATE_USERID = cREATE_USER; ctx.AddToT_OE_ROLES(r); ctx.SaveChanges(); return(1); } catch (Exception ex) { return(0); } } }
protected void btnSave_Click(object sender, EventArgs e) { try { //check duplicate role name T_OE_ROLES r = db_Accounts.GetT_VCCB_ROLEByName(txtRoleName.Text); if (r != null) { lblMsg.Text = "Role name already exists. Please try again."; } else { db_Accounts.CreateT_OE_ROLES(txtRoleName.Text, txtRoleDesc.Text, User.Identity.Name); Response.Redirect("~/Account/RoleList.aspx"); } } catch (Exception exp) { Console.WriteLine(exp); } }