Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (HospitalEntities context = new HospitalEntities())
            {
                try
                {
                    int result = (int)(context.GetNewAdminId().FirstOrDefault());
                    if (result > -1)
                    {
                        Admin p = new Admin()
                        {
                            Id_Admin = result,
                            Id_pegawai = System.Convert.ToInt32(textBox2.Text),
                            User_name = textBox3.Text,
                            Password = textBox4.Text,

                        };
                        AdminController pc = new AdminController();
                        pc.addAdmin(p);
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("Data harus teriisi semua");
                }
            }
        }
Ejemplo n.º 2
0
        public void updateAdmin(Admin ad)
        {
            Admin updateAdmin = (from b in context.Admins
                                         where b.Id_Admin == ad.Id_Admin
                                         select b).FirstOrDefault();
            if (updateAdmin != null)
            {
               // updateAdmin.Id_Admin = ad.Id_Admin;
                updateAdmin.Id_pegawai = ad.Id_pegawai;
                updateAdmin.User_name = ad.User_name;
                updateAdmin.Password = ad.Password;
                context.SaveChanges();

            }
            else
            {
                Console.WriteLine("No update");
            }
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Admin p = new Admin()
                {
                    Id_Admin = System.Convert.ToInt32(textBox1.Text),
                    Id_pegawai = System.Convert.ToInt32(textBox2.Text),
                    User_name = textBox3.Text,
                    Password = textBox4.Text,

                };
                AdminController pc = new AdminController();
                pc.updateAdmin(p);
            }
            catch (FormatException fe)
            {
                MessageBox.Show("Data harus terisi semua");
            }
        }
Ejemplo n.º 4
0
 public void addAdmin(Admin admin)
 {
     context.Admins.Add(admin);
     context.SaveChanges();
 }