Example #1
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            CR_MHTuDen rp = new CR_MHTuDen();

            CrystalDecisions.Shared.ParameterValues        myValue    = new CrystalDecisions.Shared.ParameterValues();
            CrystalDecisions.Shared.ParameterDiscreteValue PDVTuNgay  = new CrystalDecisions.Shared.ParameterDiscreteValue();
            CrystalDecisions.Shared.ParameterDiscreteValue PDVDenNgay = new CrystalDecisions.Shared.ParameterDiscreteValue();


            CrystalDecisions.Shared.ConnectionInfo con = new CrystalDecisions.Shared.ConnectionInfo();
            con.ServerName   = frmDangnhap.SV;
            con.DatabaseName = frmDangnhap.DB;
            con.UserID       = frmDangnhap.ID;
            con.Password     = frmDangnhap.PASS;

            TableLogOnInfo table = new TableLogOnInfo();

            table.ConnectionInfo = con;
            rp.Database.Tables[0].ApplyLogOnInfo(table);

            PDVTuNgay.Value = this.txtDayStart.Value;
            myValue.Add(PDVTuNgay);
            rp.DataDefinition.ParameterFields["@TUNGAY"].ApplyCurrentValues(myValue);
            myValue.Clear();

            PDVDenNgay.Value = this.txtDayEnd.Value;
            myValue.Add(PDVDenNgay);
            rp.DataDefinition.ParameterFields["@DENNGAY"].ApplyCurrentValues(myValue);
            myValue.Clear();


            this.crystalReportViewer1.ReportSource = rp;
        }
Example #2
0
        /// <summary>
        /// Sets the parameters that have been added using the SetParameter method
        /// </summary>
        private void SetParameters()
        {
            foreach (ParameterFieldDefinition parameter in _reportDocument.DataDefinition.ParameterFields)
            {
                try
                {
                    // Now get the current value for the parameter
                    CrystalDecisions.Shared.ParameterValues currentValues = parameter.CurrentValues;
                    currentValues.Clear();

                    // Create a value object for Crystal reports and assign the specified value.
                    CrystalDecisions.Shared.ParameterDiscreteValue newValue = new CrystalDecisions.Shared.ParameterDiscreteValue();

                    if (_parameters.ContainsKey(parameter.Name))
                    {
                        newValue.Value = _parameters[parameter.Name];
                        // Now add the new value to the values collection and apply the
                        // collection to the report.
                        currentValues.Add(newValue);
                        parameter.ApplyCurrentValues(currentValues);
                    }
                    else
                    {
                        parameter.ApplyCurrentValues(parameter.DefaultValues);
                    }
                }
                catch
                {
                    // Ignore any errors
                }
            }
        }
Example #3
0
        public void INHOADON(string ms)
        {
            //----------1.Khai báo CrystalReport: CrystalReportHD.rpt
            rp_DonHang rp = new rp_DonHang();

            //----------2.Cung cấp thông tin đăng nhập cho CrystalReport: CrystalReportHD
            ConnectionInfo myConn = new ConnectionInfo();

            myConn.ServerName   = frmDangnhap.SV;
            myConn.DatabaseName = frmDangnhap.DB;
            myConn.UserID       = frmDangnhap.ID;
            myConn.Password     = frmDangnhap.PASS;
            TableLogOnInfo myTable = new TableLogOnInfo();

            myTable.ConnectionInfo = myConn;
            rp.Database.Tables[0].ApplyLogOnInfo(myTable);

            //----------3.Khai báo kết nối tham số với CrystalReport
            CrystalDecisions.Shared.ParameterValues        myVL    = new CrystalDecisions.Shared.ParameterValues();
            CrystalDecisions.Shared.ParameterDiscreteValue PDVMaHD = new CrystalDecisions.Shared.ParameterDiscreteValue();


            //----------4. Truyền tham số Từ ngày - Đến ngày (Form)
            //-----4.1. Truyền tham số Từ ngày
            PDVMaHD.Value = ms;
            myVL.Add(PDVMaHD);
            rp.DataDefinition.ParameterFields["@MSHD"].ApplyCurrentValues(myVL);
            myVL.Clear();


            //-----------5.Gán CrystalReport vào crystalReportViewerP
            crystalReportViewerHD.ReportSource = rp;
        }
Example #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (!PowerCheckCsClass.IfHasPower(LoginClass.LogID, CommFunction.GSYSNAME, sender, CommFunction.ConnectString))
            {
                return;
            }

            if ((tbGzbdh.Text.Trim() == "") || tbGzbdh.Text == null)
            {
                return;
            }

            LYFunctionCs.frmReportView frv = new LYFunctionCs.frmReportView();

            ReportDocument Rpt = new ReportDocument();

            string pRptNmae = "";

            pRptNmae = LYFunctionCs.LYFunctionCsClass.cmdScalar("select cm.report_file from cc_cold_chain_c cc left join cc_cold_chain_z cz on cc.pkunid=cz.unid left join cc_item_master cm on cc.size_desc=cm.size_desc and cm.season=cz.season where pkunid='" + tbGzbdh.Text + "' and  cm.report_file is not null and rownum=1 ", CommFunction.ConnectString);
            if ((pRptNmae.Trim() == "") || (pRptNmae == null))
            {
                pRptNmae = "Rep_CC_ITEM_TRACK.rpt";
            }

            Rpt.Load(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + pRptNmae);

            TableLogOnInfo logOnInfo = new TableLogOnInfo();

            logOnInfo.ConnectionInfo.ServerName = CommFunction.cfServerName;
            logOnInfo.ConnectionInfo.UserID     = CommFunction.cfUserID;
            logOnInfo.ConnectionInfo.Password   = CommFunction.cfPassword;

            Rpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
            //Rpt.Refresh();

            frv.crystalReportViewer1.ReportSource = Rpt;


            CrystalDecisions.Shared.ParameterValues        mypaVal  = new CrystalDecisions.Shared.ParameterValues();
            CrystalDecisions.Shared.ParameterDiscreteValue mypaDVal = new CrystalDecisions.Shared.ParameterDiscreteValue();
            mypaDVal.Value = tbGzbdh.Text;

            mypaVal.Add(mypaDVal);
            Rpt.DataDefinition.ParameterFields["GZBDH"].ApplyCurrentValues(mypaVal);

            frv.ShowDialog();
        }
Example #5
0
 private void AsignarParametros(double p)
 {
     CrystalDecisions.Shared.ParameterValues myVals = new CrystalDecisions.Shared.ParameterValues();
     CrystalDecisions.Shared.ParameterDiscreteValue myDiscrete = new CrystalDecisions.Shared.ParameterDiscreteValue();
     myDiscrete.Value = NumALet.ToCardinal(Convert.ToDecimal(p));
     myVals.Add(myDiscrete);
     facturaRpt.DataDefinition.ParameterFields[0].ApplyCurrentValues(myVals);
 }
Example #6
0
        private void SetCrysParams(string respar, string IdConcretera, string IdDiam, string Prueba)
        {
            ParameterValues pvs = new CrystalDecisions.Shared.ParameterValues();

            ParameterDiscreteValue pdvRazonsocial   = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvObraUbicacion = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvObraColonia   = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvTipoPrueba    = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvExp3          = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvExp7          = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvUnidad        = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvSINO          = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvConsecutivo   = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvRes           = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvConcre        = new CrystalDecisions.Shared.ParameterDiscreteValue();
            ParameterDiscreteValue pdvDiam          = new CrystalDecisions.Shared.ParameterDiscreteValue();

            pdvRazonsocial.Value = strRazonSocial;
            pvs.Add(pdvRazonsocial);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Razonsocial"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvObraUbicacion.Value = strObraUbicacion;
            pvs.Add(pdvObraUbicacion);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["ObraUbicacion"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvObraColonia.Value = strObraColonia;
            pvs.Add(pdvObraColonia);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["ObraColonia"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvTipoPrueba.Value = Prueba;
            pvs.Add(pdvTipoPrueba);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["TipoPrueba"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvUnidad.Value = dsUnidad1.Unidad.Rows[Mpa][0].ToString();
            pvs.Add(pdvUnidad);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Unidad"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvSINO.Value = 0;
            pvs.Add(pdvSINO);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Logotipo"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvConsecutivo.Value = "0";
            pvs.Add(pdvConsecutivo);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Consecutivo"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvRes.Value = respar;
            pvs.Add(pdvRes);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Res"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvConcre.Value = IdConcretera;
            pvs.Add(pdvConcre);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Concre"].ApplyCurrentValues(pvs);
            pvs.Clear();

            pdvDiam.Value = IdDiam;
            pvs.Add(pdvDiam);
            cryRepCartaEdadEspecificada.DataDefinition.ParameterFields["Diam"].ApplyCurrentValues(pvs);
            pvs.Clear();

//			pdvRes1.Value = double.Parse(resis) ;
//			pvs.Add(pdvRes1);
//			cryRepCartaEdadTemprana.DataDefinition.ParameterFields["Res1"].ApplyCurrentValues(pvs);
//			pvs.Clear();
        }
Example #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (!PowerCheckCsClass.IfHasPower(LoginClass.LogID, CommFunction.GSYSNAME, sender, CommFunction.ConnectString)) return;

            if ((tbUnid.Text.Trim() == "") || tbUnid.Text == null) { return; }

            LYFunctionCs.frmReportView frv = new LYFunctionCs.frmReportView();

            ReportDocument Rpt = new ReportDocument();

            string pRptNmae = "";
            pRptNmae = LYFunctionCs.LYFunctionCsClass.cmdScalar("select cm.report_file from cc_cold_chain_c cc left join cc_cold_chain_z cz on cc.pkunid=cz.unid left join cc_item_master cm on cc.size_desc=cm.size_desc and cm.season=cz.season where pkunid='" + tbUnid.Text + "' and  cm.report_file is not null and rownum=1 ", CommFunction.ConnectString);
            if ((pRptNmae.Trim() == "") || (pRptNmae == null))
                pRptNmae = "Rep_CC_ITEM_TRACK.rpt";

            Rpt.Load(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + pRptNmae);

            TableLogOnInfo logOnInfo = new TableLogOnInfo();
            logOnInfo.ConnectionInfo.ServerName = CommFunction.cfServerName;
            logOnInfo.ConnectionInfo.UserID = CommFunction.cfUserID;
            logOnInfo.ConnectionInfo.Password = CommFunction.cfPassword;

            Rpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
            //Rpt.Refresh();

            frv.crystalReportViewer1.ReportSource = Rpt;

            CrystalDecisions.Shared.ParameterValues mypaVal = new CrystalDecisions.Shared.ParameterValues();
            CrystalDecisions.Shared.ParameterDiscreteValue mypaDVal = new CrystalDecisions.Shared.ParameterDiscreteValue();
            mypaDVal.Value = tbUnid.Text;

            mypaVal.Add(mypaDVal);
            Rpt.DataDefinition.ParameterFields["GZBDH"].ApplyCurrentValues(mypaVal);

            frv.ShowDialog();

            LYFunctionCs.LYFunctionCsClass.cmd("update cc_cold_chain_z set ifprint='1' where UNID='"+tbUnid.Text+"'", CommFunction.ConnectString);
        }
        void previewID()
        {
            try
            {
                CrystalDecisions.CrystalReports.Engine.ReportDocument objReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos();

                CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo();

                CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

                CrystalDecisions.CrystalReports.Engine.Tables CrTables;

                CrystalDecisions.Shared.ParameterValues crParameterValues = new CrystalDecisions.Shared.ParameterValues();

                CrystalDecisions.Shared.ParameterDiscreteValue crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();

                //objReport.Load(LoadReport());

                objReport.Load(_path + _reportName_Outside);

                string sUserID = "sa";

                string sPassword = "******";

                string sServerName = "192.168.1.42";

                string sDatabaseName = "HRIS";


                crConnectionInfo.ServerName = sServerName;

                crConnectionInfo.DatabaseName = sDatabaseName;

                crConnectionInfo.UserID = sUserID;

                crConnectionInfo.Password = sPassword;


                CrTables = objReport.Database.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    ConInfo = CrTable.LogOnInfo;

                    ConInfo.ConnectionInfo = crConnectionInfo;

                    CrTable.ApplyLogOnInfo(ConInfo);
                }

                reportViewer.ViewerCore.ReportSource = objReport;

                //rekta print
                //objReport.PrintToPrinter(1, true, 0, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }