예제 #1
0
파일: empWin.cs 프로젝트: esinai/myStore
        private void Button1_Click(object sender, EventArgs e)
        {
            empTBL e1 = new empTBL();

            checkName(textBox1.Text, textBox1);

            checkName(textBox2.Text, textBox2);
            checkEmail(textBox4.Text, textBox4);


            if (!checkName(textBox1.Text, textBox1) ||
                !checkName(textBox2.Text, textBox2) ||
                !checkEmail(textBox4.Text, textBox4))
            {
                return;
            }

            e1.firstName = textBox1.Text;
            e1.lastName  = textBox2.Text;
            e1.bDate     = DTPBdateAddEmp.Value;
            e1.startDate = dateTimePicker2.Value;
            e1.address   = textBox3.Text;
            e1.phone     = maskedTextBox1.Text;
            e1.email     = textBox4.Text;
            e1.gender    = (comboBox2.SelectedIndex == 0);
            e1.isActive  = true;

            roleTBL r1 = (roleTBL)roleCBX.SelectedItem;

            e1.roleID = r1.Id;
            if (myImg != null)
            {
                e1.img = myImg1;
            }
            else
            {
                e1.img = null;
            }

            db.empTBL.Add(e1);
            db.SaveChanges();

            List <empTBL> lst4 = (from s in db.empTBL where s.Id > 3 orderby s.lastName select s).ToList();

            MessageBox.Show("העובד התווסף בהצלחה");

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            updateList();
        }
예제 #2
0
파일: empWin.cs 프로젝트: esinai/myStore
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            empTBL e1 = (empTBL)comboBox1.SelectedItem;

            textBox8.Text         = e1.firstName;
            textBox7.Text         = e1.lastName;
            dateTimePicker4.Value = e1.bDate;
            checkBox1.Checked     = e1.isActive;
            if (e1.img != null)
            {
                pictureBox2.Image = byteArrayToImage(e1.img);
            }
            else
            {
                pictureBox2.Image = null;
            }
            roleTBL r1 = (from s in db.roleTBL where s.Id == e1.roleID select s).FirstOrDefault();

            roleEditCBX.SelectedItem = r1;

            if (e1.gender)
            {
                comboBox3.SelectedIndex = 0;
            }
            else
            {
                comboBox3.SelectedIndex = 1;
            }
            textBox6.Text       = e1.address;
            maskedTextBox2.Text = e1.phone;
            textBox5.Text       = e1.email;
            if (!e1.isActive)
            {
                if (e1.endDate.HasValue)
                {
                    dateTimePicker5.Value = e1.endDate.Value;
                    textBox9.Text         = e1.leaveR;
                }
            }
        }