private void ts_btn_save_Click(object sender, EventArgs e) { emp = new cls_employee(); string EmpType = ""; string career_name = ""; if (rdb_Emp.Checked) { EmpType += "Emp"; career_name += cb_career_name1.SelectedItem.ToString(); } else if ((rdb_doc.Checked)) { EmpType += "Doc"; career_name += cb_career_name2.SelectedItem.ToString(); } try { if (vaildate_text()) { if (this.Name == "add_emp") { if (emp.insertdata("insert", txt_id.Text, txt_name.Text, txt_address.Text, txt_phone.Text, cb_status.SelectedItem.ToString(), txt_email.Text, cb_sex.SelectedItem.ToString(), dtp_birthDate.Value.ToShortDateString(), cb_religion.SelectedItem.ToString(), txt_birthPlace.Text, cb_nationality.Text, txt_card_id.Text, txt_cardReleasePlace.Text, dtp_card_realease_date.Value.ToShortDateString(), cb_qualification.SelectedItem.ToString(), dtp_qualification_date.Value.ToShortDateString(), nupd__years_of_experience.Value.ToString(), txt_experience.Text, cb_prevoius_jobs.SelectedItem.ToString(), dtp_hiring_date.Value.ToShortDateString(), txt_totalSalary.Text, cb_career_level.SelectedItem.ToString(), career_name, txt_depCode.Text, EmpType, cb_bloodType.SelectedItem.ToString())) { MessageBox.Show("تمت الاضافة بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else if (this.Name == "update_emp") { if (emp.updatedata("update", txt_id.Text, txt_name.Text, txt_address.Text, txt_phone.Text, cb_status.SelectedItem.ToString(), txt_email.Text, cb_sex.SelectedItem.ToString(), dtp_birthDate.Value.ToShortDateString(), cb_religion.SelectedItem.ToString(), txt_birthPlace.Text, cb_nationality.Text, txt_card_id.Text, txt_cardReleasePlace.Text, dtp_card_realease_date.Value.ToShortDateString(), cb_qualification.SelectedItem.ToString(), dtp_qualification_date.Value.ToShortDateString(), nupd__years_of_experience.Value.ToString(), txt_experience.Text, cb_prevoius_jobs.SelectedItem.ToString(), dtp_hiring_date.Value.ToShortDateString(), txt_totalSalary.Text, cb_career_level.SelectedItem.ToString(), career_name, txt_depCode.Text, EmpType, cb_bloodType.SelectedItem.ToString())) { MessageBox.Show("تمت التعديل بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void frm_employee_Load(object sender, EventArgs e) { lblTime.Text = DateTime.Now.ToLongTimeString(); lblDate.Text = DateTime.Now.ToShortDateString(); lb_curent_user.Text = Main_Form.curnt_emp; try { Connection con = new Connection(); if (this.Name == "search") { this.btn_add.Visible = false; this.btn_edit.Visible = false; this.btn_delete.Visible = false; this.btn_ok.Visible = true; emp = new cls_employee(); //dt = emp.select_employee(); dt = con.selectt("select * from employee where [dbo].[employee].[id] not in(select [emp_id]from [dbo].[users]);"); if (dt.Rows.Count == 0) { MessageBox.Show("تم تسجيل جميع الموظفين واختيار اسم مسخدم وكلمة مرور لهم ", "تنبيه ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { emp = new cls_employee(); dt = emp.select_employee(); if (dt.Rows.Count > 0) { emp_code = dt.Rows[dt.Rows.Count - 1][0].ToString(); } else { emp_code = "Emp_100"; } } dv = new DataView(dt); dgv_employee.DataSource = dv; dgv_employee.Columns[0].HeaderText = "كود الموظف"; dgv_employee.Columns[1].HeaderText = "اسم الموظف"; dgv_employee.Columns[2].Visible = false; dgv_employee.Columns[3].HeaderText = "رقم الهاتف"; dgv_employee.Columns[4].HeaderText = "الحالة الاجتماعية"; dgv_employee.Columns[14].HeaderText = "المؤهل"; dgv_employee.Columns[5].Visible = false; dgv_employee.Columns[6].Visible = false; dgv_employee.Columns[7].Visible = false; dgv_employee.Columns[8].Visible = false; dgv_employee.Columns[9].Visible = false; dgv_employee.Columns[10].Visible = false; dgv_employee.Columns[11].Visible = false; dgv_employee.Columns[12].Visible = false; dgv_employee.Columns[13].Visible = false; dgv_employee.Columns[15].Visible = false; dgv_employee.Columns[21].Visible = false; dgv_employee.Columns[22].Visible = false; dgv_employee.Columns[23].Visible = false; dgv_employee.Columns[24].Visible = false; dgv_employee.Columns[25].Visible = false; dgv_employee.Columns[16].Visible = false; dgv_employee.Columns[17].Visible = false; dgv_employee.Columns[18].Visible = false; dgv_employee.Columns[19].Visible = false; dgv_employee.Columns[20].Visible = false; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }