public int UpdateRole(int input)
        {
            System.Console.Write("MASUKKAN NAMA        : ");
            string Nama = System.Console.ReadLine();

            Console.WriteLine("\n");
            Console.WriteLine("=============================================");
            System.Console.Write("MASUKKAN ULANG ID    : ");
            string id_role = System.Console.ReadLine();

            var getmhs = hld_context.Role_s.Find(Convert.ToInt16(id_role));

            if (getmhs == null)
            {
                System.Console.Write("TIDAK ADA ID ROLE : " + id_role);
            }
            else
            {
                RoleCls role = GetById(input);
                role.Role = Nama;

                hld_context.Entry(role).State = System.Data.Entity.EntityState.Modified;
                hld_context.SaveChanges();
            }
            return(input);
        }
Beispiel #2
0
 static int GetIkey(RoleCls role)
 {
     if (role.rsave.sex == Sex.Female)
     {
         return(10000000 + role.ikey);
     }
     else
     {
         return(role.ikey);
     }
 }
        // =========================================== INSERT =============================================
        public void InsertRole()
        {
            Console.Clear();
            System.Console.Write("Nama Role : ");
            string Nama_Role = System.Console.ReadLine();

            RoleCls call = new RoleCls();

            {
                call.Role = Nama_Role;
            };
            try
            {
                hld_context.Role_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }