예제 #1
0
 void FillLists()
 {
     using (DB_A65D4E_SolarEnergyEntities context2 = new DB_A65D4E_SolarEnergyEntities())
     {
         _branches      = context2.Branches.Where(x => x.IsDeleted == 0).ToList();
         _Gender        = context2.Genders.ToList();
         _Jop           = context2.Jobs.Where(x => x.IsDeleted == 0).ToList();
         _Nationality   = context2.Nationalities.Where(x => x.IsDeleted == 0).ToList();
         _Department    = context2.Departments.Where(x => x.IsDeleted == 0).ToList();
         _Employee_View = context2.Employee_View.Where(x => x.IsDeleted == 0).ToList();
     }
 }
예제 #2
0
 private void حذفToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MaterialMessageBox.Show("تاكيد الحذف", MessageBoxButtons.YesNo) == DialogResult.OK)
     {
         Employee_View xx         = gvEmployeeCard.GetFocusedRow() as Employee_View;
         Employee      _Employees = new Employee();
         using (DB_A65D4E_SolarEnergyEntities context2 = new DB_A65D4E_SolarEnergyEntities())
         {
             Employee employee = new Employee();
             _Employees           = context2.Employees.Where(item => item.Employee_Code == xx.Employee_Code && item.IsDeleted == 0).SingleOrDefault();
             _Employees.IsDeleted = 1;
             context2.SaveChanges();
             FillGride();
         }
     }
 }
예제 #3
0
        private void barButtonItem21_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmEmployees frm = new frmEmployees();

            frm._branches      = _branches;
            frm._Department    = _Department;
            frm._Jop           = _Jop;
            frm._branches      = _branches;
            frm._Gender        = _Gender;
            frm._Nationality   = _Nationality;
            frm._Employee_View = _Employee_View;
            try
            {
                if (_Employee_View.Count > 0 && _Employee_View != null)
                {
                    frm.gcEmployeeCard.DataSource = _Employee_View;
                    frm.gcEmployeeCard.RefreshDataSource();
                }
                else
                {
                    frm.gcEmployeeCard.Enabled = false;
                    frm.windowsUIButtonPanel.Buttons.ForEach(x =>
                    {
                        if (x.Properties.Caption == "تعديل" || x.Properties.Caption == "طباعة" || x.Properties.Caption == "حذف")
                        {
                            x.Properties.Enabled = false;
                        }
                        if (x.Properties.Caption == "جديد")
                        {
                            x.Properties.Enabled = true;
                        }
                    });
                }
            }
            catch
            {
            }
            frm.ShowDialog();
            using (DB_A65D4E_SolarEnergyEntities context2 = new DB_A65D4E_SolarEnergyEntities())
            {
                _Employee_View = context2.Employee_View.Where(x => x.IsDeleted == 0).ToList();
            }
        }
예제 #4
0
        void FillGride()
        {
            gcEmployeeCard.DataSource = null;
            try
            {
                using (DB_A65D4E_SolarEnergyEntities Contexts = new DB_A65D4E_SolarEnergyEntities())
                {
                    var empData = (from a in Contexts.Employee_View where a.IsDeleted == 0 select a).OrderBy(x => x.Employee_Code).ToList();


                    if (empData.Count > 0 && empData != null)
                    {
                        gcEmployeeCard.DataSource = empData;
                        gcEmployeeCard.RefreshDataSource();
                    }
                    else
                    {
                        gcEmployeeCard.Enabled = false;
                        windowsUIButtonPanel.Buttons.ForEach(x =>
                        {
                            if (x.Properties.Caption == "تعديل" || x.Properties.Caption == "طباعة" || x.Properties.Caption == "حذف")
                            {
                                x.Properties.Enabled = false;
                            }
                            if (x.Properties.Caption == "جديد")
                            {
                                x.Properties.Enabled = true;
                            }
                        });
                    }
                }
            }
            catch
            {
            }
        }
예제 #5
0
        private void btnAdd_Click_2(object sender, EventArgs e)
        {
            #region Validation
            if (string.IsNullOrWhiteSpace(TxtEmpName.Text))
            {
                MaterialMessageBox.Show("برجاء ادخال اسم الموظف", MessageBoxButtons.OK);
                //TxtEmpName.Properties.ver
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkGender.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار الجنس", MessageBoxButtons.OK);
                TxtEmpName.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(dtBrithDay.Text))
            {
                MaterialMessageBox.Show("برجاءاختيار ناريخ الميلاد", MessageBoxButtons.OK);
                dtBrithDay.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(TxtEmpNataionalId.Text))
            {
                MaterialMessageBox.Show("برجاء ادخال الرقم القومي للموظف", MessageBoxButtons.OK);
                TxtEmpNataionalId.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkNational.Text))
            {
                MaterialMessageBox.Show("برجاءاختيار الجنسية ", MessageBoxButtons.OK);
                slkNational.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkJop.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار الوظيفة", MessageBoxButtons.OK);
                slkJop.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkBranch.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار الفرع", MessageBoxButtons.OK);
                slkBranch.Focus();
                return;
            }

            else if (string.IsNullOrWhiteSpace(dtHiringDate.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار  تاريخ التوظيف", MessageBoxButtons.OK);
                dtHiringDate.Focus();
                return;
            }
            #endregion

            if (Application.OpenForms.OfType <frmEmployees>().Any())
            {
                frmEmployees frm     = (frmEmployees)Application.OpenForms["frmEmployees"];
                Int64        EmpCode = Convert.ToInt64(txtEmpCode.Text);
                using (DB_A65D4E_SolarEnergyEntities ForCheck = new DB_A65D4E_SolarEnergyEntities())
                {
                    bool TestUserName = ForCheck.Employees.Any(Emp => Emp.EmployeeName == TxtEmpName.Text && Emp.Employee_Code != EmpCode && Emp.IsDeleted == 0);
                    if (TestUserName)
                    {
                        MaterialMessageBox.Show("تم تسجيل هذا الاسم لموظف اخر", MessageBoxButtons.OK);
                        return;
                    }
                    bool TestNatId = ForCheck.Employees.Any(Emp => Emp.National_Id == TxtEmpNataionalId.Text && Emp.IsDeleted == 0);
                    if (TestUserName)
                    {
                        MaterialMessageBox.Show("تم تسجيل رقم البطاقة لموظف اخر", MessageBoxButtons.OK);
                        return;
                    }
                }

                Employee _Employee;
                _Employee = context.Employees.Where(Employee => Employee.Employee_Code == EmpCode && Employee.IsDeleted == 0).SingleOrDefault();

                _Employee.EmployeeName       = TxtEmpName.Text;
                _Employee.Natinality_Code    = Convert.ToInt32(slkNational.EditValue);
                _Employee.National_Id        = TxtEmpNataionalId.Text;
                _Employee.Email              = txtEmail.Text;
                _Employee.EmployeeAddress1   = txtAdress1.Text;
                _Employee.EmployeeAddress2   = txtAdress2.Text;
                _Employee.Birthdate          = Convert.ToDateTime(dtBrithDay.EditValue);
                _Employee.HiringDate         = Convert.ToDateTime(dtHiringDate.EditValue);
                _Employee.Phone              = txtMob1.Text;
                _Employee.Phone2             = txtMob2.Text;
                _Employee.Job_Code           = Convert.ToInt64(slkJop.EditValue);
                _Employee.Gender_Id          = Convert.ToInt16(slkGender.EditValue);
                _Employee.Branch_Code        = Convert.ToInt64(slkBranch.EditValue);
                _Employee.LandLine           = txtLandLine.Text;
                _Employee.Last_Modified_Date = DateTime.Now;
                _Employee.Last_Modified_User = st.User_Code();
                context.SaveChanges();
                frmEmployees frmEmpMain = new frmEmployees();
                using (DB_A65D4E_SolarEnergyEntities NewReco = new DB_A65D4E_SolarEnergyEntities())
                {
                    var EmpData = NewReco.Employee_View.Where(x => x.IsDeleted == 0).ToList();

                    frmEmpMain.gcEmployeeCard.DataSource = EmpData;
                    frmEmpMain.gcEmployeeCard.RefreshDataSource();
                    Employee_View result2 = EmpData.Where(x => x.Employee_Code == EmpCode && x.IsDeleted == 0).FirstOrDefault();
                    frm.gvEmployeeCard.SetFocusedRowCellValue("EmployeeName", result2.EmployeeName);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("Gender_Name", result2.Gender_Name);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("National_Id", result2.National_Id);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("Email", result2.Email);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("Phone", result2.Phone);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("Phone", result2.Phone2);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("JobName", result2.JobName);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("HiringDate", result2.HiringDate);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("LandLine", result2.LandLine);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("EmployeeAddress1", result2.EmployeeAddress1);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("EmployeeAddress2", result2.EmployeeAddress2);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("Birthdate", result2.Birthdate);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("National_Name", result2.National_Name);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("BranchName", result2.BranchName);
                    frm.gvEmployeeCard.SetFocusedRowCellValue("DepartmentName", result2.DepartmentName);
                    frm.gvEmployeeCard.RefreshData();
                    HelperClass.HelperClass.ClearValues(tableLayoutPanel2);
                }

                this.Close();
            }
        }
예제 #6
0
        private void windowsUIButtonPanel_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            WindowsUIButton btn = e.Button as WindowsUIButton;

            if (btn.Caption == "جديد")
            {
                FrmAddEmployees frm = new FrmAddEmployees();
                try
                {
                    var result = _Jop.Where(Job => Job.IsDeleted == 0).ToList();
                    if (result.Count > 0 && result != null)
                    {
                        frm.slkJop.Properties.DataSource    = result;
                        frm.slkJop.Properties.ValueMember   = "Jop_Code";
                        frm.slkJop.Properties.DisplayMember = "JobName";
                        frm.slkJop.EditValue = result[0].Jop_Code;
                    }
                }
                catch
                {
                }



                try
                {
                    var result = _branches.Where(Branche => Branche.IsDeleted == 0).ToList();
                    if (result.Count > 0 && result != null)
                    {
                        frm.slkBranch.Properties.DataSource    = result;
                        frm.slkBranch.Properties.ValueMember   = "Branch_Code";
                        frm.slkBranch.Properties.DisplayMember = "BranchName";
                        frm.slkBranch.EditValue = result[0].Branch_Code;
                    }
                }
                catch
                {
                }



                try
                {
                    var result = _Gender.ToList();

                    if (result.Count > 0 && result != null)
                    {
                        frm.slkGender.Properties.DataSource    = result;
                        frm.slkGender.Properties.ValueMember   = "Gender_Id";
                        frm.slkGender.Properties.DisplayMember = "Gender_Name";
                        frm.slkGender.EditValue = result[0].Gender_Id;
                    }
                }
                catch
                {
                }



                try
                {
                    var result = _Nationality.Where(Nationalitie => Nationalitie.IsDeleted == 0).ToList();
                    if (result.Count > 0 && result != null)
                    {
                        frm.slkNational.Properties.DataSource    = result;
                        frm.slkNational.Properties.ValueMember   = "National_Code";
                        frm.slkNational.Properties.DisplayMember = "National_Name";
                        frm.slkNational.EditValue = result[0].Id;
                    }
                }
                catch
                {
                }



                Int64?MaxCode = 1;
                if (_Employee_View != null && _Employee_View.Count > 0)
                {
                    MaxCode = _Employee_View.Where(xx => xx.IsDeleted == 0).Max(u => (Int64?)u.Employee_Code + 1);
                }
                frm.txtEmpCode.Text = MaxCode.ToString();

                frm._Employee_View = _Employee_View;
                frm.ShowDialog();
            }
            else if (btn.Caption == "تعديل")
            {
                if (gvEmployeeCard.RowCount <= 0)
                {
                    return;
                }

                frmEditeEmployees frm = new frmEditeEmployees();
                var x = gvEmployeeCard.GetFocusedRow() as Employee_View;
                using (DB_A65D4E_SolarEnergyEntities context4 = new DB_A65D4E_SolarEnergyEntities())
                {
                    var emp = context.Employee_View.Where(xx => xx.IsDeleted == 0 && xx.Employee_Code == x.Employee_Code).SingleOrDefault();

                    frm.txtEmpCode.Text        = emp.Employee_Code.ToString();
                    frm.TxtEmpName.Text        = emp.EmployeeName.ToString();
                    frm.dtBrithDay.EditValue   = emp.Birthdate;
                    frm.TxtEmpNataionalId.Text = emp.National_Id.ToString();
                    frm.txtAdress1.Text        = emp.EmployeeAddress1.ToString();
                    frm.txtAdress2.Text        = emp.EmployeeAddress2.ToString();
                    frm.txtMob1.Text           = emp.Phone.ToString();
                    frm.txtMob2.Text           = emp.Phone2.ToString();
                    frm.txtLandLine.Text       = emp.LandLine.ToString();
                    frm.txtEmail.Text          = emp.Email.ToString();
                    frm.dtHiringDate.EditValue = emp.HiringDate;
                    try
                    {
                        var result = _Jop.Where(Job => Job.IsDeleted == 0).ToList();
                        if (result.Count > 0 && result != null)
                        {
                            frm.slkJop.Properties.DataSource    = result;
                            frm.slkJop.Properties.ValueMember   = "Jop_Code";
                            frm.slkJop.Properties.DisplayMember = "JobName";
                            frm.slkJop.EditValue = emp.Job_Code;
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        var result = _branches.Where(Branche => Branche.IsDeleted == 0).ToList();
                        if (result.Count > 0 && result != null)
                        {
                            frm.slkBranch.Properties.DataSource    = result;
                            frm.slkBranch.Properties.ValueMember   = "Branch_Code";
                            frm.slkBranch.Properties.DisplayMember = "BranchName";
                            frm.slkBranch.EditValue = emp.Branch_Code;
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        var result = _Gender.ToList();

                        if (result.Count > 0 && result != null)
                        {
                            frm.slkGender.Properties.DataSource    = result;
                            frm.slkGender.Properties.ValueMember   = "Gender_Id";
                            frm.slkGender.Properties.DisplayMember = "Gender_Name";
                            frm.slkGender.EditValue = emp.Gender_Id;
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        var result = _Nationality.Where(Nationalitie => Nationalitie.IsDeleted == 0).ToList();
                        if (result.Count > 0 && result != null)
                        {
                            frm.slkNational.Properties.DataSource    = result;
                            frm.slkNational.Properties.ValueMember   = "National_Code";
                            frm.slkNational.Properties.DisplayMember = "National_Name";
                            frm.slkNational.EditValue = emp.Natinality_Code;
                        }
                    }
                    catch
                    {
                    }
                }
                frm.ShowDialog();
            }
            else if (btn.Caption == "خروج")
            {
                this.Close();
            }
            else if (btn.Caption == "حذف")
            {
                if (gvEmployeeCard.RowCount <= 0)
                {
                    return;
                }
                if (MaterialMessageBox.Show("تاكيد الحذف", MessageBoxButtons.YesNo) == DialogResult.OK)
                {
                    Employee_View xx         = gvEmployeeCard.GetFocusedRow() as Employee_View;
                    Employee      _Employees = new Employee();
                    using (DB_A65D4E_SolarEnergyEntities context2 = new DB_A65D4E_SolarEnergyEntities())
                    {
                        Employee employee = new Employee();
                        _Employees = context2.Employees.SingleOrDefault(item => item.Employee_Code == xx.Employee_Code && item.IsDeleted == 0);

                        _Employees.IsDeleted = 1;
                        context2.SaveChanges();
                    }
                }
                FillGride();
            }
            else if (btn.Caption == "تحديث")
            {
                using (DB_A65D4E_SolarEnergyEntities refershContext = new DB_A65D4E_SolarEnergyEntities())
                {
                    _branches = refershContext.Branches.Where(x => x.IsDeleted == 0).ToList();

                    _Jop         = refershContext.Jobs.Where(x => x.IsDeleted == 0).ToList();
                    _Nationality = refershContext.Nationalities.Where(x => x.IsDeleted == 0).ToList();

                    _Employee_View = refershContext.Employee_View.Where(x => x.IsDeleted == 0).ToList();

                    if (_Employee_View.Count > 0 && _Employee_View != null)
                    {
                        gcEmployeeCard.DataSource = null;
                        gcEmployeeCard.DataSource = _Employee_View;
                        gcEmployeeCard.RefreshDataSource();
                    }
                    else
                    {
                        gcEmployeeCard.Enabled = false;
                        windowsUIButtonPanel.Buttons.ForEach(x =>
                        {
                            if (x.Properties.Caption == "تعديل" || x.Properties.Caption == "طباعة" || x.Properties.Caption == "حذف")
                            {
                                x.Properties.Enabled = false;
                            }
                            if (x.Properties.Caption == "جديد")
                            {
                                x.Properties.Enabled = true;
                            }
                        });
                    }
                }
            }
            //else if (btn.Caption == "طباعة")
            //{
            //}
        }
예제 #7
0
        private void تعديلToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (gvEmployeeCard.RowCount <= 0)
            {
                return;
            }

            frmEditeEmployees frm = new frmEditeEmployees();
            var x = gvEmployeeCard.GetFocusedRow() as Employee_View;

            using (DB_A65D4E_SolarEnergyEntities context4 = new DB_A65D4E_SolarEnergyEntities())
            {
                var emp = context.Employee_View.Where(xx => xx.IsDeleted == 0 && xx.Employee_Code == x.Employee_Code).SingleOrDefault();

                frm.txtEmpCode.Text        = emp.Employee_Code.ToString();
                frm.TxtEmpName.Text        = emp.EmployeeName.ToString();
                frm.dtBrithDay.EditValue   = emp.Birthdate;
                frm.TxtEmpNataionalId.Text = emp.National_Id.ToString();
                frm.txtAdress1.Text        = emp.EmployeeAddress1.ToString();
                frm.txtAdress2.Text        = emp.EmployeeAddress2.ToString();
                frm.txtMob1.Text           = emp.Phone.ToString();
                frm.txtMob2.Text           = emp.Phone2.ToString();
                frm.txtLandLine.Text       = emp.LandLine.ToString();
                frm.txtEmail.Text          = emp.Email.ToString();
                frm.dtHiringDate.EditValue = emp.HiringDate;
                try
                {
                    var result = _Jop.Where(Job => Job.IsDeleted == 0).ToList();
                    if (result.Count > 0 && result != null)
                    {
                        frm.slkJop.Properties.DataSource    = result;
                        frm.slkJop.Properties.ValueMember   = "Jop_Code";
                        frm.slkJop.Properties.DisplayMember = "JobName";
                        frm.slkJop.EditValue = emp.Job_Code;
                    }
                }
                catch
                {
                }
                try
                {
                    var result = _branches.Where(Branche => Branche.IsDeleted == 0).ToList();
                    if (result.Count > 0 && result != null)
                    {
                        frm.slkBranch.Properties.DataSource    = result;
                        frm.slkBranch.Properties.ValueMember   = "Branch_Code";
                        frm.slkBranch.Properties.DisplayMember = "BranchName";
                        frm.slkBranch.EditValue = emp.Branch_Code;
                    }
                }
                catch
                {
                }
                try
                {
                    var result = _Gender.ToList();

                    if (result.Count > 0 && result != null)
                    {
                        frm.slkGender.Properties.DataSource    = result;
                        frm.slkGender.Properties.ValueMember   = "Gender_Id";
                        frm.slkGender.Properties.DisplayMember = "Gender_Name";
                        frm.slkGender.EditValue = emp.Gender_Id;
                    }
                }
                catch
                {
                }
                try
                {
                    var result = _Nationality.Where(Nationalitie => Nationalitie.IsDeleted == 0).ToList();
                    if (result.Count > 0 && result != null)
                    {
                        frm.slkNational.Properties.DataSource    = result;
                        frm.slkNational.Properties.ValueMember   = "National_Code";
                        frm.slkNational.Properties.DisplayMember = "National_Name";
                        frm.slkNational.EditValue = emp.Natinality_Code;
                    }
                }
                catch
                {
                }
            }
            frm.ShowDialog();
        }
예제 #8
0
        public void Save()
        {
            #region Validation
            if (string.IsNullOrWhiteSpace(TxtEmpName.Text))
            {
                MaterialMessageBox.Show("برجاء ادخال اسم الموظف", MessageBoxButtons.OK);
                //TxtEmpName.Properties.ver
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkGender.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار الجنس", MessageBoxButtons.OK);
                TxtEmpName.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(dtBrithDay.Text))
            {
                MaterialMessageBox.Show("برجاءاختيار ناريخ الميلاد", MessageBoxButtons.OK);
                dtBrithDay.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(TxtEmpNataionalId.Text))
            {
                MaterialMessageBox.Show("برجاء ادخال الرقم القومي للموظف", MessageBoxButtons.OK);
                TxtEmpNataionalId.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkNational.Text))
            {
                MaterialMessageBox.Show("برجاءاختيار الجنسية ", MessageBoxButtons.OK);
                slkNational.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkJop.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار الوظيفة", MessageBoxButtons.OK);
                slkJop.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(slkBranch.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار الفرع", MessageBoxButtons.OK);
                slkBranch.Focus();
                return;
            }

            else if (string.IsNullOrWhiteSpace(dtHiringDate.Text))
            {
                MaterialMessageBox.Show("برجاء اختيار  تاريخ التوظيف", MessageBoxButtons.OK);
                dtHiringDate.Focus();
                return;
            }
            #endregion
            if (Application.OpenForms.OfType <frmEmployees>().Any())
            {
                Int64 EmpCode = Convert.ToInt64(txtEmpCode.Text);

                bool         TestUpdate = context.Employees.Any(customer => customer.Employee_Code == EmpCode && customer.IsDeleted == 0);
                frmEmployees frm        = (frmEmployees)Application.OpenForms["frmEmployees"];
                if (TestUpdate)
                {
                    using (DB_A65D4E_SolarEnergyEntities ForCheck = new DB_A65D4E_SolarEnergyEntities())
                    {
                        bool TestUserName = ForCheck.Employees.Any(Emp => Emp.EmployeeName == TxtEmpName.Text && Emp.Employee_Code != EmpCode && Emp.IsDeleted == 0);
                        if (TestUserName)
                        {
                            MaterialMessageBox.Show("تم تسجيل هذا الاسم لموظف اخر", MessageBoxButtons.OK);
                            return;
                        }
                        bool TestNatId = ForCheck.Employees.Any(Emp => Emp.National_Id == TxtEmpNataionalId.Text && Emp.IsDeleted == 0);
                        if (TestUserName)
                        {
                            MaterialMessageBox.Show("تم تسجيل رقم البطاقة لموظف اخر", MessageBoxButtons.OK);
                            return;
                        }
                    }
                }
                else
                {
                    using (DB_A65D4E_SolarEnergyEntities ForCheck = new DB_A65D4E_SolarEnergyEntities())
                    {
                        List <Employee> _EmpList    = ForCheck.Employees.Where(x => x.IsDeleted == 0).ToList();
                        bool            TestEmpCode = _EmpList.Any(Emp => Emp.Employee_Code == EmpCode && Emp.IsDeleted == 0);
                        if (TestEmpCode)
                        {
                            MaterialMessageBox.Show("! تم تسجيل هذا كود الموظف لموظف اخر برجاء تحديث البيانات", MessageBoxButtons.OK);
                            return;
                        }
                        bool TestEmprName = _EmpList.Any(Emp => Emp.EmployeeName == TxtEmpName.Text && Emp.IsDeleted == 0);
                        if (TestEmprName)
                        {
                            MaterialMessageBox.Show("تم تسجيل هذا الاسم لموظف اخر", MessageBoxButtons.OK);
                            return;
                        }
                        bool TestEmpNatId = _EmpList.Any(Emp => Emp.National_Id == TxtEmpNataionalId.Text && Emp.IsDeleted == 0);
                        if (TestEmpNatId)
                        {
                            MaterialMessageBox.Show("تم تسجيل رقم البطاقة لموظف اخر", MessageBoxButtons.OK);
                            return;
                        }
                    };

                    Employee _Employee = new Employee()
                    {
                        Employee_Code      = EmpCode,
                        EmployeeName       = TxtEmpName.Text,
                        Phone              = txtMob1.Text,
                        Phone2             = txtMob2.Text,
                        EmployeeAddress1   = txtAdress1.Text,
                        EmployeeAddress2   = txtAdress2.Text,
                        National_Id        = TxtEmpNataionalId.Text,
                        Email              = txtEmail.Text,
                        Birthdate          = Convert.ToDateTime(dtBrithDay.EditValue),
                        HiringDate         = Convert.ToDateTime(dtHiringDate.EditValue),
                        LandLine           = LandLine.Text,
                        Last_Modified_Date = DateTime.Now,
                        Last_Modified_User = 1,
                        Branch_Code        = Convert.ToInt64(slkBranch.EditValue),
                        //Department_Code = Convert.ToInt64(slkDepartment.EditValue),
                        Gender_Id       = Convert.ToInt32(slkGender.EditValue),
                        Job_Code        = Convert.ToInt32(slkJop.EditValue),
                        Natinality_Code = Convert.ToInt32(slkNational.EditValue),
                        Created_Date    = DateTime.Now,
                        Created_User    = 1,
                    };
                    context.Employees.Add(_Employee);
                    context.SaveChanges();
                    Rest();
                    using (DB_A65D4E_SolarEnergyEntities NewContext = new DB_A65D4E_SolarEnergyEntities())
                    {
                        _Employee_View = null;
                        _Employee_View = NewContext.Employee_View.Where(x => x.IsDeleted == 0).ToList();

                        frm.gcEmployeeCard.DataSource = _Employee_View;
                        frm.gcEmployeeCard.RefreshDataSource();
                        frm.gcEmployeeCard.Enabled = true;
                        GetLastEmployeeCode();
                    }
                }
            }
        }