private void frm_employee_Load(object sender, EventArgs e) { emp = new cls_employee(); dt = new DataTable(); //================================================================ //لما اخلى الفورمة للبحث فقط if (this.Name == "search") { Connection con = new Connection(); dt = con.selectt("select * from staff where staff_id not in (select emp_id from user);"); dv = new DataView(dt); } else { dt = emp.selct_employee(); dv = new DataView(dt); } //================================================================= if (dt.Rows.Count > 0) { emp_id = dt.Rows[dt.Rows.Count - 1][0].ToString(); } else { emp_id = "E_100"; } try { dgv_employee.DataSource = dv; dgv_employee.Columns[0].HeaderText = "الكود"; dgv_employee.Columns[1].HeaderText = "الاسم"; dgv_employee.Columns[2].HeaderText = "النوع"; dgv_employee.Columns[8].HeaderText = "الهاتف"; // dgv_employee.Columns[].HeaderText = "نوع الوظيفة"; dgv_employee.Columns[3].Visible = false; dgv_employee.Columns[4].Visible = false; dgv_employee.Columns[5].Visible = false; dgv_employee.Columns[6].Visible = false; dgv_employee.Columns[7].Visible = false; dgv_employee.Columns[9].Visible = false; dgv_employee.Columns[10].Visible = false; dgv_employee.Columns[11].Visible = false; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void ts_btn_save_Click(object sender, EventArgs e) { try { if (vaildate_text()) { id = txt_id.Text; name = txt_name.Text; birth_date = dtp_birth_date.Value.ToString("yyyy-MM-dd"); reg_date = dtb_reg_date.Value.ToString("yyyy-MM-dd"); address = txt_address.Text; phone1 = txt_phone1.Text; email = txt_email.Text; cls_employee p = new cls_employee(); Connection con = new Connection(); if (this.Name == "add_employee") { if (con.ExecuteQueries(@"insert into staff values ('" + id + "','" + name + "','" + gender + "','" + birth_date + "','" + reg_date + "','" + status + "','" + address + "','" + email + "','" + phone1 + "','" + position + "','" + txt_nat_id.Text + "')")) { MessageBox.Show("تمت الاضافة بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else if (this.Name == "update_employee") { if (con.ExecuteQueries(@"update staff set staff_name='" + name + "',staff_gender='" + gender + "',staff_birth_date='" + birth_date + "',staff_date_of_employee='" + reg_date + "',staff_status='" + status + "',staff_address='" + address + "',staff_email='" + email + "',staff_contact_no = '" + phone1 + "',staff_position='" + position + "',staff_nat_id='" + txt_nat_id.Text + "' where staff_id = '" + id + "'")) { MessageBox.Show("تمت التعديل بنجاح ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }