コード例 #1
0
        private void dgSearchEmpPayroll_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                string str = dgSearchEmpPayroll.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

                Admin Bind = new Admin();
                ArrayList data_payroll = Bind.BindPayrollDetails(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 + 8)
                    {
                        string EmpNIP = (string)data_payroll[i];
                        string PayrollBase = (string)data_payroll[i + 1];
                        string PayrollPositionAllowanceTotal = (string)data_payroll[i + 2];
                        string PayrollTransportationAllowanceTotal = (string)data_payroll[i + 3];
                        string PayrollHouseAllowanceTotal = (string)data_payroll[i + 4];
                        string PayrollAnotherAllowanceTotal = (string)data_payroll[i + 5];
                        string PayrollReductionTotal = (string)data_payroll[i + 6];
                        string PayrollTotal = (string)data_payroll[i + 7];

                        tbSearchPayrollEmpNIP.Text = EmpNIP;
                        tbSearchPayrollBase.Text = PayrollBase;
                        tbSearchPayrollPosition.Text = PayrollPositionAllowanceTotal;
                        tbSearchPayrollTransportation.Text = PayrollTransportationAllowanceTotal;
                        tbSearchPayrollHouse.Text = PayrollHouseAllowanceTotal;
                        tbSearchPayrollAnother.Text = PayrollAnotherAllowanceTotal;
                        tbSearchPayrollReduction.Text = PayrollReductionTotal;
                        tbSearchTotalPayroll.Text = PayrollReductionTotal;
                    }
                }
            }
            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);
            }
        }