コード例 #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         Pegawai p = new Pegawai()
         {
             ID_Pegawai     = System.Convert.ToInt32(textBox1.Text),
             Jenis_Pegawai  = comboBox1.Text,
             Nama_Pegawai   = textBox2.Text,
             Alamat_Pegawai = textBox3.Text,
             Telp_Pegawai   = System.Convert.ToInt32(textBox5.Text),
             Kota           = textBox4.Text,
             Email          = textBox6.Text
         };
         PegawaiController pc = new PegawaiController();
         pc.updatePegawai(p);
     }
     catch (FormatException fe)
     {
         MessageBox.Show("Data Harus Terisi semua");
     }
     textBox1.Clear();
     textBox2.Clear();
     comboBox1.ResetText();
     textBox3.Clear();
     textBox4.Clear();
     textBox5.Clear();
     textBox6.Clear();
 }
コード例 #2
0
        public void AddPegawai()
        {
            PegawaiController pc = new PegawaiController();
            int count1 = (pc.ShowData().Count()) + 1;

            using (HospitalEntities context = new HospitalEntities())
            {
                int result = (int)(context.GetNewPegawaiId().FirstOrDefault());
                if (result > -1)
                {
                    Pegawai p = new Pegawai()
                    {
                        ID_Pegawai = result,
                        Jenis_Pegawai = "Dokter",
                        Nama_Pegawai = "Ipir",
                        Alamat_Pegawai = "Keputih",
                        Telp_Pegawai = 0912,
                        Kota = "asd",
                        Email = "asdfs"
                    };
                    //PegawaiController pac = new PegawaiController();
                    pc.AddPegawi(p);
                }

                int count2 = pc.ShowData().Count();

                Assert.AreEqual(count1, count2, "Wrong");

            }
        }
コード例 #3
0
        public void deletePegawai(int a)
        {
            Pegawai pegawaiDelete = context.Pegawais.Find(a);

            if (pegawaiDelete != null)
            {
                context.Pegawais.Remove(pegawaiDelete);
                context.SaveChanges();
            }
        }
コード例 #4
0
 public void AddPegawi(Pegawai Pegawai)
 {
     try
     {
         Console.WriteLine("Insert Success");
         context.Pegawais.Add(Pegawai);
         context.SaveChanges();
         Console.WriteLine("Add Success");
     }
     catch (Exception ex)
     {
         {
             Console.WriteLine("Error on inserting...");
             Console.WriteLine(ex.InnerException.
             InnerException.Message);
         }
     }
 }
コード例 #5
0
 public void AddPegawi(Pegawai Pegawai)
 {
     try
     {
         Console.WriteLine("Insert Success");
         context.Pegawais.Add(Pegawai);
         context.SaveChanges();
         Console.WriteLine("Add Success");
     }
     catch (Exception ex)
     {
         {
             Console.WriteLine("Error on inserting...");
             Console.WriteLine(ex.InnerException.
                               InnerException.Message);
         }
     }
 }
コード例 #6
0
        public void updatePegawai(Pegawai e)
        {
            Pegawai UpdatePegawai = (from b in context.Pegawais
                                     where b.ID_Pegawai == e.ID_Pegawai
                                     select b).FirstOrDefault();

            if (UpdatePegawai != null)
            {
                //UpdatePegawai.ID_Pegawai = e.ID_Pegawai;
                UpdatePegawai.Jenis_Pegawai  = e.Jenis_Pegawai;
                UpdatePegawai.Nama_Pegawai   = e.Nama_Pegawai;
                UpdatePegawai.Alamat_Pegawai = e.Alamat_Pegawai;
                UpdatePegawai.Telp_Pegawai   = e.Telp_Pegawai;
                UpdatePegawai.Kota           = e.Kota;
                UpdatePegawai.Email          = e.Email;
                context.SaveChanges();
            }
            else
            {
                Console.WriteLine("No Update");
            }
        }
コード例 #7
0
 public void updatePegawai(Pegawai e)
 {
    
         Pegawai UpdatePegawai = (from b in context.Pegawais
                                   where b.ID_Pegawai == e.ID_Pegawai
                                   select b).FirstOrDefault();
         if (UpdatePegawai != null)
         {
             //UpdatePegawai.ID_Pegawai = e.ID_Pegawai;
             UpdatePegawai.Jenis_Pegawai = e.Jenis_Pegawai;
             UpdatePegawai.Nama_Pegawai = e.Nama_Pegawai;
             UpdatePegawai.Alamat_Pegawai = e.Alamat_Pegawai;
             UpdatePegawai.Telp_Pegawai = e.Telp_Pegawai;
             UpdatePegawai.Kota = e.Kota;
             UpdatePegawai.Email = e.Email;
             context.SaveChanges();
         }
         else
         {
             Console.WriteLine("No Update");
         }
     
 }
コード例 #8
0
        private void Tambah_Click(object sender, EventArgs e)
        {
            using (HospitalEntities context = new HospitalEntities())
            {
                try
                {
                    int result = (int)(context.GetNewPegawaiId().FirstOrDefault());
                    if (result > -1)
                    {
                        Pegawai p = new Pegawai()
                        {
                            ID_Pegawai     = result,
                            Jenis_Pegawai  = comboBox1.Text,
                            Nama_Pegawai   = textBox2.Text,
                            Alamat_Pegawai = textBox3.Text,
                            Telp_Pegawai   = System.Convert.ToInt32(textBox5.Text),
                            Kota           = textBox4.Text,
                            Email          = textBox6.Text
                        };
                        PegawaiController pc = new PegawaiController();
                        pc.AddPegawi(p);
                    }
                }
                catch (FormatException fe)
                {
                    MessageBox.Show("Data harus terisi semua ");
                }
            }

            textBox1.Clear();
            textBox2.Clear();
            comboBox1.ResetText();
            textBox3.Clear();
            textBox4.Clear();
            textBox5.Clear();
            textBox6.Clear();
        }
コード例 #9
0
        private void Tambah_Click(object sender, EventArgs e)
        {
            using (HospitalEntities context = new HospitalEntities())
            {
                try
                {
                    int result = (int)(context.GetNewPegawaiId().FirstOrDefault());
                    if (result > -1)
                    {
                        Pegawai p = new Pegawai()
                        {
                            ID_Pegawai = result,
                            Jenis_Pegawai = comboBox1.Text,
                            Nama_Pegawai = textBox2.Text,
                            Alamat_Pegawai = textBox3.Text,
                            Telp_Pegawai = System.Convert.ToInt32(textBox5.Text),
                            Kota = textBox4.Text,
                            Email = textBox6.Text
                        };
                        PegawaiController pc = new PegawaiController();
                        pc.AddPegawi(p);
                    }
                }
                catch (FormatException fe)
                {
                    MessageBox.Show("Data harus terisi semua ");
                }
            }

            textBox1.Clear();
            textBox2.Clear();
            comboBox1.ResetText();
            textBox3.Clear();
            textBox4.Clear();
            textBox5.Clear();
            textBox6.Clear();
        }
コード例 #10
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         Pegawai p = new Pegawai()
         {
             ID_Pegawai = System.Convert.ToInt32(textBox1.Text),
             Jenis_Pegawai = comboBox1.Text,
             Nama_Pegawai = textBox2.Text,
             Alamat_Pegawai = textBox3.Text,
             Telp_Pegawai = System.Convert.ToInt32(textBox5.Text),
             Kota = textBox4.Text,
             Email = textBox6.Text
         };
         PegawaiController pc = new PegawaiController();
         pc.updatePegawai(p);
     }
     catch (FormatException fe)
     {
         MessageBox.Show("Data Harus Terisi semua");
     }
     textBox1.Clear();
     textBox2.Clear();
     comboBox1.ResetText();
     textBox3.Clear();
     textBox4.Clear();
     textBox5.Clear();
     textBox6.Clear();
 }