private void btnEdit_Click(object sender, EventArgs e)
        {
            Employee employees = new Employee();

            using (EncryptionAndDescrption cn = new EncryptionAndDescrption())
            {
                employees.password = cn.Encryption(txtpassword.Text);
            }
            employees.ID   = _id;
            employees.Name = txtname.Text;

            employees.username      = txtusername.Text;
            employees.DateOfBirth   = birthdate.Value;
            employees.HiredDate     = hiredate.Value;
            employees.JobID         = Convert.ToInt32(combojob.SelectedValue);
            employees.DepartmentID  = Convert.ToInt32(combodepartment.SelectedValue);
            employees.Geneder       = comboGender.Text;
            employees.MaritalStatus = comboStatus.Text;
            employees.Salary        = Convert.ToDouble(topdownNumic.Value);
            if (picture != null)
            {
                employees.Picture = picture;
            }
            else
            {
                employees.Picture = orignalImage;
            }

            if (employees.EditEmployees(employees))
            {
                MessageBox.Show("لقد تم التعديل", "رسالة", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (image == null)
         {
             throw new Exception("قم باضافة الصورة");
         }
         using (Employee employee = new Employee())
         {
             employee.Name          = txtname.Text;
             employee.Salary        = Convert.ToDouble(minandMax.Value);
             employee.DepartmentID  = Convert.ToInt32(comboDepartment.SelectedValue);
             employee.HiredDate     = dateHire.Value;
             employee.DateOfBirth   = dateBirth.Value;
             employee.Picture       = image;
             employee.MaritalStatus = comboStatus.Text;
             employee.Geneder       = comboGender.Text;
             employee.JobID         = Convert.ToInt32(comboJobTitle.SelectedValue);
             employee.username      = txtusername.Text;
             using (EncryptionAndDescrption cn = new EncryptionAndDescrption())
             {
                 employee.password = cn.Encryption(txtpassword.Text);
             }
             if (employee.InsertEmployees(employee))
             {
                 MessageBox.Show("لقد تم اضافة الموظفين", "رسالة ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 SelectInformation();
             }
             else
             {
                 MessageBox.Show("يوجد خطاء في ادخال البيانات", "رسالة ", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "رسالة ", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }