Пример #1
0
        private void PrintPreview(bool preview)
        {
            DsTokenSummary printds = new DsTokenSummary();

            DsTokenSummary.PatientRegistrationDataTable resultTalbe = new DsTokenSummary.PatientRegistrationDataTable();
            rptAllTokenReceipt crp           = new rptAllTokenReceipt();
            string             BranchName    = ConfigurationManager.AppSettings["Name"].ToString();
            string             BranchAddress = ConfigurationManager.AppSettings["Address"].ToString();
            string             shifttime     = "";

            int?   uNO      = 0;
            string UserName = "******";

            if (chbUsers.Checked)
            {
                uNO = Convert.ToInt16(cbxUser.SelectedValue.ToString());
                List <User> selectedusers = this.users.Where(u => u.Userno == uNO).ToList <User>();
                foreach (var item in selectedusers)
                {
                    UserName = item.UserName;
                }
                //UserBLL userBLL = new UserBLL();
                //List<User> users = this.userBLL.GetUsers().Where(u => u.Userno == uNO).ToList<User>();
            }


            if (cbxShifts.SelectedIndex == 0 || cbxShifts.SelectedIndex == -1)
            {
                printds = new TokenSummaryBLL().GetTokenSummary(dtpFrom.Value.Date, dtpTo.Value.Date, rbAll.Checked, rbInjection.Checked, rbCheckup.Checked, rbLab.Checked, rbMedicine.Checked, cb50.Checked, uNO);
            }
            else
            {
                printds = new TokenSummaryBLL().GetTokenSummary(dtpFrom.Value.Date, dtpTo.Value.Date, rbAll.Checked, rbInjection.Checked, rbCheckup.Checked, rbLab.Checked, rbMedicine.Checked, cb50.Checked, (Shift)cbxShifts.SelectedItem, uNO);
                Shift shift = (Shift)cbxShifts.SelectedItem;
                shift     = new BLL.ShiftsBLL().GetShiftStartEndTime(shift, this.dtpFrom.Value.Date);
                shifttime = shift.ChangeDateTime.ToString("hh:mm:ss");
            }

            string tokenType  = "";
            string tokenRange = "";

            if (rbAll.Checked == true)
            {
                tokenType = "All tokens";
            }
            else if (rbCheckup.Checked == true)
            {
                tokenType = "Checkup only";
            }
            else if (rbInjection.Checked == true)
            {
                tokenType = "Injection only";
            }
            else if (rbLab.Checked == true)
            {
                tokenType = "Lab test only";
            }
            else if (rbMedicine.Checked == true)
            {
                tokenType = "Medicines";
            }

            tokenType += " - " + cbxShifts.Text + ' ' + shifttime;
            string filterExpression;

            if (rbRange.Checked == true)
            {
                try
                {
                    int  to = 0, from = 0;
                    bool r;
                    if (txtToToken.Text.Trim() != string.Empty)
                    {
                        r = int.TryParse(txtToToken.Text.Trim(), out to);
                    }
                    if (txtFromToken.Text.Trim() != string.Empty)
                    {
                        r = int.TryParse(txtFromToken.Text.Trim(), out from);
                    }

                    if (to == 0)
                    {
                        MessageBox.Show("Please Enter the Valid Token Number");
                        this.txtToToken.Focus();
                        return;
                    }
                    if (from == 0)
                    {
                        MessageBox.Show("Please Enter the Valid Token Number");
                        this.txtFromToken.Focus();
                        return;
                    }

                    filterExpression = "TokenNumber >= " + from.ToString() + " and TokenNumber <= " + to.ToString();

                    DataRow[] TokenRows = ((DataTable)printds.PatientRegistration).Select(filterExpression);

                    foreach (DataRow row in TokenRows)
                    {
                        resultTalbe.ImportRow(row);
                    }
                    tokenRange = from.ToString() + "  to  " + to.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Token Range Invalid");
                    return;
                }
            }
            else
            {
                resultTalbe = printds.PatientRegistration;
                tokenRange  = "All Tokens";
            }

            //if (rbCheckup.Checked)
            //{
            //    if (chbPoor.Checked)
            //    {
            //        if (String.IsNullOrEmpty(filterExpression))
            //    }
            //}


            crp.SetDataSource((DataTable)resultTalbe);
            crp.SetParameterValue("TokenType", tokenType);
            crp.SetParameterValue("fromDate", dtpFrom.Value.Date);
            crp.SetParameterValue("toDate", dtpTo.Value.Date);
            crp.SetParameterValue("TokenRange", tokenRange);
            crp.SetParameterValue("BranchName", BranchName);
            crp.SetParameterValue("BranchAddress", BranchAddress);
            crp.SetParameterValue("UserName", UserName);
            FrmReportViewer frmViewer = new FrmReportViewer();

            frmViewer.crystalReportViewer1.ReportSource = crp;

            //frmViewer.crystalReportViewer1.SelectionFormula = ""
            if (preview)
            {
                frmViewer.ShowDialog();
            }
            else
            {
                frmViewer.crystalReportViewer1.RefreshReport();
                frmViewer.crystalReportViewer1.PrintReport();
            }
        }
Пример #2
0
        private void PrintPreview(bool preview)
        {
            DsTokenSummary printds = new DsTokenSummary();

            DsTokenSummary.PatientRegistrationDataTable resultTalbe = new DsTokenSummary.PatientRegistrationDataTable();
            rptAllTokenReceipt crp           = new rptAllTokenReceipt();
            string             BranchName    = ConfigurationManager.AppSettings["Name"].ToString();
            string             BranchAddress = ConfigurationManager.AppSettings["Address"].ToString();

            printds = new TokenSummaryBLL().GetTokenSummary(dtpFrom.Value.Date, dtpTo.Value.Date, rbAll.Checked, rbInjection.Checked, rbCheckup.Checked, rbLab.Checked, rbMedicine.Checked, cb50.Checked);
            string tokenType  = "";
            string tokenRange = "";

            if (rbAll.Checked == true)
            {
                tokenType = "All tokens";
            }
            else if (rbCheckup.Checked == true)
            {
                tokenType = "Checkup only";
            }
            else if (rbInjection.Checked == true)
            {
                tokenType = "Injection only";
            }
            else if (rbLab.Checked == true)
            {
                tokenType = "Lab test only";
            }
            else if (rbMedicine.Checked == true)
            {
                tokenType = "Medicines";
            }

            if (rbRange.Checked == true)
            {
                try
                {
                    int  to = 0, from = 0;
                    bool r;
                    if (txtToToken.Text.Trim() != string.Empty)
                    {
                        r = int.TryParse(txtToToken.Text.Trim(), out to);
                    }
                    if (txtFromToken.Text.Trim() != string.Empty)
                    {
                        r = int.TryParse(txtFromToken.Text.Trim(), out from);
                    }

                    if (to == 0)
                    {
                        MessageBox.Show("Please Enter the Valid Token Number");
                        this.txtToToken.Focus();
                        return;
                    }
                    if (from == 0)
                    {
                        MessageBox.Show("Please Enter the Valid Token Number");
                        this.txtFromToken.Focus();
                        return;
                    }

                    string    filterExpression = "TokenNumber >= " + from.ToString() + " and TokenNumber <= " + to.ToString();
                    DataRow[] TokenRows        = ((DataTable)printds.PatientRegistration).Select(filterExpression);

                    foreach (DataRow row in TokenRows)
                    {
                        resultTalbe.ImportRow(row);
                    }
                    tokenRange = from.ToString() + "  to  " + to.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Token Range Invalid");
                    return;
                }
            }
            else
            {
                resultTalbe = printds.PatientRegistration;
                tokenRange  = "All Tokens";
            }

            crp.SetDataSource((DataTable)resultTalbe);
            crp.SetParameterValue("TokenType", tokenType);
            crp.SetParameterValue("fromDate", dtpFrom.Value.Date);
            crp.SetParameterValue("toDate", dtpTo.Value.Date);
            crp.SetParameterValue("TokenRange", tokenRange);
            crp.SetParameterValue("BranchName", BranchName);
            crp.SetParameterValue("BranchAddress", BranchAddress);
            FrmReportViewer frmViewer = new FrmReportViewer();

            frmViewer.crystalReportViewer1.ReportSource = crp;
            if (preview)
            {
                frmViewer.ShowDialog();
            }
            else
            {
                frmViewer.crystalReportViewer1.RefreshReport();
                frmViewer.crystalReportViewer1.PrintReport();
            }
        }
        private void PrintPreview(bool preview)
        {
            DSTTokenSummryUserWise printds = new DSTTokenSummryUserWise();

            //   DsTokenSummary.PatientRegistrationDataTable resultTalbe = new DsTokenSummary.PatientRegistrationDataTable();
            DSTTokenSummryUserWise.TokenSummeryUserWiseDataTable resultTalbe = new DSTTokenSummryUserWise.TokenSummeryUserWiseDataTable();
            rptTokensUserWise crp           = new rptTokensUserWise();
            string            BranchName    = ConfigurationManager.AppSettings["Name"].ToString();
            string            BranchAddress = ConfigurationManager.AppSettings["Address"].ToString();

            //  string shifttime="";

            /////////   ---------------------------     Asif - 04-05-19 - Disable if & send time flag as parameter
            printds = new TokenSummaryBLL().GetTokenSummaryUserWise(dtpFrom.Value, dtpTo.Value, chkSelectTime.Checked);
            //if (chkSelectTime.Checked==true)
            //{
            //    printds = new TokenSummaryBLL().GetTokenSummaryUserWise(dtpFrom.Value, dtpTo.Value);
            //}
            //else
            //{
            //    printds = new TokenSummaryBLL().GetTokenSummaryUserWise(dtpFrom.Value.Date, dtpTo.Value.Date);
            //}
            /////////   ---------------------------     Asif - 04-05-19 - Disable

            //   printds = new TokenSummaryBLL().GetTokenSummaryUserWise(dtpFrom.Value, dtpTo.Value);


            //if (cbxShifts.SelectedIndex == 0 || cbxShifts.SelectedIndex == -1)
            //    printds = new TokenSummaryBLL().GetTokenSummary(dtpFrom.Value.Date, dtpTo.Value.Date, rbAll.Checked, rbInjection.Checked, rbCheckup.Checked, rbLab.Checked, rbMedicine.Checked, cb50.Checked);
            //else
            //{
            //    Shift shift = (Shift)cbxShifts.SelectedItem;
            //    shift = new BLL.ShiftsBLL().GetShiftStartEndTime(shift,this.dtpFrom.Value.Date);
            //    shifttime = shift.ChangeDateTime.ToString("hh:mm:ss");

            //}

            //string tokenType = "";
            //string tokenRange = "";
            //if (rbAll.Checked == true)
            //    tokenType = "All tokens";
            //else if (rbCheckup.Checked == true)
            //    tokenType = "Checkup only";
            //else if (rbInjection.Checked == true)
            //    tokenType = "Injection only";
            //else if (rbLab.Checked == true)
            //    tokenType = "Lab test only";
            //else if (rbMedicine.Checked == true)
            //    tokenType = "Medicines";

            //tokenType += " - " + cbxShifts.Text+shifttime;
            //if (rbRange.Checked == true)
            //{
            //    try
            //    {
            //        int to = 0, from = 0;
            //        bool r;
            //        if (txtToToken.Text.Trim() != string.Empty)
            //            r = int.TryParse(txtToToken.Text.Trim(), out to);
            //        if (txtFromToken.Text.Trim() != string.Empty)
            //            r = int.TryParse(txtFromToken.Text.Trim(), out from);

            //        if (to == 0)
            //        {
            //            MessageBox.Show("Please Enter the Valid Token Number");
            //            this.txtToToken.Focus();
            //            return;
            //        }
            //        if (from == 0)
            //        {
            //            MessageBox.Show("Please Enter the Valid Token Number");
            //            this.txtFromToken.Focus();
            //            return;
            //        }

            //        string filterExpression = "TokenNumber >= " + from.ToString() + " and TokenNumber <= " + to.ToString();
            //        DataRow[] TokenRows = ((DataTable)printds.PatientRegistration).Select(filterExpression);

            //        foreach (DataRow row in TokenRows)
            //        {
            //            resultTalbe.ImportRow(row);
            //        }
            //        tokenRange = from.ToString() + "  to  " + to.ToString();
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show(ex.Message, "Token Range Invalid");
            //        return;
            //    }

            //}
            //else
            //{
            //    resultTalbe = printds.PatientRegistration;
            //    tokenRange = "All Tokens";
            //}
            resultTalbe = printds.TokenSummeryUserWise;
            crp.SetDataSource((DataTable)resultTalbe);
            //  crp.SetParameterValue("TokenType", tokenType);

            if (chkSelectTime.Checked == true)
            {
                crp.SetParameterValue("fromDate", dtpFrom.Value.ToString("dd/MM/yyyy HH:mm"));
                crp.SetParameterValue("toDate", dtpTo.Value.ToString("dd/MM/yyyy HH:mm"));
            }
            else
            {
                crp.SetParameterValue("fromDate", dtpFrom.Value.ToString("dd/MM/yyyy"));
                crp.SetParameterValue("toDate", dtpTo.Value.ToString("dd/MM/yyyy"));
            }

            //crp.SetParameterValue("TokenRange", tokenRange);
            crp.SetParameterValue("BranchName", BranchName);
            crp.SetParameterValue("BranchAddress", BranchAddress);
            FrmReportViewer frmViewer = new FrmReportViewer();

            frmViewer.crystalReportViewer1.ReportSource = crp;
            if (preview)
            {
                frmViewer.ShowDialog();
            }
            else
            {
                frmViewer.crystalReportViewer1.RefreshReport();
                frmViewer.crystalReportViewer1.PrintReport();
            }
        }