Beispiel #1
0
        //кнопка удалить
        private void button3_Click(object sender, EventArgs e)
        {
            Database1Entities2 db = new Database1Entities2();
            var emp = db.Eployees.Where(c => c.Id == idEmp).FirstOrDefault();

            db.Eployees.Remove(emp);
            db.SaveChanges();
            updateEmp();
        }
Beispiel #2
0
        //кнопка добавить
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("Обновите должность");
                textBox6.Clear();
                return;
            }

            Database1Entities2 db = new Database1Entities2();

            MessageBox.Show("Выберите фото");
            byte[] b = null;
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                Bitmap myBmp = new Bitmap(ofd.FileName);

                Image.GetThumbnailImageAbort myCallBack = new Image.GetThumbnailImageAbort(ThumbnailCallBack);
                Image imgPreview = myBmp.GetThumbnailImage(200, 200, myCallBack, IntPtr.Zero);
                b = imageToByteArray(imgPreview);
            }

            else
            {
                MessageBox.Show("Вы не выбрали новую фотографию");
            }
            Eployees employ = new Eployees
            {
                fname  = textBox1.Text,
                mnane  = textBox2.Text,
                sname  = textBox3.Text,
                bdate  = dateTimePicker1.Value,
                pos_id = p_id[comboBox2.SelectedIndex],
                order1 = textBox4.Text,
                order2 = textBox5.Text,
                foto   = b
            };

            db.Eployees.Add(employ);
            db.SaveChanges();

            updateEmp();
        }
Beispiel #3
0
        //редактировать
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("Обновите должность");
                textBox6.Clear();
                return;
            }

            Database1Entities2 db = new Database1Entities2();
            var employ            = db.Eployees.Where(c => c.Id == idEmp)
                                    .FirstOrDefault();

            employ.Id     = idEmp;
            employ.fname  = textBox1.Text;
            employ.mnane  = textBox2.Text;
            employ.sname  = textBox3.Text;
            employ.bdate  = dateTimePicker1.Value;
            employ.pos_id = p_id[comboBox2.SelectedIndex];
            employ.order1 = textBox4.Text;
            employ.order2 = textBox5.Text;

            MessageBox.Show("Выберите фото");
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                Bitmap myBmp = new Bitmap(ofd.FileName);

                Image.GetThumbnailImageAbort myCallBack = new Image.GetThumbnailImageAbort(ThumbnailCallBack);
                Image imgPreview = myBmp.GetThumbnailImage(200, 200, myCallBack, IntPtr.Zero);
                employ.foto = imageToByteArray(imgPreview);
            }

            else
            {
                MessageBox.Show("Вы не выбрали новую фотографию");
            }
            db.SaveChanges();
            updateEmp();
        }