Beispiel #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                string MemberName     = dgvDeath.CurrentRow.Cells[3].Value.ToString();
                bool   isPrinted      = Convert.ToBoolean(dgvDeath.CurrentRow.Cells["IsPrinted"].Value.ToString());
                string FCardNo        = dgvDeath.CurrentRow.Cells[2].Value.ToString();
                string RegNo          = dgvDeath.CurrentRow.Cells[1].Value.ToString();
                int    FamilyMemberID = Convert.ToInt32(usp_SEL_TSF_tblFamilyMemberTableAdapter.ScalarQuery(FCardNo, MemberName));

                DialogResult dr;

                if (isPrinted)
                {
                    dr = MessageBox.Show("Death Certificate for this member is already Printed.\r\n Do you want to print duplicate report ? ", "Death Certificate", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }
                else
                {
                    dr = MessageBox.Show("Do you want to print report ? ", "Death Certificate", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }

                if (dr == DialogResult.Yes)
                {
                    SqlConnection con = new SqlConnection(Community.DBLayer.con_String);
                    con.Open();

                    ReportDocument cryRpt = new ReportDocument();
                    //cryRpt.Load("E:\\MCKJ\\SourceCode-Hall5Updated\\Mckj Software - SourceCode\\KCommunity\\Reports\\Hall Booking\\rptHallBookingInfo.rpt");
                    //cryRpt.Load(Application.StartupPath + "rptHallBookingInfo.rpt");
                    //cryRpt.SetParameterValue("StartDate", dtpSearchDate.Text);
                    //cryRpt.SetParameterValue("EndDate", dtpSearchDateTo.Text);

                    Reports.BirthDeath.frmViewer           frm = new MCKJ.Reports.BirthDeath.frmViewer();
                    Reports.BirthDeath.rptDeathCertificate rpt = new MCKJ.Reports.BirthDeath.rptDeathCertificate();
                    rpt.SetDatabaseLogon("sa", "sql_pwd_SA", "MCKJ-SERVER", "Community");

                    frm.crystalReportViewer1.ReportSource = rpt;
                    rpt.SetParameterValue("FamilyMemberID", FamilyMemberID);

                    frm.Refresh();
                    frm.Show();
                    con.Close();

                    //UpdatePrinted(FamilyMemberID, RegNo);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void rptBirth()
        {
            try
            {
                SqlConnection conn = new SqlConnection(DBLayer.CON_string);
                SqlCommand    cmd  = new SqlCommand(richTextBox1.Text);

                cmd.Connection = conn;

                cmd.CommandType = CommandType.Text;

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

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

                SqlDataAdapter sda = new SqlDataAdapter(cmd);

                DataTable aaa = new DataTable();

                sda.Fill(aaa);

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

                rpt.SetDataSource(aaa);

                rpt.SetParameterValue("fromDate", Convert.ToDateTime(dtpFromDate.Text));
                rpt.SetParameterValue("toDate", Convert.ToDateTime(dtpToDate.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);
            }
        }