Exemplo n.º 1
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            if (tbxTC.Text == "" || tbxName.Text == "" || tbxSurname.Text == "" ||
                txtAdress.Text == "" || tbxNetMaas.Text == "" || dtIseGirme.Value.ToString() == "" ||
                dtDogumTarihi.Value.ToString() == "" || !picture)
            {
                MessageBox.Show("Gerekli alanları doldurun!");
            }
            else
            {
                long tc        = long.Parse(tbxTC.Text);
                var  _employee = ctx.Employee.Where(p => p.TC == tc).FirstOrDefault();
                if (_employee != null)
                {
                    MessageBox.Show("Aynı Tc noya sahip personel mevcuttur!");
                }
                else
                {
                    string newFilePath = "resimler/" + tc.ToString();
                    if (filePath.EndsWith(".jpg") || filePath.EndsWith(".jpeg"))
                    {
                        newFilePath += ".jpg";
                        pictureBox1.Image.Save(newFilePath, ImageFormat.Jpeg);
                    }
                    else if (filePath.EndsWith(".png"))
                    {
                        newFilePath += ".png";
                        pictureBox1.Image.Save(newFilePath, ImageFormat.Png);
                    }


                    Employee _employeee = new Employee();
                    _employeee.Name    = tbxName.Text.ToString();
                    _employeee.Surname = tbxSurname.Text.ToString();
                    _employeee.TC      = tc;
                    _employeee.BDate   = (DateTime)dtDogumTarihi.Value;
                    _employeee.WDate   = dtIseGirme.Value;
                    _employeee.NetMaas = tbxNetMaas.Text.ToString();
                    _employeee.Address = txtAdress.Text.ToString();
                    _employeee.FYolu   = newFilePath;

                    _employeee.KanGrubu         = cbxKanGrubu.SelectedItem.ToString();
                    ctx.Entry(_employeee).State = EntityState.Added;
                    ctx.SaveChanges();

                    if (filePath.EndsWith(".jpg") || filePath.EndsWith(".jpeg"))
                    {
                        pictureBox1.Image.Save("resimler/" + tc.ToString() + ".jpg", ImageFormat.Jpeg);
                    }
                    else if (filePath.EndsWith(".png"))
                    {
                        pictureBox1.Image.Save("resimler/" + tc.ToString() + ".png", ImageFormat.Png);
                    }


                    MessageBox.Show("Kayıt Başarı ile Eklendi");
                }
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string userName = userNameTb.Text;
            string password = passwordTb.Text;

            if (userName.Equals("") || password.Equals(""))
            {
                MessageBox.Show("Kullanıcı adı veya şifre boş. Lütfen doldurunuz.");
                return;
            }

            LoginUser user = ctx.LoginUserSet.Where(l => l.UserName.Equals(userName)).FirstOrDefault();

            if (user != null)
            {
                MessageBox.Show("Aynı kullanıcı adı zaten mevcut. Liütfen kullanıcı adını değiştiriniz");
            }
            else
            {
                LoginUser newUser = new LoginUser {
                    UserName = userName, Password = password, IsAdmin = false
                };
                ctx.Entry(newUser).State = EntityState.Added;
                ctx.SaveChanges();

                MessageBox.Show("Kullanıcı başarı ile eklendi");
            }
        }
Exemplo n.º 3
0
        private void silBtn_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["EmployeeID"].Value);

            DialogResult result = MessageBox.Show(id + " id li personel kalıcı olarak silinecektir! Devam Edilsin mi?", "Uyarı!", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                Employee silinecek = ctx.Employee.Where(p => p.EmployeeID == id).FirstOrDefault();
                ctx.Employee.Attach(silinecek);
                ctx.Employee.Remove(silinecek);
                ctx.SaveChanges();
                fillEmployeList();
            }
        }