private void editBtnEmp_Click_1(object sender, EventArgs e) { // edit if (DGV_EmployeeHome.SelectedRows.Count == 0) { MessageBoxIcon.Warning.ToString(); MessageBox.Show("يجب ان تختار موظف من الموظفين"); } else { if (Txt_Ee.Visible == false) { Txt_Ee.Show(); } if (Btn_SaveEmp.Visible == true) { Btn_SaveEmp.Hide(); } UpdateBtnEmployee.Show(); Btn_SaveEmp.Hide(); p_id = int.Parse(DGV_EmployeeHome.SelectedRows[0].Cells[4].Value.ToString()); var query = store.employee.FirstOrDefault(p => p.ID == p_id); EmployeeNamrTxt.Text = query.EmployeeName; EmployeeAddressTxt.Text = query.Address; EmployeePhoneTxt.Text = query.Phone; EmployeeSalaryTxt.Text = query.Salary.ToString(); EmployeeNationalIDTxt.Text = query.NationalId; } }
private void BtnAddEmp_Click_1(object sender, EventArgs e) { // add if (Txt_Ee.Visible == false) { Txt_Ee.Show(); } if (Btn_SaveEmp.Visible == false) { Btn_SaveEmp.Show(); } UpdateBtnEmployee.Hide(); EmployeeAddressTxt.Text = ""; EmployeeNamrTxt.Text = ""; EmployeeSalaryTxt.Text = ""; EmployeeNationalIDTxt.Text = ""; EmployeePhoneTxt.Text = ""; }
private void Btn_SaveEmp_Click_1(object sender, EventArgs e) { // save if (Btn_SaveEmp.Visible == false) { Btn_SaveEmp.Show(); } UpdateBtnEmployee.Hide(); var nameFilter = store.employee.FirstOrDefault(p => p.EmployeeName == EmployeeNamrTxt.Text); if (nameFilter == null) { Employee employee = new Employee(); employee.Address = EmployeeAddressTxt.Text; employee.NationalId = EmployeeNationalIDTxt.Text; employee.EmployeeName = EmployeeNamrTxt.Text; employee.HireDate = Txt_EmployeeHireDate.Value; employee.Phone = EmployeePhoneTxt.Text; employee.Salary = float.Parse(EmployeeSalaryTxt.Text); store.employee.Add(employee); store.SaveChanges(); bindGridView(); EmployeeAddressTxt.Text = ""; EmployeeNamrTxt.Text = ""; EmployeeSalaryTxt.Text = ""; EmployeeNationalIDTxt.Text = ""; EmployeePhoneTxt.Text = ""; } else { MessageBox.Show("هذا الموظف موجود بالفعل"); EmployeeNamrTxt.Text = null; // AllPro allPro = new AllPro(); } }