Exemplo n.º 1
0
        private void dgAddPayroll_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                string str = dgAddPayroll.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

                Admin Bind = new Admin();
                ArrayList data_payroll = Bind.BindAddPayrollDetails(str);

                if (data_payroll.Count == 0)
                {
                    MessageBox.Show("NO DATA MATCH WITH DATABASE RECORDS", "NO DATA FOUND", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    for (int i = 0; i < data_payroll.Count; i = i + 2)
                    {
                        string EmpNIP = (string)data_payroll[i];
                        string PayrollBase = (string)data_payroll[i + 1];

                        tbSaveEmpNIP.Text = EmpNIP;
                        tbSaveEmpPayrollBase.Text = PayrollBase;
                    }
                }
            }
            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);
            }
        }