Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();

                SqlCommand cmd = new SqlCommand("select workedDate as 'Worked Date', inTime as 'In Time', outTime as 'Out Time', workedHours as 'Worked Hours', bSal as 'Basic Salary', advance as 'Advance', deduction as 'Deduction', netSal as 'Net Salary' from payments where empId = (select empId from employee where empName = @name) and workedDate >= @startDate and workedDate <= @endDate", con);

                cmd.Parameters.Add(new SqlParameter("name", txtR1EName.Text));
                cmd.Parameters.Add(new SqlParameter("startDate", dtpR1StartDate.Value.ToString("yyyy-MM-dd")));
                cmd.Parameters.Add(new SqlParameter("endDate", dtpR1EndDate.Value.ToString("yyyy-MM-dd")));

                SqlDataAdapter result = new SqlDataAdapter(cmd);

                DataTable data = new DataTable();

                result.Fill(data);

                // titles

                string mTitle = "Report by Employee";

                string[] uTitles = new string[3];
                uTitles[0] = "Employee Name : " + txtR1EName.Text;
                uTitles[1] = "Start Date    : " + dtpR1StartDate.Value.ToString("yyyy-MM-dd");
                uTitles[2] = "End Date      : " + dtpR1EndDate.Value.ToString("yyyy-MM-dd");

                string[] lTitles = new string[0];

                frmReporViewer rep = new frmReporViewer(data, mTitle, uTitles, lTitles);
                rep.Show();



                con.Close();
            }

            catch
            {
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();

                string query = txtCQuery.Text;

                SqlCommand cmd = new SqlCommand(query, con);

                SqlDataAdapter result = new SqlDataAdapter(cmd);

                DataTable data = new DataTable();

                result.Fill(data);

                // titles

                string mTitle = "Custom Report";

                string[] uTitles = new string[0];

                string[] lTitles = new string[0];

                frmReporViewer rep = new frmReporViewer(data, mTitle, uTitles, lTitles);
                rep.Show();



                con.Close();
            }

            catch
            {
            }
        }