private void dgSearchEmp_CellClick(object sender, DataGridViewCellEventArgs e) { try { string str = dgSearchEmp.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); Admin Bind = new Admin(); ArrayList data_emp = Bind.BindEmpDetails(str); if (data_emp.Count == 0) { MessageBox.Show("NO DATA MATCH WITH DATABASE RECORDS", "NO DATA FOUND", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { for (int i = 0; i < data_emp.Count; i = i + 8) { string EmpNIP = (string)data_emp[i]; string EmpName = (string)data_emp[i + 1]; string EmpGender = (string)data_emp[i + 2]; string EmpDOB = (string)data_emp[i + 3]; string EmpEmail = (string)data_emp[i + 4]; string EmpPhone = (string)data_emp[i + 5]; string DivID = (string)data_emp[i + 6]; string PosID = (string)data_emp[i + 7]; tbSearchEmpNIP.Text = EmpNIP; tbSearchEmpName.Text = EmpName; tbSearchEmpGender.Text = EmpGender; tbSearchEmpDOB.Text = EmpDOB; tbSearchEmpEmail.Text = EmpEmail; tbSearchEmpPhone.Text = EmpPhone; Admin BindSingleDiv = new Admin(); ArrayList data_singleDiv = BindSingleDiv.BindCBDivisionForEditAndSearchEmployeeForm(DivID); for (int iD = 0; iD < data_singleDiv.Count; iD = iD + 2) { string CompletedDivID = (string)data_singleDiv[iD]; string CompletedDivName = (string)data_singleDiv[iD + 1]; tbSearchEmpDivision.Text = CompletedDivID + ". " + CompletedDivName; } Admin BindSinglePos = new Admin(); ArrayList data_singlePos = BindSingleDiv.BindCBPositionForEditAndSearchEmployeeForm(PosID); for (int iP = 0; iP < data_singlePos.Count; iP = iP + 2) { string CompletedPosID = (string)data_singlePos[iP]; string CompletedPosName = (string)data_singlePos[iP + 1]; tbSearchEmpPosition.Text = CompletedPosID + ". " + CompletedPosName; } } } } catch (SqlException) { MessageBox.Show("MICROSOFT SQL SERVER DATABASE ERROR!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (InvalidOperationException) { MessageBox.Show("INVALID OPERATION!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void BindDetails() { try { string str = lblUser.Text; Admin Bind = new Admin(); ArrayList data_emp = Bind.UserBindEmpDetails(str); if (data_emp.Count == 0) { MessageBox.Show("NO DATA MATCH WITH DATABASE RECORDS", "NO DATA FOUND", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { for (int i = 0; i < data_emp.Count; i = i + 9) { string EmpNIP = (string)data_emp[i]; string EmpName = (string)data_emp[i + 1]; string EmpGender = (string)data_emp[i + 2]; string EmpDOB = (string)data_emp[i + 3]; string EmpEmail = (string)data_emp[i + 4]; string EmpPhone = (string)data_emp[i + 5]; string EmpPhoto = (string)data_emp[i + 6]; string DivID = (string)data_emp[i + 7]; string PosID = (string)data_emp[i + 8]; lblEmpNIP.Text = EmpNIP; lblEmpName.Text = EmpName; lblEmpGender.Text = EmpGender; lblEmpDOB.Text = EmpDOB; lblEmpEmail.Text = EmpEmail; lblEmpPhone.Text = EmpPhone; pbEmpPhoto.Image = Image.FromFile(@"D:\Important\Clients\PT Bahtera Adhiguna\Misc\Employee Photo\"+EmpPhoto+""); pbEmpPhoto.SizeMode = PictureBoxSizeMode.StretchImage; pbEmpPhoto.BorderStyle = BorderStyle.Fixed3D; Admin BindSingleDiv = new Admin(); ArrayList data_singleDiv = BindSingleDiv.BindCBDivisionForEditAndSearchEmployeeForm(DivID); for (int iD = 0; iD < data_singleDiv.Count; iD = iD + 2) { string CompletedDivID = (string)data_singleDiv[iD]; string CompletedDivName = (string)data_singleDiv[iD + 1]; lblEmpDivision.Text = CompletedDivID + ". " + CompletedDivName; } Admin BindSinglePos = new Admin(); ArrayList data_singlePos = BindSingleDiv.BindCBPositionForEditAndSearchEmployeeForm(PosID); for (int iP = 0; iP < data_singlePos.Count; iP = iP + 2) { string CompletedPosID = (string)data_singlePos[iP]; string CompletedPosName = (string)data_singlePos[iP + 1]; lblEmpPosition.Text = CompletedPosID + ". " + CompletedPosName; } } } } catch (SqlException) { MessageBox.Show("MICROSOFT SQL SERVER DATABASE ERROR!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (InvalidOperationException) { MessageBox.Show("INVALID OPERATION!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }