Exemplo n.º 1
0
        /// <summary>
        /// Extract value from a raw parameter string.
        /// "paraInputText" must be just a single value and not a multiple value parameters
        /// </summary>
        /// <param name="paraType"></param>
        /// <param name="paraInputText"></param>
        /// <param name="paraName"></param>
        /// <remarks>
        /// Complex parameter input can be as such,
        /// pipe "|" is used to split multiple values, comma "," is used to split Start and End value of a range.
        ///
        /// -a "date:(01-01-2001,28-02-2001)|(02-01-2002,31-10-2002)|(02-08-2002,31-12-2002)"
        /// -a "Client:(Ace Soft Inc,Best Computer Inc)|(Xtreme Bike Inc,Zebra Design Inc)"
        /// </remarks>
        /// <returns></returns>
        private ParameterValue GetSingleParamValue(DiscreteOrRangeKind paraType, string paraInputText, string paraName)
        {
            ParameterValues paraValues              = new ParameterValues();
            bool            isDiscreateType         = paraType == DiscreteOrRangeKind.DiscreteValue ? true : false;
            bool            isDiscreateAndRangeType = paraType == DiscreteOrRangeKind.DiscreteAndRangeValue ? true : false;
            bool            isRangeType             = paraType == DiscreteOrRangeKind.RangeValue ? true : false;
            bool            paraTextIsRange         = paraInputText.IndexOf("(") != -1 ? true : false;

            if (isDiscreateType || (isDiscreateAndRangeType && !paraTextIsRange))
            {
                var paraValue = new ParameterDiscreteValue()
                {
                    Value = paraInputText
                };
                _logger.Write(string.Format("Discrete Parameter : {0} = {1}", paraName, ((ParameterDiscreteValue)paraValue).Value));
                return(paraValue);
            }
            else if (isRangeType || (isDiscreateAndRangeType && paraTextIsRange))
            {
                // sample of range parameter (01-01-2001,28-02-2001)
                var paraValue = new ParameterRangeValue()
                {
                    StartValue = Helper.GetStartValue(paraInputText),
                    EndValue   = Helper.GetEndValue(paraInputText)
                };
                _logger.Write(string.Format("Range Parameter : {0} = {1} to {2} ", paraName, ((ParameterRangeValue)paraValue).StartValue, ((ParameterRangeValue)paraValue).EndValue));
                return(paraValue);
            }
            return(null);
        }
        private static void AddParameter(ref ParameterValues pValues, DiscreteOrRangeKind DoR, string inputString, string pName)
        {
            ParameterValue paraValue;

            if (DoR == DiscreteOrRangeKind.DiscreteValue || (DoR == DiscreteOrRangeKind.DiscreteAndRangeValue && inputString.IndexOf("(") == -1))
            {
                paraValue = new ParameterDiscreteValue();
                ((ParameterDiscreteValue)paraValue).Value = inputString;
                Console.WriteLine("Discrete Parameter : {0} = {1}", pName, ((ParameterDiscreteValue)paraValue).Value);

                if (enableLog)
                {
                    WriteLog("Discrete Parameter : " + pName + " = " + ((ParameterDiscreteValue)paraValue).Value);
                }

                pValues.Add(paraValue);
                paraValue = null;
            }
            else if (DoR == DiscreteOrRangeKind.RangeValue || (DoR == DiscreteOrRangeKind.DiscreteAndRangeValue && inputString.IndexOf("(") != -1))
            {
                paraValue = new ParameterRangeValue();
                ((ParameterRangeValue)paraValue).StartValue = GetStartValue(inputString);
                ((ParameterRangeValue)paraValue).EndValue   = GetEndValue(inputString);
                Console.WriteLine("Range Parameter : {0} = {1} to {2} ", pName, ((ParameterRangeValue)paraValue).StartValue, ((ParameterRangeValue)paraValue).EndValue);

                if (enableLog)
                {
                    WriteLog("Range Parameter : " + pName + " = " + ((ParameterRangeValue)paraValue).StartValue + " to " + ((ParameterRangeValue)paraValue).EndValue);
                }

                pValues.Add(paraValue);
                paraValue = null;
            }
        }
        private void displayReport()
        {
            DateTime dtStartDate = Convert.ToDateTime(txtStartDate.Text);
            DateTime dtEndDate   = Convert.ToDateTime(txtEndDate.Text);

            ParameterRangeValue myRangeValue = new ParameterRangeValue();

            myRangeValue.StartValue = dtStartDate; //txtDateStart.Text;
            myRangeValue.EndValue   = dtEndDate;



            //This will display specific supplier transaction only
            oReportDocument.Load(Server.MapPath("~/Reports/PartnerSOASummary.rpt"));

            try
            {
                oReportDocument.SetParameterValue("PartnerCode", ddPartnerList.SelectedValue.ToString());
                oReportDocument.SetParameterValue("DateRange", myRangeValue);
                oReportDocument.SetDatabaseLogon("sa", "p@ssw0rd");     // Supply user credentials

                CrystalReportViewer1.ReportSource = oReportDocument;
            }
            catch
            {
            }
        }
        private void displayReport()
        {
            DateTime dtStartDate = Convert.ToDateTime(txtStartDate.Text);
            DateTime dtEndDate   = Convert.ToDateTime(txtEndDate.Text);

            ParameterRangeValue myRangeValue = new ParameterRangeValue();

            myRangeValue.StartValue = dtStartDate; //txtDateStart.Text;
            myRangeValue.EndValue   = dtEndDate;

            try
            {
                if (ddSupplierList.SelectedIndex > 0)
                {
                    oReportDocument.Load(Server.MapPath("~/Reports/Direct_Receive_Supplier_Summary.rpt"));
                    oReportDocument.SetParameterValue("SupplierCode", ddSupplierList.SelectedValue.ToString());
                }
                else
                {
                    oReportDocument.Load(Server.MapPath("~/Reports/Direct_Receive_Summary.rpt"));
                }

                oReportDocument.SetParameterValue("DateRange", myRangeValue);
                oReportDocument.SetDatabaseLogon("sa", "p@ssw0rd");

                CrystalReportViewer1.ReportSource = oReportDocument;
            }
            catch
            {
            }
        }
Exemplo n.º 5
0
        private void DisplayReport()
        {
            DateTime dtStartDate = Convert.ToDateTime(txtStartDate.Text);
            DateTime dtEndDate   = Convert.ToDateTime(txtEndDate.Text);

            ParameterRangeValue myRangeValue = new ParameterRangeValue();

            myRangeValue.StartValue = dtStartDate;
            myRangeValue.EndValue   = dtEndDate;


            //try
            //{
            if (ddBranchList.SelectedIndex == 0)
            {
                oReportDocument.Load(Server.MapPath("~/Reports/BranchSalesSummary_Final.rpt"));
            }
            else
            {
                oReportDocument.Load(Server.MapPath("~/Reports/BranchSalesSummary_PerBranch_Final.rpt"));
                oReportDocument.SetParameterValue("BranchCode", ddBranchList.SelectedValue);
            }
            oReportDocument.SetParameterValue("DateRange", myRangeValue);
            //oReportDocument.SetParameterValue("@STORAGECODE", ddStorage.SelectedValue.ToString());
            //oReportDocument.SetParameterValue("StorageName", ddStorage.SelectedItem.ToString());
            oReportDocument.SetDatabaseLogon("sa", "p@ssw0rd");

            CrystalReportViewer1.ReportSource = oReportDocument;
            //}
            //catch
            //{

            //}
        }
        private void displayReport()
        {
            DateTime dtStartDate = Convert.ToDateTime(txtStartDate.Text);
            DateTime dtEndDate   = Convert.ToDateTime(txtEndDate.Text);

            ParameterRangeValue myRangeValue = new ParameterRangeValue();

            myRangeValue.StartValue = dtStartDate; //txtDateStart.Text;
            myRangeValue.EndValue   = dtEndDate;



            try
            {
                oReportDocument.Load(Server.MapPath("~/Reports/BranchDeliverySummary.rpt"));
                oReportDocument.SetParameterValue("BranchCode", ddBranchList.SelectedValue.ToString());
                oReportDocument.SetParameterValue("DateRange", myRangeValue);
                oReportDocument.SetDatabaseLogon("sa", "p@ssw0rd");

                CrystalReportViewer1.ReportSource = oReportDocument;
            }
            catch
            {
            }
        }
Exemplo n.º 7
0
        private void DeveloperReportForm_Load(object sender, EventArgs e)
        {
            //string strServer = "tcp:192.168.1.100,49172";
            //string strUserName = "******";
            //string strPassword = "******";
            //string strDatabaseName = "SrisDb";

            // crystalReportViewer1.SelectionFormula = "monthname(month({ SystemDevelopments.DateAccomplishment})) LIKE '" + ucSystemDevWeekly.printMonth + "'";

            if (MainForm.accessLevel.Contains("ADMIN"))
            {
                rpt_Programmer_Weekly rpt_Programmer_Weekly = new rpt_Programmer_Weekly();
                rpt_Programmer_Weekly.DataSourceConnections[0].SetConnection(CrystalReportConnection.strServer, CrystalReportConnection.strDatabase, CrystalReportConnection.strUserId, CrystalReportConnection.strPwd);

                rpt_Programmer_Weekly.SetParameterValue("UserID", ucSystemDevAdmin.titleId);
                rpt_Programmer_Weekly.SetParameterValue("monthName", ucSystemDevWeekly.printMonth);

                DateTime date            = DateTime.Parse("01" + ucSystemDevWeekly.printMonth + ucSystemDevWeekly.printYear);
                var      firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
                var      lastDayOfMonth  = firstDayOfMonth.AddMonths(1).AddDays(-1);

                ParameterRangeValue myParameterRangeValue = new ParameterRangeValue();
                myParameterRangeValue.StartValue = firstDayOfMonth;
                myParameterRangeValue.EndValue   = lastDayOfMonth;
                rpt_Programmer_Weekly.SetParameterValue("Month", myParameterRangeValue);


                crystalReportViewer1.ReportSource = rpt_Programmer_Weekly;
            }


            if (MainForm.accessLevel.Contains("PROGRAMMER"))
            {
                rpt_Programmer_Weekly rpt_Programmer_Weekly = new rpt_Programmer_Weekly();
                // rpt_Programmer_Weekly.DataSourceConnections[0].SetConnection(CrystalReportConnection.strServer, CrystalReportConnection.strDatabase, CrystalReportConnection.strUserId, CrystalReportConnection.strPwd, true);
                rpt_Programmer_Weekly.DataSourceConnections[0].SetConnection(CrystalReportConnection.strServer, CrystalReportConnection.strDatabase, true);

                rpt_Programmer_Weekly.SetParameterValue("UserID", WelcomeForm.AccountID);
                rpt_Programmer_Weekly.SetParameterValue("monthName", ucSystemDevWeekly.printMonth);
                rpt_Programmer_Weekly.SetParameterValue("SystemTitle", ucSystemDevWeekly.PrintSystemTitle);

                DateTime date            = DateTime.Parse("01" + ucSystemDevWeekly.printMonth + ucSystemDevWeekly.printYear);
                var      firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
                var      lastDayOfMonth  = firstDayOfMonth.AddMonths(1).AddDays(-1);

                ParameterRangeValue myParameterRangeValue = new ParameterRangeValue();
                myParameterRangeValue.StartValue = firstDayOfMonth;
                myParameterRangeValue.EndValue   = lastDayOfMonth;
                rpt_Programmer_Weekly.SetParameterValue("Month", myParameterRangeValue);


                crystalReportViewer1.ReportSource = rpt_Programmer_Weekly;
            }
        }
Exemplo n.º 8
0
    private void SetParameter(ArrayList para)
    {
        ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
        ParameterRangeValue    rangeVal    = new ParameterRangeValue();
        ParameterValues        curvalues   = new ParameterValues();

        for (int i = 0; i < para.Count; i++)
        {
            discreteVal.Value = para[i];
            curvalues.Add(discreteVal);
            rpt1.DataDefinition.ParameterFields[i].ApplyCurrentValues(curvalues);
        }
    }
Exemplo n.º 9
0
 private void SetDateRangeForOrders(ReportDocument report, string startData, string endData, string name_parametre)
 {
     ParameterRangeValue param_ = new ParameterRangeValue();
     param_.StartValue = startData;
     param_.EndValue = endData;
     param_.LowerBoundType = RangeBoundType.BoundInclusive;
     param_.UpperBoundType = RangeBoundType.BoundInclusive;
     ParameterFieldDefinitions def_ = report.DataDefinition.ParameterFields;
     ParameterFieldDefinition paramDef_ = def_[name_parametre];
     paramDef_.IsOptionalPrompt = false;
     paramDef_.CurrentValues.Clear();
     paramDef_.CurrentValues.Add(param_);
     paramDef_.ApplyCurrentValues(paramDef_.CurrentValues);
 }
Exemplo n.º 10
0
        private void SetDateRangeForOrders(ReportDocument report, string startData, string endData, string name_parametre)
        {
            ParameterRangeValue param_ = new ParameterRangeValue();

            param_.StartValue     = startData;
            param_.EndValue       = endData;
            param_.LowerBoundType = RangeBoundType.BoundInclusive;
            param_.UpperBoundType = RangeBoundType.BoundInclusive;
            ParameterFieldDefinitions def_      = report.DataDefinition.ParameterFields;
            ParameterFieldDefinition  paramDef_ = def_[name_parametre];

            paramDef_.IsOptionalPrompt = false;
            paramDef_.CurrentValues.Clear();
            paramDef_.CurrentValues.Add(param_);
            paramDef_.ApplyCurrentValues(paramDef_.CurrentValues);
        }
Exemplo n.º 11
0
        private static void LoadReportForPeriodTest()
        {
            var jednostkaId = 1;
            var osobaId     = 1;
            var dataOd      = DateTime.Parse("2016-01-01");
            var dataDo      = DateTime.Parse("2017-12-01");



            var period = new ParameterRangeValue
            {
                StartValue = dataOd,
                EndValue   = dataDo,
            };

            var rpt = new ReportDocument();

            rpt.Load(@"Reports\ReportForPeriod.rpt");

            if (rpt.IsLoaded)
            {
                // Logowanie do bazy danych
                // rpt.SetDatabaseLogon("user", "password");

                // Przekazanie parametru
                rpt.SetParameterValue("Jednostka", jednostkaId);
                rpt.SetParameterValue("Osoba", osobaId);
                rpt.SetParameterValue("Okres", period);

                //rpt.SetParameterValue("DataOd", dataOd);
                //rpt.SetParameterValue("DataDo", dataDo);

                if (rpt.HasSavedData)
                {
                    rpt.Refresh();
                }

                rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "ReportForPeriod.pdf");
            }

            rpt.Close();

            rpt.Dispose();

            System.Diagnostics.Process.Start("ReportForPeriod.pdf");
        }
        private void btnPrintML_Click(object sender, EventArgs e)
        {
            daterangeML            = new ParameterRangeValue();
            daterangeML.StartValue = dtpDateFromML.Value;
            daterangeML.EndValue   = dtpDatetoML.Value;
            paramstatus            = cmbStatus.SelectedItem.ToString();
            if (rdnDateRange.Checked)
            {
                isDateRange = true;
            }
            else
            {
                isDateRange = false;
            }
            frmMemberListingReport frm = new frmMemberListingReport();

            frm.ShowDialog();
        }
Exemplo n.º 13
0
 private static void ProcessParameterValue(ParameterValue pv, XmlWriter xmlw, string value)
 {
     xmlw.WriteStartElement(value);
     xmlw.WriteAttributeString("Description", pv.Description);
     xmlw.WriteAttributeString("IsRange", pv.IsRange.ToStringSafe());
     xmlw.WriteAttributeString("Kind", pv.Kind.ToStringSafe());
     if (pv.IsRange)
     {
         ParameterRangeValue prv = (ParameterRangeValue)pv;
         xmlw.WriteAttributeString("EndValue", prv.EndValue.ToStringSafe());
         xmlw.WriteAttributeString("LowerBoundType", prv.LowerBoundType.ToStringSafe());
         xmlw.WriteAttributeString("StartValue", prv.StartValue.ToStringSafe());
         xmlw.WriteAttributeString("UpperBoundType", prv.UpperBoundType.ToStringSafe());
     }
     else
     {
         ParameterDiscreteValue pdv = (ParameterDiscreteValue)pv;
         xmlw.WriteAttributeString("Value", pdv.Value.ToStringSafe());
     }
     xmlw.WriteEndElement();
 }
Exemplo n.º 14
0
        private static void SetRangeParameterTest()
        {
            var beginDate = DateTime.Parse("2017-01-01");
            var endDate   = DateTime.Parse("2017-06-01");

            var rpt = new ReportDocument();

            rpt.Load(@"Reports\ReportForPeriod.rpt");

            if (rpt.IsLoaded)
            {
                var periodRangeValue = new ParameterRangeValue {
                    StartValue = beginDate, EndValue = endDate
                };

                rpt.SetParameterValue("Okres", periodRangeValue);

                rpt.ExportToDisk(ExportFormatType.PortableDocFormat, "ReportForPeriod.pdf");

                System.Diagnostics.Process.Start("ReportForPeriod.pdf");
            }
        }
Exemplo n.º 15
0
        private void DisplayReport()
        {
            DateTime dtStartDate = Convert.ToDateTime(txtStartDate.Text);
            DateTime dtEndDate   = Convert.ToDateTime(txtEndDate.Text);

            ParameterRangeValue myRangeValue = new ParameterRangeValue();

            myRangeValue.StartValue = dtStartDate; //txtDateStart.Text;
            myRangeValue.EndValue   = dtEndDate;

            try
            {
                oReportDocument.Load(Server.MapPath("~/Reports/ItemSummaryTransaction.rpt"));

                oReportDocument.SetParameterValue("DateRange", myRangeValue);
                oReportDocument.SetDatabaseLogon("sa", "p@ssw0rd");

                CrystalReportViewer1.ReportSource = oReportDocument;
            }
            catch
            {
            }
        }
Exemplo n.º 16
0
        public void CreateParameterCollection(ParameterFields parameterFields, Dictionary <string, string> paramValuesdictionary)
        {
            ParameterValues        parameterValues;
            ParameterDiscreteValue parameterDiscreteValue;
            ParameterField         parameterField;

            foreach (KeyValuePair <string, string> keyValuePair in paramValuesdictionary)
            {
                parameterValues = parameterFields[keyValuePair.Key].CurrentValues;
                string parameterSubText = keyValuePair.Value;

                if (parameterFields[keyValuePair.Key].DiscreteOrRangeKind == DiscreteOrRangeKind.RangeValue &&
                    (parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateParameter ||
                     parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateTimeParameter)
                    )
                {
                    ParameterRangeValue parameterRangeValue = new ParameterRangeValue();
                    int position = parameterSubText.IndexOf(" - ");

                    parameterRangeValue.EndValue = parameterSubText.Substring(position, parameterSubText.Length - position);
                    if (parameterRangeValue.EndValue.ToString() == "and up")
                    {
                        parameterRangeValue.EndValue       = DateTime.Today;
                        parameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
                    }
                    else
                    {
                        parameterRangeValue.EndValue       = Convert.ToDateTime(parameterRangeValue.EndValue);
                        parameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
                    }

                    parameterRangeValue.StartValue = parameterSubText.Substring(0, position - 1);
                    if (parameterRangeValue.StartValue.ToString() == "up to")
                    {
                        parameterRangeValue.StartValue     = DateTime.Today;
                        parameterRangeValue.UpperBoundType = RangeBoundType.NoBound;
                    }
                    else
                    {
                        parameterRangeValue.StartValue     = Convert.ToDateTime(parameterRangeValue.StartValue);
                        parameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
                    }

                    parameterValues.Add(parameterRangeValue);
                }
                else
                {
                    if (parameterFields[keyValuePair.Key].EnableAllowMultipleValue &&
                        keyValuePair.Value.Trim() != "All")
                    {
                        bool valid         = true;
                        int  position      = 0;
                        int  startPosition = 1;

                        if (parameterFields[keyValuePair.Key].ReportParameterType == ParameterType.StoreProcedureParameter)
                        {
                            string commaDelimList = string.Empty;
                            while (valid)
                            {
                                position = keyValuePair.Value.ToString().IndexOf(";", startPosition);
                                if (position == 0)
                                {
                                    parameterDiscreteValue       = new ParameterDiscreteValue();
                                    commaDelimList              += keyValuePair.Value.Substring(startPosition, keyValuePair.Value.Length);
                                    parameterDiscreteValue.Value = commaDelimList;

                                    parameterValues.Add(parameterDiscreteValue);
                                    return;
                                }
                                else
                                {
                                    commaDelimList += keyValuePair.Value.Substring(startPosition, position - startPosition) + ",";
                                    startPosition   = position + 1;
                                }
                            }
                        }
                        else
                        {
                            while (valid)
                            {
                                position = keyValuePair.Value.ToString().IndexOf(";", startPosition);
                                if (position == 0)
                                {
                                    parameterDiscreteValue       = new ParameterDiscreteValue();
                                    parameterDiscreteValue.Value = keyValuePair.Value.Substring(startPosition, keyValuePair.Value.Length);

                                    parameterValues.Add(parameterDiscreteValue);
                                    return;
                                }
                                else
                                {
                                    parameterDiscreteValue       = new ParameterDiscreteValue();
                                    parameterDiscreteValue.Value = keyValuePair.Value.Substring(startPosition, position - startPosition);

                                    parameterValues.Add(parameterDiscreteValue);
                                    startPosition = position + 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        parameterField         = parameterFields[keyValuePair.Key];
                        parameterValues        = parameterField.CurrentValues;
                        parameterDiscreteValue = new ParameterDiscreteValue();

                        if (
                            (parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateParameter ||
                             parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateTimeParameter)
                            &&
                            (parameterSubText == "up to" || parameterSubText == "and up")
                            )
                        {
                            parameterDiscreteValue.Value = "1/1/1900";
                        }
                        else
                        {
                            parameterDiscreteValue.Value = parameterSubText;
                        }

                        parameterValues.Add(parameterDiscreteValue);
                    }
                }
            }
        }
Exemplo n.º 17
0
        public void generateReport(List <int> jenisPembayaran, List <int> kurir, List <int> kategori, List <int> promo, DateTime awal, DateTime akhir, int isofficial)
        {
            AdminReport     report = new AdminReport();
            ParameterValues pv     = new ParameterValues();
            ReportView      rv     = new ReportView(report);

            getKurir();
            getJenisPembayaran();
            getKategori();
            getPromo();
            //awal = awal.AddDays(-1);
            //akhir = akhir.AddDays(1);

            pv.Clear();
            foreach (int i in jenisPembayaran)
            {
                DataRow dr = dtJenisPembayaran.Rows[i];
                pv.Add(getParamVal(dr["ID"].ToString()));
            }
            rv.setParam("payment_Methods", pv);
            pv.Clear();
            foreach (int i in kurir)
            {
                DataRow dr = dtKurir.Rows[i];
                pv.Add(getParamVal(dr["ID"].ToString()));
            }
            rv.setParam("Kurirs", pv);
            pv.Clear();
            foreach (int i in kategori)
            {
                DataRow dr = dtKategori.Rows[i];
                pv.Add(getParamVal(dr["ID"].ToString()));
            }
            rv.setParam("Categories", pv);
            pv.Clear();
            //foreach (int i in promo)
            //{
            //    DataRow dr = dtPromo.Rows[i];
            //    pv.Add(getParamVal(dr["ID"].ToString()));
            //}
            //rv.setParam("Promos", pv);
            //pv.Clear();

            string path = (ImageHelper.getDebugPath() + "\\Resource\\Items\\");

            pv.Add(getParamVal(path));
            rv.setParam("imageParam", pv);

            ParameterRangeValue paramTanggal = new ParameterRangeValue();

            // Setup nilai start
            paramTanggal.StartValue = awal;
            // Setup nilai end
            paramTanggal.EndValue = akhir;
            // pasang paramter tanggal saya ke dalam rpt
            rv.setParam("DateBetween", paramTanggal);
            rv.setParam("awal", awal);
            rv.setParam("akhir", akhir);
            pv.Clear();
            if (isofficial == 0)
            {
                pv.Add(getParamVal("0"));
                pv.Add(getParamVal("1"));
            }
            else if (isofficial == 1)
            {
                pv.Add(getParamVal("1"));
            }
            else
            {
                pv.Add(getParamVal("0"));
            }

            rv.setParam("SellerTypes", pv);

            rv.ShowDialog();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Sets up the report based on the generationItem and configureArgs. may or may not build the report
        /// </summary>
        /// <param name="generationItem">Description of the report to generate</param>
        /// <param name="configureArgs">report instance data</param>
        public void ConfigureReport(ReportGenerationItem generationItem,
                                    ReportGetDataSourceEventArgs getDataSourceArgs,
                                    Dictionary <string, List <ReportParameterValue> > parameterNamesToValueMap)
        {
            //get the configuration args
            this.getDataSourceArgs        = getDataSourceArgs;
            this.parameterNamesToValueMap = parameterNamesToValueMap;

            //need to set source before seting params
            foreach (ReportDocument doc in this.reportDocList)
            {
                doc.SetDataSource(this.getDataSourceArgs.DataSource);
            }

            //loop thru parameters that are set and set them into the crystal documnet
            foreach (ParameterField paramField in reportDocument.ParameterFields)
            {
                ParameterValues currentParameterValues = new ParameterValues();

                List <ReportParameterValue> objList;
                this.parameterNamesToValueMap.TryGetValue(paramField.Name, out objList);

                //convert all the data to a string and let crystal covert it to its known type
                for (int i = 0; i < objList.Count; i++)
                {
                    object val = objList[i].Value;
                    if (val == null)
                    {
                        continue;
                    }
                    object convertedObject = null;
                    convertedObject  = val.ToString();
                    objList[i].Value = convertedObject;

                    if (objList[i].EndValue != null)
                    {
                        objList[i].EndValue = objList[i].EndValue.ToString();
                    }
                }

                //create single or range crystal values
                foreach (ReportParameterValue paramVal in objList)
                {
                    if (paramVal.IsRange == false)
                    {
                        ParameterDiscreteValue pv = new ParameterDiscreteValue();
                        pv.Value = paramVal.Value;
                        currentParameterValues.Add(pv);
                    }
                    else
                    {
                        ParameterRangeValue pv = new ParameterRangeValue();
                        pv.StartValue = paramVal.Value;
                        pv.EndValue   = paramVal.EndValue;
                        currentParameterValues.Add(pv);
                    }
                }

                //apply the newly set parameter values to the document so they will be used in the generation
                ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
                ParameterFieldDefinition  parameterFieldDefinition  = parameterFieldDefinitions[paramField.Name];
                parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
            }
        }
Exemplo n.º 19
0
        /// check parameters prompting user for missing ones
        /// </summary>
        /// <param name="parameterNamesToValueMap"></param>
        /// <returns>true if can continue</returns>
        public bool ValidateParameters(Dictionary <string, List <ReportParameterValue> > parameterNamesToValueMap)
        {
            List <ParameterField> missingParamList = new List <ParameterField>();

            //loop thru parameters in crystal doc looking
            //for them in the paramNameValueMap
            foreach (ParameterField paramField in this.reportDocument.ParameterFields)
            {
                List <ReportParameterValue> objList;
                parameterNamesToValueMap.TryGetValue(paramField.Name, out objList);
                if (objList == null || objList.Count == 0)
                {
                    missingParamList.Add((ParameterField)paramField.Clone());
                }
            }

            //nithing is missing
            if (missingParamList.Count == 0)
            {
                return(true);
            }

            //prepare crystal prompting dialog to prompt user
            //for values. !!!RM their prompting dlg is messy probably need to do something else
            ParameterFields parameterFieldInfo = new ParameterFields();

            foreach (ParameterField missingField in missingParamList)
            {
                parameterFieldInfo.Add(missingField);
            }

            PromptingDialog dialog = new PromptingDialog();

            if (dialog.DoModal(null, parameterFieldInfo) == -1)
            {
                //user canceled the dialog so cannot continue
                return(false);
            }

            //fill the missing fields entered in the dialog into
            //the crystal document
            foreach (ParameterField missingField in missingParamList)
            {
                ParameterRangeValue    rangeValue    = missingField.CurrentValues[0] as ParameterRangeValue;
                ParameterDiscreteValue discreteValue = missingField.CurrentValues[0] as ParameterDiscreteValue;
                if (rangeValue != null)
                {
                    List <ReportParameterValue> objList  = new List <ReportParameterValue>();
                    ReportParameterValue        paramVal = new ReportParameterValue(rangeValue.StartValue, null);
                    paramVal.IsRange  = true;
                    paramVal.EndValue = rangeValue.EndValue;
                    objList.Add(paramVal);

                    parameterNamesToValueMap[missingField.Name] = objList;
                }
                else
                {
                    List <ReportParameterValue> objList = new List <ReportParameterValue>();
                    objList.Add(new ReportParameterValue(discreteValue.Value, null));

                    parameterNamesToValueMap[missingField.Name] = objList;
                }
            }

            //ok to continue with report generation since all fields are found
            return(true);
        }
Exemplo n.º 20
0
        public void CreateParameterCollection(ParameterFields parameterFields, Dictionary<string, string> paramValuesdictionary)
        {
            ParameterValues parameterValues;
            ParameterDiscreteValue parameterDiscreteValue;
            ParameterField parameterField;

            foreach (KeyValuePair<string, string> keyValuePair in paramValuesdictionary)
            {
                parameterValues = parameterFields[keyValuePair.Key].CurrentValues;
                string parameterSubText = keyValuePair.Value;

                if (parameterFields[keyValuePair.Key].DiscreteOrRangeKind == DiscreteOrRangeKind.RangeValue
                    && (parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateParameter
                        || parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateTimeParameter)
                    )
                {
                    ParameterRangeValue parameterRangeValue = new ParameterRangeValue();
                    int position = parameterSubText.IndexOf(" - ");

                    parameterRangeValue.EndValue = parameterSubText.Substring(position, parameterSubText.Length - position);
                    if (parameterRangeValue.EndValue.ToString() == "and up")
                    {
                        parameterRangeValue.EndValue = DateTime.Today;
                        parameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
                    }
                    else
                    {
                        parameterRangeValue.EndValue = Convert.ToDateTime(parameterRangeValue.EndValue);
                        parameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
                    }

                    parameterRangeValue.StartValue = parameterSubText.Substring(0, position - 1);
                    if (parameterRangeValue.StartValue.ToString() == "up to")
                    {
                        parameterRangeValue.StartValue = DateTime.Today;
                        parameterRangeValue.UpperBoundType = RangeBoundType.NoBound;
                    }
                    else
                    {
                        parameterRangeValue.StartValue = Convert.ToDateTime(parameterRangeValue.StartValue);
                        parameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive;
                    }

                    parameterValues.Add(parameterRangeValue);
                }
                else
                {
                    if (parameterFields[keyValuePair.Key].EnableAllowMultipleValue &&
                        keyValuePair.Value.Trim() != "All")
                    {
                        bool valid = true;
                        int position = 0;
                        int startPosition = 1;

                        if (parameterFields[keyValuePair.Key].ReportParameterType == ParameterType.StoreProcedureParameter)
                        {
                            string commaDelimList = string.Empty;
                            while (valid)
                            {
                                position = keyValuePair.Value.ToString().IndexOf(";", startPosition);
                                if (position == 0)
                                {
                                    parameterDiscreteValue = new ParameterDiscreteValue();
                                    commaDelimList += keyValuePair.Value.Substring(startPosition, keyValuePair.Value.Length);
                                    parameterDiscreteValue.Value = commaDelimList;

                                    parameterValues.Add(parameterDiscreteValue);
                                    return;
                                }
                                else
                                {
                                    commaDelimList += keyValuePair.Value.Substring(startPosition, position - startPosition) + ",";
                                    startPosition = position + 1;
                                }
                            }
                        }
                        else
                        {
                            while (valid)
                            {
                                position = keyValuePair.Value.ToString().IndexOf(";", startPosition);
                                if (position == 0)
                                {
                                    parameterDiscreteValue = new ParameterDiscreteValue();
                                    parameterDiscreteValue.Value = keyValuePair.Value.Substring(startPosition, keyValuePair.Value.Length);

                                    parameterValues.Add(parameterDiscreteValue);
                                    return;
                                }
                                else
                                {
                                    parameterDiscreteValue = new ParameterDiscreteValue();
                                    parameterDiscreteValue.Value = keyValuePair.Value.Substring(startPosition, position - startPosition);

                                    parameterValues.Add(parameterDiscreteValue);
                                    startPosition = position + 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        parameterField = parameterFields[keyValuePair.Key];
                        parameterValues = parameterField.CurrentValues;
                        parameterDiscreteValue = new ParameterDiscreteValue();

                        if (
                            (parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateParameter ||
                            parameterFields[keyValuePair.Key].ParameterValueType == ParameterValueKind.DateTimeParameter)
                            &&
                            (parameterSubText == "up to" || parameterSubText == "and up")
                            )
                        {
                            parameterDiscreteValue.Value = "1/1/1900";
                        }
                        else
                        {
                            parameterDiscreteValue.Value = parameterSubText;
                        }

                        parameterValues.Add(parameterDiscreteValue);
                    }
                }
            }
        }