Exemple #1
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            try
            {
                int    from = Convert.ToInt32(txtFrom.Text);
                int    to   = Convert.ToInt32(txtTo.Text);
                string quer = "ReceiptNo = '";
                if (to > from)
                {
                    for (int x = from; x <= to; x++)
                    {
                        if (x == to)
                        {
                            quer += x.ToString("00000") + "'";
                        }
                        else
                        {
                            quer += x.ToString("00000") + "' OR ReceiptNo = '";
                        }
                    }
                    SqlConnection con = new SqlConnection(Community.DBLayer.con_String);
                    con.Open();
                    SqlCommand cmd = new SqlCommand("Select *,tblFamily.FamilyLeader AS MemberName from tblDonations INNER JOIN tblFamily ON tblDonations.FCardNo = tblFamily.FCardNo WHERE " + quer, con);

                    DataTable dt = new DataTable();

                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = cmd;

                    da.Fill(dt);
                    Reports.Donation.frmViewer   frm = new MCKJ.Reports.Donation.frmViewer();
                    Reports.Donation.rptDonation rpt = new MCKJ.Reports.Donation.rptDonation();

                    frm.crystalReportViewer1.ReportSource = rpt;

                    rpt.SetDataSource(dt);
                    frm.Show();
                    con.Close();
                }
                else
                {
                    MessageBox.Show("Please select right combination in From and To boxes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void rptDeath()
        {
            try
            {
                SqlConnection conn = new SqlConnection(DBLayer.CON_string);
                SqlCommand    cmd  = new SqlCommand(richTextBox2.Text);

                cmd.Connection = conn;

                cmd.CommandType = CommandType.Text;

                SqlParameter paraStartDate = cmd.Parameters.Add("@FromDate", SqlDbType.DateTime);
                paraStartDate.Value = Convert.ToDateTime(dateTimePicker1.Text);

                SqlParameter paraEndDate = cmd.Parameters.Add("@ToDate", SqlDbType.DateTime);
                paraEndDate.Value = Convert.ToDateTime(dateTimePicker2.Text);

                SqlDataAdapter sda = new SqlDataAdapter(cmd);

                DataTable aaa = new DataTable();

                sda.Fill(aaa);

                MCKJ.Reports.Donation.frmViewer frm = new MCKJ.Reports.Donation.frmViewer();
                Reports.BirthDeath.rptDeath     rpt = new rptDeath();

                rpt.SetDataSource(aaa);

                rpt.SetParameterValue("fromDate", Convert.ToDateTime(dateTimePicker1.Text));
                rpt.SetParameterValue("toDate", Convert.ToDateTime(dateTimePicker2.Text));


                frm.crystalReportViewer1.ReportSource = rpt;

                //frm.Text = "Purchase Bill";

                frm.Show();

                conn.Close();
            }
            catch (Exception exceptionparamter)
            {
                MessageBox.Show("Unable to view report!\n\n" + exceptionparamter.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure to print this report?", "Donation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                if (dgvDonation.Rows.Count != 0)
                {
                    int           id  = Convert.ToInt32(dgvDonation.CurrentRow.Cells[0].Value.ToString());
                    SqlConnection con = new SqlConnection(Community.DBLayer.con_String);
                    con.Open();
                    string query = "";

                    if (dgvDonation.CurrentRow.Cells[3].Value.ToString() == "")
                    {
                        query = "Select * , Cast(0 AS varchar(50)) MemberName From tblDonations WHERE ID =" + id;
                    }
                    else
                    {
                        query = "Select *,tblFamily.FamilyLeader AS MemberName from tblDonations INNER JOIN tblFamily ON tblDonations.FCardNo = tblFamily.FCardNo WHERE ID =" + id;
                    }

                    SqlCommand cmd = new SqlCommand(query, con);

                    DataTable dt = new DataTable();

                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = cmd;

                    da.Fill(dt);
                    Reports.Donation.frmViewer   frm = new MCKJ.Reports.Donation.frmViewer();
                    Reports.Donation.rptDonation rpt = new MCKJ.Reports.Donation.rptDonation();

                    frm.crystalReportViewer1.ReportSource = rpt;

                    rpt.SetDataSource(dt);
                    frm.Show();
                    con.Close();
                }
                else
                {
                    MessageBox.Show("No record to print!", "No record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemple #4
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(Community.DBLayer.con_String);

                conn.Open();

                //
                string     query   = "SELECT SUM(tblTransactions.Debit) As Debit,SUM(tblTransactions.Credit) As Credit, IsNull(Sum(Debit-Credit),0) As Balance FROM tblTransactions WHERE tblTransactions.Dated < '" + Convert.ToDateTime(dateTimePicker1.Text).ToString("MM/dd/yyyy") + "' AND tblTransactions.AccountCode =" + comboBox1.SelectedValue.ToString();
                SqlCommand Command = new SqlCommand(query, conn);
                Command.CommandType = CommandType.Text;
                SqlDataReader cReader = Command.ExecuteReader();;

                double OpeningBalance = 0;

                if (cReader.HasRows)
                {
                    cReader.Read();
                    OpeningBalance = Convert.ToDouble(cReader.GetValue(2));
                }
                else
                {
                    OpeningBalance = 0;
                }
                cReader.Close();
                //
                SqlCommand cmd = new SqlCommand("usp_RPT_Ledger", conn);

                cmd.Connection = conn;

                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter paraStartDate = cmd.Parameters.Add("@StartDate", SqlDbType.DateTime);
                paraStartDate.Value = Convert.ToDateTime(dateTimePicker1.Text);

                SqlParameter paraEndDate = cmd.Parameters.Add("@EndDate", SqlDbType.DateTime);
                paraEndDate.Value = Convert.ToDateTime(dateTimePicker2.Text);

                SqlParameter paraCode = cmd.Parameters.Add("@Code", SqlDbType.VarChar, 100);
                paraCode.Value = comboBox1.SelectedValue.ToString();

                SqlDataAdapter sda = new SqlDataAdapter(cmd);

                DataTable aaa = new DataTable();

                sda.Fill(aaa);


                MCKJ.Reports.Donation.frmViewer   frm = new MCKJ.Reports.Donation.frmViewer();
                Reports.Accounts.Ledger.rptLedger rpt = new MCKJ.Reports.Accounts.Ledger.rptLedger();


                rpt.SetDataSource(aaa);


                rpt.SetParameterValue("OBalance", OpeningBalance);
                rpt.SetParameterValue("fromDate", Convert.ToDateTime(dateTimePicker1.Text));
                rpt.SetParameterValue("toDate", Convert.ToDateTime(dateTimePicker2.Text));
                rpt.SetParameterValue("AccountName", comboBox1.Text.ToString());

                frm.crystalReportViewer1.ReportSource = rpt;

                //frm.Text = "Purchase Bill";

                frm.Show();

                conn.Close();
            }
            catch (Exception exceptionparamter)
            {
                MessageBox.Show("Unable to view report!\n\n" + exceptionparamter.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }