Пример #1
1
        public Boolean printReport(CrystalDecisions.CrystalReports.Engine.ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param1, String ParamName1, String param2, String ParamName2)
        {
            if (PrinterName=="none") return false;

            paramField.ParameterFieldName = ParamName1;
            discreteVal.Value = param1;
            paramField.CurrentValues.Add (discreteVal);
            paramFields.Add (paramField);
            crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal);

            paramField2.ParameterFieldName = ParamName2;
            discreteVal2.Value = param2;
            paramField2.CurrentValues.Add (discreteVal2);
            paramFields.Add (paramField2);
            crReport.DataDefinition.ParameterFields[1].CurrentValues.Add (discreteVal2);

            CrystalReportViewer1.ReportSource = crReport;
            CrystalReportViewer1.ParameterFieldInfo = paramFields;
            CrystalReportViewer1.RefreshReport();

            ParameterValues tmpParam = new ParameterValues();
            ParameterValues tmpParam2 = new ParameterValues();
            tmpParam.Add(discreteVal);
            tmpParam2.Add(discreteVal2);
            crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(tmpParam);
            crReport.DataDefinition.ParameterFields[1].ApplyCurrentValues(tmpParam2);
            crReport.PrintOptions.PrinterName = PrinterName;
            //			crReport.PrintToPrinter(1,false,1,1);
            crReport.PrintToPrinter(1,false,1,99);

            //Response.write (PrinterName);
            return true;
        }
Пример #2
0
        private void GroupReport_Load(object sender, EventArgs e)
        {
            repDoc = new ReportDocument();
            ParameterFields rptParams;
            ParameterValues paramValues;
            ParameterDiscreteValue paramDiscreteValue;
            ParameterField paramField;

            try
            {
                repDoc.Load("../../Reports/Group.rpt");
                //repDoc.Load("C:\\Users\\keith.sullivan\\Documents\\CIS\\CISApp\\CISApp\\Reports\\Group.rpt");
                rptParams = repDoc.ParameterFields;
                paramValues = new ParameterValues();
                paramDiscreteValue = new ParameterDiscreteValue();
                paramDiscreteValue.Value = groupId;
                paramValues.Add(paramDiscreteValue);
                paramField = rptParams["studentgroup"];
                paramField.CurrentValues = paramValues;
                crystalReportViewer1.ReportSource = repDoc;
                crystalReportViewer1.Refresh();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine("Could not connect to report");
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var report = new rptTestimonial();

            ParameterValues pvValues = new ParameterValues();

            ParameterDiscreteValue pdvDiscreteValue = new ParameterDiscreteValue();

            pdvDiscreteValue.Value = textBox1.Text;

            pvValues.Add(pdvDiscreteValue);

            ParameterFieldDefinitions pfdDefinitions = report.DataDefinition.ParameterFields;

            ParameterFieldDefinition prdDefinition = pfdDefinitions["textThing"];

            prdDefinition.ApplyCurrentValues(pvValues);
            /*var data =
                Database.Row("learner_details a, enrollments b, enrollmentscourses c, courses d",
                             "a.Division = '" + clsGlobal.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                             number.Selection +
                             "' AND b.LearnerKey = a.LearnerKey AND c.idEnrollments = b.idEnrollments AND" +
                             " d.idCourses = c.idCourses");*/
            report.DataDefinition.FormulaFields["mainText"].Text = "\"" + textBox1.Text + "\"";
            report.DataDefinition.FormulaFields["principle"].Text = "\"" + GlobalProperties.DivisionPrinciple + "\"";
            report.DataDefinition.FormulaFields["name"].Text = "\"" +  learner["Surname"] + ", " + learner["name"]+ "\"";
            report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + number + "\"";
            //report.DataDefinition.FormulaFields["respParty"].Text = "\"" + clsGlobal.loggedOnUser + "\"";
            //report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";

            //logs.WriteXml(@"C:\tmpXml.xml");
            var frmReport = new frmReport(report) { Text = "Testimonial" };
            frmReport.ShowDialog();
        }
        private void FrmVisualizadorContrato_Load(object sender, EventArgs e)
        {
            //ReportDocument report = new ReportDocument();
            //report.Load("C:\\Users\\João\\Documents\\Video Aulas\\Canal Professor Drausion\\1° Temporada\\KISNER_EVENTOS\\Apresentacao\\Relatorios\\Contrato\\RelContrato.rpt");
            //string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
            //report.Load("\\Relatorios\\Contrato\\RelContrato.rpt");
            Relatorios.Contrato.RelContrato report = new Relatorios.Contrato.RelContrato();

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;
            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

            crParameterDiscreteValue.Value = codEvento;
            crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["ParCodEvento"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;
            //trabalhando com os brinquedos escolhidos pelo usuário! Usando DataSet
            /*Relatorios.Contrato.DsEventoBrinquedo eb = new Relatorios.Contrato.DsEventoBrinquedo();
            DataTable brinquedos = eb.Tables.Add("DtBrinquedo");

            brinquedos.Columns.Add("codBrinquedo", Type.GetType("System.Int32"));
            brinquedos.Columns.Add("nome", Type.GetType("System.String"));

            BrinquedoColecao bc = new BrinquedoColecao();
            */

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            crystalReportViewer1.ReportSource = report;
            crystalReportViewer1.Refresh();
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ReportDocument crystalrpt = new ReportDocument();
                crystalrpt.Load(@"C:\Users\Lahkrome\Desktop\Beta Sinergia\alfa2_Sinergia\CrystalReport.rpt");
                //crystalReportViewer1.ReportSource = crystalrpt;
                //crystalReportViewer1.Refresh();
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

                crParameterDiscreteValue.Value = textBox1.Text;
                crParameterFieldDefinitions = crystalrpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["ProductName"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                crystalReportViewer1.ReportSource = crystalrpt;
                crystalReportViewer1.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error"+ex);

            }
        }
Пример #6
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            
            ReportDocument report = new ReportDocument();

            report.Load(this.filePath);
            report.SetDatabaseLogon(userName, password, server, db);

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;
            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

            //order no
            crParameterDiscreteValue.Value = txtFilter.Text;
            crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["orderNo"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            //start date
            crParameterDiscreteValue.Value = dtpStartDate.Value;
            crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["startDate"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            //end date
            crParameterDiscreteValue.Value = dtpEndDate.Value;
            crParameterFieldDefinitions = report.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["endDate"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);


            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            crConnectionInfo.ServerName = server;
            crConnectionInfo.DatabaseName = db;
            crConnectionInfo.UserID = userName;
            crConnectionInfo.Password = password;

            TableLogOnInfo logOnInfo = new TableLogOnInfo();
            logOnInfo.ConnectionInfo = crConnectionInfo;
            
            TableLogOnInfos logOnInfos = new TableLogOnInfos();
            logOnInfos.Add(logOnInfo);
            crystalReportViewer.LogOnInfo = logOnInfos;
            crystalReportViewer.ReportSource = report;
            crystalReportViewer.Refresh();
        }
 public override AsimovTask GetDeployTask(AsimovVersion version, ParameterValues parameterValues, AsimovUser user, string correlationId)
 {
     var task = new DeployTask(this, version, parameterValues, user, correlationId);
     task.AddDeployStep<UpdateWebSite>();
     foreach (var action in Actions.OfType<VerifyCommandUnitAction>())
     {
         task.AddDeployStep(new ExecuteUnitAction(action, user));
     }
     return task;
 }
Пример #8
0
 private void SetCurrentValuesForParameterField(ParameterFields parameterFields, ArrayList arrayList)
 {
     ParameterValues currentParameterValues = new ParameterValues();
     foreach (object submittedValue in arrayList)
     {
         ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
         parameterDiscreteValue.Value = submittedValue.ToString();
         currentParameterValues.Add(parameterDiscreteValue);
     }
     ParameterField parameterField = parameterFields[PARAMETER_FIELD_NAME];
     parameterField.CurrentValues = currentParameterValues;
 }
Пример #9
0
        public void Read(string srr)
        {
            this.reportQuary = dateTimePicker1.Text + "  to  " + dateTimePicker2.Text;
            string query = "";

            query = "Select * From TbDailyIncome Where IncomeDate BETWEEN  '" + dateTimePicker1.Value.Date + "' AND  '" + dateTimePicker2.Value.Date + "' AND Debit = @Debit Order By IncomeDate";

            if (query != "")
            {

                SqlConnection conn = new SqlConnection(this.connectionString);
                SqlCommand comm = new SqlCommand(query, conn);

                comm.Parameters.Add("@Debit", SqlDbType.VarChar, 50);
                comm.Parameters["@Debit"].Value = comboBox1.Text;

                SqlDataAdapter adap = new SqlDataAdapter();
                DataSets.DebitVoucherDataSet dataset = new DataSets.DebitVoucherDataSet();
               DebitVoucherByDebitACCrystalReport crp = new DebitVoucherByDebitACCrystalReport();

                try
                {
                    conn.Open();
                    adap.SelectCommand = comm;
                    adap.Fill(dataset, "DataTable1");

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    conn.Close();
                }
                crp.SetDataSource(dataset);

                ParameterValues v = new ParameterValues();
                ParameterDiscreteValue dv = new ParameterDiscreteValue();

                dv = new ParameterDiscreteValue();
                dv.Value = this.reportQuary;
                v.Add(dv);
                crp.DataDefinition.ParameterFields["report_query"].ApplyCurrentValues(v);

                crystalReportViewer2.ReportSource = crp;
            }
        }
Пример #10
0
      private void load_pass(transaksiugd crystal, string val)
      {
         ParameterFieldDefinitions crParameterFieldDefinitions;
         ParameterFieldDefinition crParameterFieldDefinition;
         ParameterValues crParameterValues = new ParameterValues();
         ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

         crParameterDiscreteValue.Value = val;
         crParameterFieldDefinitions = crystal.DataDefinition.ParameterFields;
         crParameterFieldDefinition = crParameterFieldDefinitions["pasien"];
         crParameterValues = crParameterFieldDefinition.CurrentValues;

         crParameterValues.Clear();
         crParameterValues.Add(crParameterDiscreteValue);
         crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
      }
Пример #11
0
      private void load_pass(CrystalReportPass crystal, string val)
      {
         ParameterFieldDefinitions crParameterFieldDefinitions;
         ParameterFieldDefinition crParameterFieldDefinition;
         ParameterValues crParameterValues = new ParameterValues();
         ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

         crParameterDiscreteValue.Value = val;
         crParameterFieldDefinitions = crystal.DataDefinition.ParameterFields;
         crParameterFieldDefinition = crParameterFieldDefinitions["idresep"];
         crParameterValues = crParameterFieldDefinition.CurrentValues;

         crParameterValues.Clear();
         crParameterValues.Add(crParameterDiscreteValue);
         crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
      }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!SessionBox.CheckUserSession())
            {
                Response.Redirect("~/Admin/Login.aspx");
            }
            else
            {
                //load crystal report
                ReportDocument Report = new ReportDocument();
                Report.Load(Server.MapPath("Sales_Return.rpt "));
                //this.CrystalReportSource1.Report.FileName = Server.MapPath("Sales_order.rpt");

                TableLogOnInfo logOnInfo = new TableLogOnInfo();
                logOnInfo.ConnectionInfo.ServerName = "USER-3924AC2E56";
                logOnInfo.ConnectionInfo.DatabaseName = "MyData";
                logOnInfo.ConnectionInfo.UserID = "sa";
                logOnInfo.ConnectionInfo.Password = "******";
                //对报表中的每个表进行循环 
                for (int i = 0; i < Report.Database.Tables.Count; i++)
                {
                    Report.Database.Tables[i].ApplyLogOnInfo(logOnInfo);
                }

                //load param
                //CrystalDecisions.Web.Parameter param = new CrystalDecisions.Web.Parameter();
                //param.Name = "OrderID";
                //param.DefaultValue = Request.QueryString["TextBoxId"].ToString().Trim();

                //add param
                //this.CrystalReportSource1.Report.Parameters.Add(param);
                ParameterValues ParamValues = new ParameterValues();
                ParameterDiscreteValue ParamValue = new ParameterDiscreteValue();
                ParamValue.Value = Request.QueryString["TextBoxId"].ToString().Trim();
                ParamValues.Add(ParamValue);
                Report.DataDefinition.ParameterFields[0].ApplyCurrentValues(ParamValues);

                //bind
                this.CrystalReportViewer1.ReportSource = Report;
                //this.CrystalReportViewer1.ReportSourceID = this.CrystalReportSource1.ID;
                //關閉左邊
                this.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
                //強制安裝ActiveX
                CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
                this.CrystalReportViewer1.DataBind();
            }
        }
        public void AddParameter(string i_paramName, string i_paramValue, ParameterFields o_paramFields)
        {
            ParameterField paramField = new ParameterField();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
            ParameterValues paramValues = new ParameterValues();

            // Set the name of the parameter to modify.
            paramField.ParameterFieldName = i_paramName;

            // Set a value to the parameter.
            paramDiscreteValue.Value = i_paramValue;
            paramValues.Add(paramDiscreteValue);
            paramField.CurrentValues = paramValues;

            // Add the parameter to the ParameterFields collection.
            o_paramFields.Add(paramField);
            //      Return paramFields
        }
Пример #14
0
        public ModelOutput Run(ParameterValues parameters)
        {
            ModelOutput mf = new ModelOutput();

            LoadDimensions(parameters, mf);

            InitVariables(mf);

            ConnectBindings(mf);

            ConnectLeftoversToParameters(mf, parameters);

            RunComponents(mf);

            mf.SwitchOffChecks();

            return mf;
        }
Пример #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.reportQuary = dateTimePicker1.Text + "  to  " + dateTimePicker2.Text;
            string query = "";

            query = "Select * From tblBankStatement Where TransDate BETWEEN  '" + dateTimePicker1.Value.Date + "' AND  '" + dateTimePicker2.Value.Date + "' Order By AutoId";
            if (query != "")
            {

                SqlConnection conn = new SqlConnection(this.connectionString);
                SqlCommand comm = new SqlCommand(query, conn);

                SqlDataAdapter adap = new SqlDataAdapter();
                DataSets.BankDataSet dataset = new DataSets.BankDataSet();
                BankStatementCrystalReport crp = new BankStatementCrystalReport();

                try
                {
                    conn.Open();
                    adap.SelectCommand = comm;
                    adap.Fill(dataset, "DataTable1");
                    crp.SetDataSource(dataset);
                    ParameterValues v = new ParameterValues();
                    ParameterDiscreteValue dv = new ParameterDiscreteValue();

                    dv = new ParameterDiscreteValue();
                    dv.Value = this.reportQuary;
                    v.Add(dv);
                    crp.DataDefinition.ParameterFields["report_query"].ApplyCurrentValues(v);

                    crystalReportViewer2.ReportSource = crp;

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    conn.Close();
                }

            }
        }
Пример #16
0
        private ParameterFields AddParameter(string paramName, string paramValue, ParameterFields paramFields)
        {
            ParameterField paramField = new ParameterField();
            ParameterDiscreteValue paramDiscreteValue = new
            ParameterDiscreteValue();
            ParameterValues paramValues = new ParameterValues();

            // 设置要修改的参数的名称。
            paramField.ParameterFieldName = paramName;

            // 为该参数设置一个值。
            paramDiscreteValue.Value = paramValue;
            paramValues.Add(paramDiscreteValue);
            paramField.CurrentValues = paramValues;

            // 将该参数添加到 ParameterFields 集合中。
            paramFields.Add(paramField);
            return paramFields;
        }
Пример #17
0
        public void Read()
        {
            this.reportQuary = fromdateTimePicker.Text + "  to  " + todateTimePicker2.Text;
            string query = "";

            query = "Select * From TbAccountStatement Where CreateDate BETWEEN  '" + fromdateTimePicker.Value.Date + "' AND  '" + todateTimePicker2.Value.Date + "' Order By AutoId";
            if (query != "")
            {

                SqlConnection conn = new SqlConnection(this.connectionString);
                SqlCommand comm = new SqlCommand(query, conn);

                SqlDataAdapter adap = new SqlDataAdapter();
                AccountStatementDataSet dataset = new AccountStatementDataSet();
                AccountStatementCrystalReport crp = new AccountStatementCrystalReport();

                try
                {
                    conn.Open();
                    adap.SelectCommand = comm;
                    adap.Fill(dataset, "DataTable1");
                    crp.SetDataSource(dataset);
                    ParameterValues v = new ParameterValues();
                    ParameterDiscreteValue dv = new ParameterDiscreteValue();

                    dv = new ParameterDiscreteValue();
                    dv.Value = this.reportQuary;
                    v.Add(dv);
                    crp.DataDefinition.ParameterFields["report_query"].ApplyCurrentValues(v);

                    crystalReportViewer1.ReportSource = crp;

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Пример #18
0
        public void StartingDeploy(AsimovVersion newVersion, string logFileName, AsimovUser user, string correlationId, ParameterValues parameters)
        {
            DeployStatus = DeployStatus.Deploying;
            Version = new DeployedVersion
            {
                DeployTimestamp = DateTime.Now,
                VersionId = newVersion.Id,
                VersionNumber = newVersion.Number,
                VersionBranch = newVersion.Branch,
                VersionTimestamp = newVersion.Timestamp,
                VersionCommit = newVersion.Commit,
                LogFileName = logFileName,
                UserId = user.UserId,
                UserName = user.UserName,
                DeployFailed = false,
                CorrelationId = correlationId,
                Parameters = parameters.GetInternalDictionary()
            };

            NotificationPublisher.PublishNotifications(new DeployStartedEvent(Name, Version));
        }
        private void fmProjectCosting_Load(object sender, EventArgs e)
        {
            crystalReportViewer1.Top = 0;
            try
            {
                ReportDocument cryRpt = new ReportDocument();
                string dir = System.IO.Directory.GetCurrentDirectory();
                dir = "Default_ProjectCost.rpt";
                cryRpt.Load(dir);
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

                crParameterDiscreteValue.Value = orderid;
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["orderid"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                crystalReportViewer1.ReportSource = cryRpt;
                //crystalReportViewer1.RefreshReport();

            }
            catch (LogOnException)
            {
                MessageBox.Show("Incorrect Logon Parameters. Check your user name and password.");
            }
            catch (DataSourceException)
            {
                MessageBox.Show("An error has occurred while connecting to the database.");
            }
            catch (EngineException ex)
            {
                MessageBox.Show (ex.Message);
            }
        }
        private void setReport(string[] discretes, string[] values, ReportDocument reportSource)
        {
            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;
            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

            for (int i = 0; i < discretes.Length; i++)
            {
                crParameterDiscreteValue.Value = values[i];
                crParameterFieldDefinitions = reportSource.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions[discretes[i]];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
            }

            crystalReportViewer1.ReportSource = reportSource;
            crystalReportViewer1.Refresh();
        }
Пример #21
0
        private void button1_Click(object sender, EventArgs e)
        {
            CrystalReport5 xxx = new CrystalReport5();
            xxx.DataSourceConnections[0].SetConnection("THANH\\SQLEXPRESS","Po",true);
            MessageBox.Show(xxx.DataSourceConnections[0].DatabaseName);
            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;
            ParameterValues crParameterValues = new ParameterValues();

            ParameterFieldDefinitions crParameterFieldDefinitions1;
            ParameterFieldDefinition crParameterFieldDefinition1;
            ParameterValues crParameterValues1 = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
            ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();


            crParameterDiscreteValue.Value = "1001";
            crParameterFieldDefinitions = xxx.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["@Store_ID"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            crParameterDiscreteValue1.Value = textBox1.Text;
            crParameterFieldDefinitions1 = xxx.DataDefinition.ParameterFields;
            crParameterFieldDefinition1 = crParameterFieldDefinitions1["@Invoice_Number"];
            crParameterValues1 = crParameterFieldDefinition1.CurrentValues;

            crParameterValues1.Clear();
            crParameterValues1.Add(crParameterDiscreteValue1);
            crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);


            xxx.PrintToPrinter(1, true, 1, 1);
            crystalReportViewer1.ReportSource = xxx;
        }
        private void setReport(string[] discretes, string[] values, ReportDocument reportSource)
        {
            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;
            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
            reportSource.SetDatabaseLogon(dbo.getDatabaseInformationLogon()[2], dbo.getDatabaseInformationLogon()[3], dbo.getDatabaseInformationLogon()[0], dbo.getDatabaseInformationLogon()[1]);

            for (int i = 0; i < discretes.Length; i++)
            {
                crParameterDiscreteValue.Value = values[i];
                crParameterFieldDefinitions = reportSource.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions[discretes[i]];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
            }

            crv.ReportSource = reportSource;
            crv.Refresh();
        }
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //clsConexion a la base de datos
            MySqlConnection myclsConexion = new MySqlConnection(clsConexion.ConectionString);
            // Creando el command que ejecutare
            MySqlCommand myCommand = new MySqlCommand();
            // Creando el Data Adapter
            MySqlDataAdapter myAdapter = new MySqlDataAdapter();
            // Creando el String Builder
            StringBuilder sbQuery = new StringBuilder();
            // Otras variables del entorno
            string cWhere = " WHERE 1 = 1";
            string cUsuario = frmLogin.cUsuarioActual;
            string cTitulo = "";

            try
            {
                // Abro clsConexion
                myclsConexion.Open();
                // Creo comando
                myCommand = myclsConexion.CreateCommand();
                // Adhiero el comando a la clsConexion
                myCommand.Connection = myclsConexion;
                // Filtros de la busqueda
                // CREANDO EL QUERY DE CONSULTA
                //string fechadesde = fechaDesde.Value.ToString("yyyy-MM-dd");
                //string fechahasta = fechaHasta.Value.ToString("yyyy-MM-dd");
                //cWhere = cWhere + " AND fechacita >= "+"'"+ fechadesde +"'" +" AND fechacita <= "+"'"+ fechahasta +"'"+"";
                //cWhere = cWhere + " AND year = '" + txtYear.Text + "'";
                sbQuery.Clear();
                sbQuery.Append("SELECT estaciones.id, estaciones.estacion as estaciones ");
                //sbQuery.Append(" tipo_deptogas.tipo as tipodescripcion, tipo_deptogas.id, deptobeneficiariogas.tarjeta");
                sbQuery.Append(" FROM estaciones ");
                //sbQuery.Append(" INNER JOIN tipo_deptogas ON tipo_deptogas.id = deptobeneficiariogas.tipo");
                sbQuery.Append(cWhere);
                sbQuery.Append(" ORDER BY estaciones.estacion ASC");

                // Paso los valores de sbQuery al CommandText
                myCommand.CommandText = sbQuery.ToString();

                // Creo el objeto Data Adapter y ejecuto el command en el
                myAdapter = new MySqlDataAdapter(myCommand);

                // Creo el objeto Data Table
                DataTable dtEstaciones = new DataTable();

                // Lleno el data adapter
                myAdapter.Fill(dtEstaciones);

                // Cierro el objeto clsConexion
                myclsConexion.Close();

                // Verifico cantidad de datos encontrados
                int nRegistro = dtEstaciones.Rows.Count;
                if (nRegistro == 0)
                {
                    MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema de Gestion de Combustibles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //1ero.HACEMOS LA COLECCION DE PARAMETROS
                    //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                    ParameterFields oParametrosCR = new ParameterFields();
                    //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                    ParameterValues oParametrosValuesCR = new ParameterValues();

                    //2do.CREAMOS LOS PARAMETROS
                    ParameterField oUsuario = new ParameterField();
                    //parametervaluetype especifica el TIPO de valor de parametro
                    //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                    oUsuario.ParameterValueType = ParameterValueKind.StringParameter;

                    //3ero.VALORES PARA LOS PARAMETROS
                    //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de
                    //parametros de valores discretos
                    ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                    oUsuarioDValue.Value = cUsuario;

                    //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                    oUsuario.CurrentValues.Add(oUsuarioDValue);

                    //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION
                    oParametrosCR.Add(oUsuario);
                    //nombre del parametro en CR (Crystal Reports)
                    oParametrosCR[0].Name = "cUsuario";
                    //nombre del TITULO DEL INFORME
                    cTitulo = "LISTADO DE ESTACIONES DE COMBUSTIBLE";

                    //6to Instanciamos nuestro REPORTE
                    //Reportes.ListadoDoctores oListado = new Reportes.ListadoDoctores();
                    //REPORTES.rptClientes orptClientes = new REPORTES.rptClientes();
                    rptEstaciones orptEstaciones = new rptEstaciones();

                    //pasamos el nombre del TITULO del Listado
                    //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                    // oListado.SummaryInfo.ReportTitle = cTitulo;
                    orptEstaciones.SummaryInfo.ReportTitle = cTitulo;

                    //7mo. instanciamos nuestro el FORMULARIO donde esta nuestro ReportViewer
                    frmPrinter ofrmPrinter = new frmPrinter(dtEstaciones, orptEstaciones, cTitulo);
                    //ParameterFieldInfo Obtiene o establece la colección de campos de parámetros.
                    ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                    ofrmPrinter.ShowDialog();
                }
            }
            catch (Exception myEx)
            {
                MessageBox.Show("Error : " + myEx.Message, "Mostrando Reporte", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                // clsExceptionLog.LogError(myEx, false);
                return;
            }
        }
Пример #24
0
 protected override IEnumerable <ISearchResultModel> GetResultIsLatestBySqlQuery(string sqlString)
 {
     return(DbManager.SqlQuery <SearchResultIsLatest>(sqlString, ParameterValues.ToArray()).ToList());
 }
Пример #25
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //clsConexion a la base de datos
            MySqlConnection myclsConexion = new MySqlConnection(Conexion.ConectionString);
            // Creando el command que ejecutare
            MySqlCommand myCommand = new MySqlCommand();
            // Creando el Data Adapter
            MySqlDataAdapter myAdapter = new MySqlDataAdapter();
            // Creando el String Builder
            StringBuilder sbQuery = new StringBuilder();
            // Otras variables del entorno
            string cWhere   = " WHERE 1 = 1";
            string cUsuario = ""; //frmLogin.cUsuarioActual;
            string cTitulo  = "";

            try
            {
                // Abro clsConexion
                myclsConexion.Open();
                // Creo comando
                myCommand = myclsConexion.CreateCommand();
                // Adhiero el comando a la clsConexion
                myCommand.Connection = myclsConexion;
                // Filtros de la busqueda
                //if (txtYear.Text != "")
                //{
                //// Habilitando los campos necesarios
                //txtYear.Enabled = true;
                //txtYear.Focus();

                // CREANDO EL QUERY DE CONSULTA
                //string fechadesde = fechaDesde.Value.ToString("yyyy-MM-dd");
                //string fechahasta = fechaHasta.Value.ToString("yyyy-MM-dd");
                //cWhere = cWhere + " AND fechacita >= "+"'"+ fechadesde +"'" +" AND fechacita <= "+"'"+ fechahasta +"'"+"";
                //cWhere = cWhere + " AND year = '" + txtYear.Text + "'";
                sbQuery.Clear();
                sbQuery.Append("SELECT subcategorias.id as Id, subcategorias.descripcion as Descripcion, categorias.descripcion as Categoria");
                //sbQuery.Append(" doctores.doctores_cedula,upper(CONCAT(doctores.doctores_nombre,' ',doctores.doctores_apellido)) as doctor,departamentos.departamento_descripcion");
                sbQuery.Append(" FROM subcategorias");
                sbQuery.Append(" INNER JOIN categorias ON subcategorias.categoria = categorias.id");
                sbQuery.Append(cWhere);
                sbQuery.Append(" ORDER BY categorias.descripcion, subcategorias.descripcion ASC");

                // Paso los valores de sbQuery al CommandText
                myCommand.CommandText = sbQuery.ToString();

                // Creo el objeto Data Adapter y ejecuto el command en el
                myAdapter = new MySqlDataAdapter(myCommand);

                // Creo el objeto Data Table
                DataTable dtSubcategoriasProductos = new DataTable();

                // Lleno el data adapter
                myAdapter.Fill(dtSubcategoriasProductos);

                // Cierro el objeto clsConexion
                myclsConexion.Close();

                // Verifico cantidad de datos encontrados
                int nRegistro = dtSubcategoriasProductos.Rows.Count;
                if (nRegistro == 0)
                {
                    MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema de Gestion Bananera", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //1ero.HACEMOS LA COLECCION DE PARAMETROS
                    //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                    ParameterFields oParametrosCR = new ParameterFields();
                    //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                    ParameterValues oParametrosValuesCR = new ParameterValues();

                    //2do.CREAMOS LOS PARAMETROS
                    ParameterField oUsuario = new ParameterField();
                    //parametervaluetype especifica el TIPO de valor de parametro
                    //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                    oUsuario.ParameterValueType = ParameterValueKind.StringParameter;

                    //3ero.VALORES PARA LOS PARAMETROS
                    //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de
                    //parametros de valores discretos
                    ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                    oUsuarioDValue.Value = cUsuario;

                    //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                    oUsuario.CurrentValues.Add(oUsuarioDValue);

                    //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION
                    oParametrosCR.Add(oUsuario);
                    //nombre del parametro en CR (Crystal Reports)
                    oParametrosCR[0].Name = "cUsuario";
                    //nombre del TITULO DEL INFORME
                    cTitulo = "LISTADO DE SUB-CATEGORIAS DE PRODUCTOS";

                    //6to Instanciamos nuestro REPORTE
                    //Reportes.ListadoDoctores oListado = new Reportes.ListadoDoctores();
                    REPORTES.rptSubCategorias orptSubCategoriasProductos = new REPORTES.rptSubCategorias();
                    //pasamos el nombre del TITULO del Listado
                    //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                    // oListado.SummaryInfo.ReportTitle = cTitulo;
                    orptSubCategoriasProductos.SummaryInfo.ReportTitle = cTitulo;

                    //7mo. instanciamos nuestro el FORMULARIO donde esta nuestro ReportViewer
                    frmPrinter ofrmPrinter = new frmPrinter(dtSubcategoriasProductos, orptSubCategoriasProductos, cTitulo);
                    //ParameterFieldInfo Obtiene o establece la colección de campos de parámetros.
                    ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                    ofrmPrinter.ShowDialog();
                }

                //}
                //else
                //{
                //    MessageBox.Show("No se puede realizar busqueda con campos vacios...");
                //    txtYear.Focus();
                //}
            }
            catch (Exception myEx)
            {
                MessageBox.Show("Error : " + myEx.Message, "Mostrando Reporte", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                // clsExceptionLog.LogError(myEx, false);
                return;
            }
        }
Пример #26
0
        private void frmRVentaProductoCaja_Load(object sender, EventArgs e)
        {
            try
            {
                string   bandera     = frmReporteVentaCliente.f1.lblBandera.Text;
                string   fechaInicio = "";
                string   fechaFin    = "";
                DateTime fecIn;
                if (bandera == "1")
                {
                    fechaInicio = frmReporteVentaCliente.f1.dtpFechaInicio.Value.ToString("yyyy-MM-dd" + " 00:00:00");
                    fechaFin    = frmReporteVentaCliente.f1.dtpFechaFin.Value.ToString("yyyy-MM-dd" + " 23:59:59");
                }
                else
                {
                    fecIn       = Convert.ToDateTime(frmPrincipal.f1.lblFechaApertura.Text);
                    fechaInicio = fecIn.ToString("yyyy-MM-dd HH:mm:ss");

                    fechaFin = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                int idProducto = Convert.ToInt32(frmReporteVentasProducto.f1.cbProducto.SelectedValue);
                int nroCaja    = Convert.ToInt32(frmReporteVentasProducto.f1.lblCaja.Text);

                ReportDocument repdoc = new ReportDocument();
                repdoc.Load(@"C:\Users\vioma\OneDrive\Documentos\Visual Studio 2017\Projects\SISTEMAUCHPA_Barra1\CapaPresentacion\Reportes/RVentaProductoCaja.rpt");
                //repdoc.Load(@"E:\Reportes\RVentaProducto.rpt");

                ParameterFieldDefinitions pfds;
                ParameterFieldDefinition  pfd;

                ParameterValues        pvs = new ParameterValues();
                ParameterDiscreteValue pdv = new ParameterDiscreteValue();

                pdv.Value = Convert.ToDateTime(fechaInicio + " 00:00:00");
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaInicio"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);


                pdv.Value = Convert.ToDateTime(fechaFin + " 23:59:59");
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaFin"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                pdv.Value = idProducto;
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@idProducto"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                pdv.Value = nroCaja;
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@nroCaja"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo  crtableLogoninfo  = new TableLogOnInfo();
                ConnectionInfo  crConnectionInfo  = new ConnectionInfo();
                Tables          CrTables;
                crConnectionInfo.ServerName   = @"UCHPABAR\SQLUCHPA";
                crConnectionInfo.DatabaseName = "db_SISTEMAUCHPA";
                crConnectionInfo.UserID       = "sa";
                crConnectionInfo.Password     = "******";

                CrTables = repdoc.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }


                cvVentas.ReportSource = repdoc;
                cvVentas.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show("ERROR" + ex);
            }
        }
Пример #27
0
        private void SetParameters(ReportDocument Report)
        {
            DateTime dteRetValue = Constants.C_DATE_MIN_VALUE;

            ParameterFieldDefinition paramField;
            ParameterValues          currentValues;
            ParameterDiscreteValue   discreteParam;

            paramField          = Report.DataDefinition.ParameterFields["CompanyName"];
            discreteParam       = new ParameterDiscreteValue();
            discreteParam.Value = CompanyDetails.CompanyName;
            currentValues       = new ParameterValues();
            currentValues.Add(discreteParam);
            paramField.ApplyCurrentValues(currentValues);

            paramField          = Report.DataDefinition.ParameterFields["PrintedBy"];
            discreteParam       = new ParameterDiscreteValue();
            discreteParam.Value = Session["Name"].ToString();
            currentValues       = new ParameterValues();
            currentValues.Add(discreteParam);
            paramField.ApplyCurrentValues(currentValues);

            switch (cboReportType.SelectedItem.Value)
            {
            case ReportTypes.CREDITS_Purchases:
                #region purchases
                paramField          = Report.DataDefinition.ParameterFields["CreditCardTypeName"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = cboCreditType.SelectedItem.Text;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["PurchaseStartDate"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = DateTime.TryParse(txtTrxStartDate.Text, out dteRetValue) ? dteRetValue.ToString("yyyy-MM-dd") : Constants.C_DATE_MIN_VALUE.ToString("yyyy-MM-dd");
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["PurchaseEndDate"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = DateTime.TryParse(txtTrxEndDate.Text, out dteRetValue) ? dteRetValue.ToString("yyyy-MM-dd") : Constants.C_DATE_MIN_VALUE.ToString("yyyy-MM-dd");
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);
                #endregion
                break;

            case ReportTypes.CREDITS_Payments:
                #region payments

                paramField          = Report.DataDefinition.ParameterFields["CreditCardTypeName"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = cboCreditType.SelectedItem.Text;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["PaymentStartDate"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = DateTime.TryParse(txtTrxStartDate.Text, out dteRetValue) ? dteRetValue.ToString("yyyy-MM-dd") : Constants.C_DATE_MIN_VALUE.ToString("yyyy-MM-dd");
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["PaymentEndDate"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = DateTime.TryParse(txtTrxEndDate.Text, out dteRetValue) ? dteRetValue.ToString("yyyy-MM-dd") : Constants.C_DATE_MIN_VALUE.ToString("yyyy-MM-dd");
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);
                #endregion
                break;

            case ReportTypes.CREDITS_CreditorsLedgerSummary:
                #region ledger summary
                paramField          = Report.DataDefinition.ParameterFields["CreditCardTypeName"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = cboCreditType.SelectedItem.Text;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                Data.CreditBills       clsCreditBills       = new Data.CreditBills();
                Data.CreditBillDetails clsCreditBillDetails = clsCreditBills.Details(CreditType.Individual, DateTime.Parse(cboBillingDate.SelectedItem.Value), Int16.Parse(cboCreditType.SelectedItem.Value));
                clsCreditBills.CommitAndDispose();

                paramField          = Report.DataDefinition.ParameterFields["CreditPurcStartDateToProcess"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = clsCreditBillDetails.CreditPurcStartDateToProcess;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["CreditPurcEndDateToProcess"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = clsCreditBillDetails.CreditPurcEndDateToProcess;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["PaymentDueDate"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = clsCreditBillDetails.CreditPaymentDueDate;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["BillingDate"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = DateTime.Parse(cboBillingDate.SelectedItem.Value);
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField          = Report.DataDefinition.ParameterFields["ShowDetails"];
                discreteParam       = new ParameterDiscreteValue();
                discreteParam.Value = true;
                currentValues       = new ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                #endregion
                break;

            default:
                break;
            }
        }
Пример #28
0
    public static ReportDocument SetReportDoc(double top, double bottom, double left, double right, int printCount, params string[] nums)
    {
        ReportDocument doc = new ReportDocument();

        try
        {
            string ReportPath = nums[0].ToString();
            doc.Load(ReportPath);
            for (int i = 3; i < nums.Length; i++)
            {
                string paramValue          = nums[i].ToString();
                ParameterDiscreteValue pdv = new ParameterDiscreteValue();
                pdv.Value = paramValue;
                ParameterValues pv = new ParameterValues();
                pv.Add(pdv);
                doc.DataDefinition.ParameterFields[i - 3].ApplyCurrentValues(pv);
            }
            if (doc.Database.Tables.Count > 0)
            {
                //for (int i = 0; i < doc.Database.Tables.Count; i++)
                //{
                //    doc.Database.Tables[i].ApplyLogOnInfo(LoginInfo());
                //}
                doc.Database.Tables[0].ApplyLogOnInfo(LoginInfo());
            }

            string msgStr = "【" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "】  加载报表 \r\n";
            PrinterLOG.WriterLog(msgStr, nums[2], false);

            //Sections sections = doc.ReportDefinition.Sections;
            //foreach (Section section in sections)
            //{
            //    ReportObjects reportObjects = section.ReportObjects;
            //    foreach (ReportObject reportObject in reportObjects)
            //    {
            //        if (reportObject.Kind == ReportObjectKind.SubreportObject)
            //        {
            //            SubreportObject subreportObject = (SubreportObject)reportObject;
            //            ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
            //            if (subReportDocument.Database.Tables.Count > 0)
            //            {
            //                for (int i = 0; i < subReportDocument.Database.Tables.Count; i++)
            //                {
            //                    subReportDocument.Database.Tables[i].ApplyLogOnInfo(LoginInfo());
            //                }
            //                //subReportDocument.Database.Tables[0].ApplyLogOnInfo(LoginInfo());
            //            }
            //        }
            //    }
            //}

            //打印机名字
            doc.PrintOptions.PrinterName = nums[2].ToString();

            //设置打印边距
            PageMargins margins;
            margins              = doc.PrintOptions.PageMargins;
            margins.topMargin    = Convert.ToInt32(top * 567); //567
            margins.leftMargin   = Convert.ToInt32(left * 567);
            margins.rightMargin  = Convert.ToInt32(right * 567);
            margins.bottomMargin = Convert.ToInt32(bottom * 567);
            doc.PrintOptions.ApplyPageMargins(margins);

            if (nums[1].ToString().StartsWith("Y"))
            {
                //if (nums[1].ToString() == "Y1")
                //{
                //    doc.PrintOptions.PaperSize = PaperSize.PaperA4;
                //}
                //else
                //{
                //    doc.PrintOptions.PaperOrientation = PaperOrientation.DefaultPaperOrientation;
                //    doc.PrintOptions.PaperSize = PaperSize.DefaultPaperSize;
                //}

                //打印份数,是否逐份打印,打印第一页,最后一页
                if (printCount > 20)
                {
                    printCount = 1;
                }
                doc.PrintToPrinter(printCount, false, 0, 0);
            }
        }
        catch (Exception exp)
        {
            PrinterLOG.WriterLog(exp.Message, nums[2].ToString(), true);
            doc = null;
        }
        return(doc);
    }
Пример #29
0
        private void addDefaultPercentileFor(ParameterValues parameterValues)
        {
            var allPercentiles = new double[parameterValues.Values.Count].InitializeWith(CoreConstants.DEFAULT_PERCENTILE);

            addPercentileValues(parameterValues, allPercentiles);
        }
Пример #30
0
        private void TransactionsReportFrom_Load(object sender, EventArgs e)
        {
            string                 str;
            ReportDocument         reportDocument;
            ReportDataTable        reportDataTable;
            ParameterValues        parameterValue;
            ParameterDiscreteValue parameterDiscreteValue;
            ParameterValues        parameterValue2;
            ParameterDiscreteValue parameterDiscreteValue2;
            ParameterValues        parameterValue3;
            ParameterDiscreteValue parameterDiscreteValue3;
            ParameterValues        parameterValue4;
            ParameterDiscreteValue parameterDiscreteValue4;
            ReportDocument         reportDocument2;
            ParameterValues        parameterValue5;
            ParameterDiscreteValue parameterDiscreteValue5;
            ParameterValues        parameterValue6;
            ParameterDiscreteValue parameterDiscreteValue6;
            ReportDocument         reportDocument3;
            ParameterValues        parameterValue7;
            ParameterDiscreteValue parameterDiscreteValue7;
            ParameterValues        parameterValue8;
            ParameterDiscreteValue parameterDiscreteValue8;
            ReportDocument         reportDocument4;
            ParameterValues        parameterValue9;
            ParameterDiscreteValue parameterDiscreteValue9;
            ParameterValues        parameterValue10;
            ParameterDiscreteValue parameterDiscreteValue10;
            ReportDocument         reportDocument5;
            AccountsViewDataTable  accountsViewDataTable;
            ReportDocument         reportDocument6;
            ReportDocument         reportDocument7;
            ReportDocument         reportDocument8;
            ParameterValues        parameterValue11;
            ParameterDiscreteValue parameterDiscreteValue11;
            ParameterValues        parameterValue12;
            ParameterDiscreteValue parameterDiscreteValue12;
            AccountsBLL            accountsBLL = new AccountsBLL();

            Cursor.Current   = Cursors.WaitCursor;
            base.WindowState = FormWindowState.Maximized;
            switch (this.reportType)
            {
            case ReportType.TrialBalance:
            {
                this.set_Text("ميزان المراجعة");
                reportDocument3 = new ReportDocument();
                reportDocument3.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\TrialBalanceCR.rpt"));
                reportDocument3.SetDataSource(this._reportBll.getTrialBalance(this.From, this.To));
                parameterValue7         = new ParameterValues();
                parameterDiscreteValue7 = new ParameterDiscreteValue();
                parameterDiscreteValue7.set_Value(this.From);
                parameterValue7.Add(parameterDiscreteValue7);
                reportDocument3.DataDefinition.ParameterFields["from"].ApplyCurrentValues(parameterValue7);
                parameterValue8         = new ParameterValues();
                parameterDiscreteValue8 = new ParameterDiscreteValue();
                parameterDiscreteValue8.set_Value(this.To);
                parameterValue8.Add(parameterDiscreteValue8);
                reportDocument3.DataDefinition.ParameterFields["to"].ApplyCurrentValues(parameterValue8);
                this.crViewer.set_ReportSource(reportDocument3);
            }

            case ReportType.BalanceSheet:
            {
                this.set_Text("الميزانية العمومية");
                reportDocument4 = new ReportDocument();
                reportDocument4.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\BalanceSheetCR.rpt"));
                reportDocument4.SetDataSource(this._reportBll.getBalanceSheet(this.From, this.To));
                parameterValue9         = new ParameterValues();
                parameterDiscreteValue9 = new ParameterDiscreteValue();
                parameterDiscreteValue9.set_Value(this.From);
                parameterValue9.Add(parameterDiscreteValue9);
                reportDocument4.DataDefinition.ParameterFields["from"].ApplyCurrentValues(parameterValue9);
                parameterValue10         = new ParameterValues();
                parameterDiscreteValue10 = new ParameterDiscreteValue();
                parameterDiscreteValue10.set_Value(this.To);
                parameterValue10.Add(parameterDiscreteValue10);
                reportDocument4.DataDefinition.ParameterFields["to"].ApplyCurrentValues(parameterValue10);
                this.crViewer.set_ReportSource(reportDocument4);
            }

            case ReportType.Transactions:
            {
                this.set_Text("كشف حركة حساب");
                str            = accountsBLL.GetAccountByID(this.account)[0].GL_Name_VC;
                reportDocument = new ReportDocument();
                reportDocument.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\reportTest.rpt"));
                reportDataTable = this._reportBll.getByCodeDate(this.From, this.To, this.account);
                reportDocument.SetDataSource(reportDataTable);
                parameterValue         = new ParameterValues();
                parameterDiscreteValue = new ParameterDiscreteValue();
                parameterDiscreteValue.set_Value(str);
                parameterValue.Add(parameterDiscreteValue);
                reportDocument.DataDefinition.ParameterFields["account"].ApplyCurrentValues(parameterValue);
                parameterValue2         = new ParameterValues();
                parameterDiscreteValue2 = new ParameterDiscreteValue();
                parameterDiscreteValue2.set_Value(this.From);
                parameterValue2.Add(parameterDiscreteValue2);
                reportDocument.DataDefinition.ParameterFields["dtFrom"].ApplyCurrentValues(parameterValue2);
                parameterValue3         = new ParameterValues();
                parameterDiscreteValue3 = new ParameterDiscreteValue();
                parameterDiscreteValue3.set_Value(this.To);
                parameterValue3.Add(parameterDiscreteValue3);
                reportDocument.DataDefinition.ParameterFields["dtTo"].ApplyCurrentValues(parameterValue3);
                parameterValue4         = new ParameterValues();
                parameterDiscreteValue4 = new ParameterDiscreteValue();
                parameterDiscreteValue4.set_Value(reportDataTable[reportDataTable.Count - 1].Balance);
                parameterValue4.Add(parameterDiscreteValue4);
                reportDocument.DataDefinition.ParameterFields["tBalance"].ApplyCurrentValues(parameterValue4);
                this.crViewer.set_ReportSource(reportDocument);
            }

            case ReportType.ProfitAndLoss:
            {
                this.set_Text("بيان الأرباح والخسائر");
                reportDocument2 = new ReportDocument();
                reportDocument2.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\ProfitLossCR.rpt"));
                reportDocument2.SetDataSource(this._reportBll.getProfitAndLoss(this.From, this.To));
                parameterValue5         = new ParameterValues();
                parameterDiscreteValue5 = new ParameterDiscreteValue();
                parameterDiscreteValue5.set_Value(this.From);
                parameterValue5.Add(parameterDiscreteValue5);
                reportDocument2.DataDefinition.ParameterFields["from"].ApplyCurrentValues(parameterValue5);
                parameterValue6         = new ParameterValues();
                parameterDiscreteValue6 = new ParameterDiscreteValue();
                parameterDiscreteValue6.set_Value(this.To);
                parameterValue6.Add(parameterDiscreteValue6);
                reportDocument2.DataDefinition.ParameterFields["to"].ApplyCurrentValues(parameterValue6);
                this.crViewer.set_ReportSource(reportDocument2);
            }

            case ReportType.Accounts:
            {
                this.set_Text("كشف أرصدة مجموعة حسابات");
                reportDocument5 = new ReportDocument();
                reportDocument5.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\AccountsCR.rpt"));
                accountsViewDataTable = new AccountsBLL().GetAccountsView();
                reportDocument5.SetDataSource(accountsViewDataTable);
                this.crViewer.set_ReportSource(reportDocument5);
                this.set_Text("الموظفون");
                reportDocument6 = new ReportDocument();
                reportDocument6.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\EmployeeCR.rpt"));
                reportDocument6.SetDataSource(new EmployeeBll().getEmployee());
                this.crViewer.set_ReportSource(reportDocument6);
                this.set_Text("الموردون");
                reportDocument7 = new ReportDocument();
                reportDocument7.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\SupplierCR.rpt"));
                reportDocument7.SetDataSource(new SupplierBll().getSuppliers());
                this.crViewer.set_ReportSource(reportDocument7);
                this.set_Text("مجمع الإهلاك");
                reportDocument8 = new ReportDocument();
                reportDocument8.Load(string.Concat(Path.GetDirectoryName(Application.ExecutablePath), "\\fixedCR.rpt"));
                reportDocument8.SetDataSource(this._reportBll.FixedAssetsReport(this.From, this.To));
                parameterValue11         = new ParameterValues();
                parameterDiscreteValue11 = new ParameterDiscreteValue();
                parameterDiscreteValue11.set_Value(this.From);
                parameterValue11.Add(parameterDiscreteValue11);
                reportDocument8.DataDefinition.ParameterFields["from"].ApplyCurrentValues(parameterValue11);
                parameterValue12         = new ParameterValues();
                parameterDiscreteValue12 = new ParameterDiscreteValue();
                parameterDiscreteValue12.set_Value(this.To);
                parameterValue12.Add(parameterDiscreteValue12);
                reportDocument8.DataDefinition.ParameterFields["to"].ApplyCurrentValues(parameterValue12);
                this.crViewer.set_ReportSource(reportDocument8);
                goto;
            }

            case ReportType.None:
            {
                this.set_Cursor(Cursors.Default);
                return;
            }
            }
        }
Пример #31
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //Conexion a la base de datos
            MySqlConnection myConexion = new MySqlConnection(clsConexion.ConectionString);
            // Creando el command que ejecutare
            MySqlCommand myCommand = new MySqlCommand();
            // Creando el Data Adapter
            MySqlDataAdapter myAdapter = new MySqlDataAdapter();
            // Creando el String Builder
            StringBuilder sbQuery = new StringBuilder();
            // Otras variables del entorno
            string cWhere   = " WHERE 1 = 1";
            string cUsuario = "";
            string cTitulo  = "";

            if (rbDespachada.Checked == true)
            {
                cWhere = cWhere + " AND facturacion.despachada = 0 AND facturacion.anulada = 0";
            }
            else if (rbCobradas.Checked == true)
            {
                cWhere = cWhere + " AND facturacion.despachada = 1 AND facturacion.status = 0 AND facturacion.anulada = 0";
            }
            else
            {
                cWhere = cWhere + " AND facturacion.anulada = 1";
            }

            try
            {
                // Abro conexion
                myConexion.Open();
                // Creo comando
                myCommand = myConexion.CreateCommand();
                // Adhiero el comando a la conexion
                myCommand.Connection = myConexion;
                // Filtros de la busqueda
                //string fechadesde = fechaDesde.Value.ToString("yyyy-MM-dd");
                //string fechahasta = fechaHasta.Value.ToString("yyyy-MM-dd");
                //cWhere = cWhere + " AND fechacita >= " + "'" + fechadesde + "'" + " AND fechacita <= " + "'" + fechahasta + "'" + "";
                sbQuery.Clear();
                sbQuery.Append("SELECT ");
                sbQuery.Append(" facturacion.idfacturacion, facturacion.fecha, facturacion.monto_b,");
                sbQuery.Append(" facturacion.monto_n, ");
                sbQuery.Append(" clientes.nombre as cliente");
                sbQuery.Append(" FROM facturacion ");
                sbQuery.Append(" INNER JOIN clientes ON facturacion.idcliente = clientes.idcliente");
                sbQuery.Append(cWhere);

                // Paso los valores de sbQuery al CommandText
                myCommand.CommandText = sbQuery.ToString();
                // Creo el objeto Data Adapter y ejecuto el command en el
                myAdapter = new MySqlDataAdapter(myCommand);
                // Creo el objeto Data Table
                DataTable dtFacturacion = new DataTable();
                // Lleno el data adapter
                myAdapter.Fill(dtFacturacion);
                // Cierro el objeto conexion
                myConexion.Close();

                // Verifico cantidad de datos encontrados
                int nRegistro = dtFacturacion.Rows.Count;
                if (nRegistro == 0)
                {
                    MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema de Gestion de Facturacion e Inventario", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //1ero.HACEMOS LA COLECCION DE PARAMETROS
                    //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                    ParameterFields oParametrosCR = new ParameterFields();
                    //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                    ParameterValues oParametrosValuesCR = new ParameterValues();

                    //2do.CREAMOS LOS PARAMETROS
                    ParameterField oUsuario = new ParameterField();
                    //parametervaluetype especifica el TIPO de valor de parametro
                    //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                    oUsuario.ParameterValueType = ParameterValueKind.StringParameter;

                    //3ero.VALORES PARA LOS PARAMETROS
                    //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de
                    //parametros de valores discretos
                    ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                    oUsuarioDValue.Value = cUsuario;

                    //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                    oUsuario.CurrentValues.Add(oUsuarioDValue);


                    //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION
                    oParametrosCR.Add(oUsuario);

                    //nombre del parametro en CR (Crystal Reports)
                    oParametrosCR[0].Name = "cUsuario";

                    //nombre del TITULO DEL INFORME
                    if (rbDespachada.Checked == true)
                    {
                        cTitulo = "LISTADO DE FACTURACIONES PENDIENTES POR DESPACHAR";
                    }
                    else if (rbCobradas.Checked == true)
                    {
                        cTitulo = "LISTADO DE FACTURACIONES PENDIENTES POR COBRAR";
                    }
                    else
                    {
                        cTitulo = "LISTADO DE FACTURACIONES ANULADAS";
                    }

                    //6to Instanciamos nuestro REPORTE
                    //Reportes.ListadoDoctores oListado = new Reportes.ListadoDoctores();
                    rptFacturacion orptFacturacion = new rptFacturacion();

                    //pasamos el nombre del TITULO del Listado
                    //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                    // oListado.SummaryInfo.ReportTitle = cTitulo;
                    orptFacturacion.SummaryInfo.ReportTitle = cTitulo;

                    //7mo. instanciamos nuestro el FORMULARIO donde esta nuestro ReportViewer
                    frmPrinter ofrmPrinter = new frmPrinter(dtFacturacion, orptFacturacion, cTitulo);

                    //ParameterFieldInfo Obtiene o establece la colección de campos de parámetros.
                    ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                    ofrmPrinter.ShowDialog();
                }
            }
            catch (Exception myEx)
            {
                MessageBox.Show("Error : " + myEx.Message, "Mostrando Reporte", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                //ExceptionLog.LogError(myEx, false);
                return;
            }
        }
Пример #32
0
 public string Execute(ParameterValues parameterValues)
 {
     return(_Execute?.Invoke(parameterValues) ?? "No Action defined");
 }
Пример #33
0
        protected void GenerateReport()
        {
            string paramName = string.Empty;

            try
            {
                ReportDocument theReport  = new ReportDocument();
                string         reportFile = Converter.GetString(SessionStore.GetValue(Params.REPORT_FILE_NAME_KEY));

                if ((reportFile != string.Empty) & (reportFile != null))
                {
                    TableLogOnInfo myLog;
                    CrystalDecisions.CrystalReports.Engine.Table myTable;
                    reportFile = reportFile + ".rpt";
                    string reportPath = this.MapPath(".") + @"\Reports\" + reportFile;
                    theReport.Load(reportPath);
                    ConnectionInfo conn = new ConnectionInfo();
                    //conn.ServerName = ConfigurationManager.AppSettings["DBServer"].Trim();
                    conn.DatabaseName = Converter.GetString(SessionStore.GetValue(Params.REPORT_DATABASE_NAME_KEY));//ConfigurationManager.AppSettings["InitialDB"].Trim();
                    //conn.UserID = ConfigurationManager.AppSettings["DBUserName"].Trim();
                    //conn.Password = ConfigurationManager.AppSettings["DBPassword"].Trim();
                    conn.IntegratedSecurity = true;
                    int tableCount = theReport.Database.Tables.Count - 1;
                    for (int i = 0; i <= tableCount; i++)
                    {
                        myTable = theReport.Database.Tables[i];
                        myLog   = myTable.LogOnInfo;
                        myLog.ConnectionInfo = conn;
                        myTable.ApplyLogOnInfo(myLog);
                        myTable.Location = myLog.TableName;
                    }
                    int reportobjectsCount = theReport.ReportDefinition.ReportObjects.Count - 2;
                    for (int i = 0; i <= reportobjectsCount; i++)
                    {
                        CrystalDecisions.CrystalReports.Engine.ReportObject rpt = theReport.ReportDefinition.ReportObjects[i];
                        if (rpt.Kind == ReportObjectKind.SubreportObject)
                        {
                            SubreportObject subrpt = (SubreportObject)rpt;
                            ReportDocument  r      = theReport.OpenSubreport(subrpt.SubreportName);
                            int             subreportTableCount = r.Database.Tables.Count - 2;
                            for (int j = 0; j <= subreportTableCount; j++)
                            {
                                myTable = r.Database.Tables[j];
                                myLog   = myTable.LogOnInfo;
                                myTable.ApplyLogOnInfo(myLog);
                                myTable.Location = myLog.TableName;
                            }
                        }
                    }
                    ParameterValues        pList = new ParameterValues();
                    ParameterDiscreteValue pV    = new ParameterDiscreteValue();
                    int parameterFieldsCount     = theReport.DataDefinition.ParameterFields.Count - 1;
                    for (int i = 0; i <= parameterFieldsCount; i++)
                    {
                        paramName = theReport.DataDefinition.ParameterFields[i].Name;
                        //Report Parameters Fields 1
                        if (paramName == "@BRNO")
                        {
                            pV.Value = SessionStore.GetValue(Params.BRNO_ID);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 2
                        else if (paramName == "@CONO")
                        {
                            pV.Value = SessionStore.GetValue(Params.CONO_ID);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 3
                        else if (paramName == "@CompanyName")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMPANY_NAME);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CompanyNameB")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMPANY_NAME_B);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 4

                        else if (paramName == "@BranchName")
                        {
                            pV.Value = SessionStore.GetValue(Params.BRANCH_NAME);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 5
                        else if (paramName == "@BranchAddress")
                        {
                            pV.Value = SessionStore.GetValue(Params.BRANCH_ADDRESS);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@BranchAddressB")
                        {
                            pV.Value = SessionStore.GetValue(Params.BRANCH_ADDRESS_B);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 6
                        else if (paramName == "@CommonName")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 6
                        else if (paramName == "@CommonName1")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME1);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 7
                        else if (paramName == "@CommonName2")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME2);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 8
                        else if (paramName == "@CommonName3")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME3);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 9
                        else if (paramName == "@CommonName4")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME4);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 10
                        else if (paramName == "@CommonName5")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME5);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 11
                        else if (paramName == "@CommonName6")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME6);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 12
                        else if (paramName == "@CommonName7")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME7);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 13
                        else if (paramName == "@CommonName8")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME8);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 14
                        else if (paramName == "@CommonName9")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME9);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 15
                        else if (paramName == "@CommonName10")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME10);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 15
                        else if (paramName == "@CommonName11")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME11);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 15
                        else if (paramName == "@CommonName12")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME12);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 15
                        else if (paramName == "@CommonName13")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME13);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 15
                        else if (paramName == "@CommonName14")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME14);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CommonName15")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NAME15);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 16
                        else if (paramName == "@CommonNo1")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO1);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 17
                        else if (paramName == "@CommonNo2")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO2);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 18
                        else if (paramName == "@CommonNo3")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO3);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 19
                        else if (paramName == "@CommonNo4")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO4);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 20
                        else if (paramName == "@CommonNo5")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO5);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 21
                        else if (paramName == "@CommonNo6")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO6);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 22
                        else if (paramName == "@CommonNo7")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO7);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 23
                        else if (paramName == "@CommonNo8")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO8);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 24
                        else if (paramName == "@CommonNo9")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO9);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 25
                        else if (paramName == "@CommonNo10")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO10);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }


                        else if (paramName == "@CommonNo11")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO11);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }


                        //Report Parameters Fields 32
                        else if (paramName == "@CommonNo12")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO12);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 33
                        else if (paramName == "@CommonNo13")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO13);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }


                        //Report Parameters Fields 34
                        else if (paramName == "@CommonNo14")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO14);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 35
                        else if (paramName == "@CommonNo15")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO15);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CommonNo16")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO16);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CommonNo17")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO17);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CommonNo18")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO18);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CommonNo19")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO19);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CommonNo20")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_NO20);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 26
                        else if (paramName == "@UserID")
                        {
                            pV.Value = SessionStore.GetValue(Params.USERNO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@UserName")
                        {
                            pV.Value = SessionStore.GetValue(Params.USERNAME);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@BranchNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.BRNO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CuNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.CUNO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 27
                        else if (paramName == "@CuType")
                        {
                            pV.Value = SessionStore.GetValue(Params.CUPTYE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 28
                        else if (paramName == "@AccType")
                        {
                            pV.Value = SessionStore.GetValue(Params.ACCTYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 29
                        else if (paramName == "@AccNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.ACCNO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }


                        //Report Parameters Fields 30
                        else if (paramName == "@MemType")
                        {
                            pV.Value = SessionStore.GetValue(Params.MEMTYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@MemNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.MEMNO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@ColCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.COLCODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@RegNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.REGNO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 31
                        //Report Parameters Fields 36
                        else if (paramName == "@fDate")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_FDATE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        // Report Parameters Fields 37
                        else if (paramName == "@tDate")
                        {
                            pV.Value = SessionStore.GetValue(Params.COMMON_TDATE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        // Report Parameters Fields 38

                        else if (paramName == "@ProdCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.PROD_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        // Report Parameters Fields 39
                        else if (paramName == "@BatchNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.BATCH_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        // Report Parameters Fields 40
                        else if (paramName == "@VchNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.VOUCHER_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        // Report Parameters Fields 41
                        else if (paramName == "@fBatchNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.FIRST_BATCH_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        // Report Parameters Fields 42
                        else if (paramName == "@tBatchNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.TO_BATCH_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        // Report Parameters Fields 43
                        else if (paramName == "@TrnasferType")
                        {
                            pV.Value = SessionStore.GetValue(Params.TRANSFER_TYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        // Report Parameters Fields 45
                        else if (paramName == "@TrnSlNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.TRNSL_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 46
                        else if (paramName == "@LedgerType")
                        {
                            pV.Value = SessionStore.GetValue(Params.LEDGER_TYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 47
                        else if (paramName == "@LedgerNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.LEDGER_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 48
                        else if (paramName == "@ReqNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.REQ_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 49
                        else if (paramName == "@ProdCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.PROD_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 50
                        else if (paramName == "@BatchNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.BATCH_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 51
                        else if (paramName == "@GRNNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.GRN_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 52
                        else if (paramName == "@nItemType")
                        {
                            pV.Value = SessionStore.GetValue(Params.ITEM_TYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 53
                        else if (paramName == "@nItemSource")
                        {
                            pV.Value = SessionStore.GetValue(Params.ITEM_SOURCE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //......................................nimara.................................................
                        //Report Parameters Fields 54
                        else if (paramName == "@SuppCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.SUPP_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //.......................................................................................
                        //Report Parameters Fields 55
                        else if (paramName == "@ManuCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.MANU_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //............................................................................................
                        //Report Parameters Fields 56
                        else if (paramName == "@OrdNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.ORDER_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 57
                        else if (paramName == "@ItemCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.ITEM_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 58
                        else if (paramName == "@fItemCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.F_ITEM_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 59
                        else if (paramName == "@tItemCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.T_ITEM_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 60
                        else if (paramName == "@ChalanNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.CHALLAN_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //Report Parameters Fields 61
                        else if (paramName == "@EmpNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.EMP_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //Report Parameters Fields 62
                        else if (paramName == "@PPICNo")
                        {
                            pV.Value = SessionStore.GetValue(Params.PPIC_NO);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@AccountCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.ACCOUNTCODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@nFlag")
                        {
                            pV.Value = SessionStore.GetValue(Params.NFLAG);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@LPurpose")
                        {
                            pV.Value = SessionStore.GetValue(Params.LPURPOSE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@KeyCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.KEYCODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@Currency")
                        {
                            pV.Value = SessionStore.GetValue(Params.CURRENCY);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        //......................................Multiuser Store Procedure...........................
                        else if (paramName == "@AccClass")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_ACC_CLASS);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        else if (paramName == "@Func99")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_FUNC_99);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        else if (paramName == "@FcashCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_F_CASH_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TrnType")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRN_TYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@teller")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TELLER);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TrnMode")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRN_MODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TrnNature")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRN_NATURE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TrnModule")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRN_MODULE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TranSw")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRAN_SW);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@UserId")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_USER_ID);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CashCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_CASH_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CSGLTransaction")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_CS_GL_TRN);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@AutoTransaction")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_AUTO_TRN);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TransactionAmount")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRAN_AMT);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@AccStatFlag")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_ACC_STAT_FLAG);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@BalanceFlag")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_BALANCE_FLAG);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@fBalance")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_F_BALANCE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@tBalance")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_T_BALANCE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@CodeType")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_CODE_TYPE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@TrnCode")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_TRN_CODE);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                        else if (paramName == "@ContractInt")
                        {
                            pV.Value = SessionStore.GetValue(Params.MU_CONTRACT_INT);
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }

                        //......................................End of Multiuser Store Procedure....................
                        //............................................................................................
                        else
                        {
                            //This else for SP parameters 63
                            paramName = theReport.DataDefinition.ParameterFields[i].Name;
                            string paramValue = Converter.GetString(SessionStore.GetValue(Params.WHERE_CLAUSE));
                            pV.Value = paramValue;
                            pList.Add((ParameterValue)pV);
                            theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
                        }
                    }

                    this.CrystalReportViewer1.ReportSource = theReport;
                    this.CrystalReportViewer1.RefreshReport();

                    Session["ReportDocument"] = theReport;
                }
                else
                {
                    //TODO
                }
            }
            catch (Exception ex)
            {
                //string notifyMsg = "?msg=" + ex.ToString() + System.Environment.NewLine + "Please Check Value = " + paramName + System.Environment.NewLine + Request.UrlReferrer + "&PreviousMenu=A2ZERPModule.aspx";
                //Server.Transfer("MessageDisplay.aspx" + notifyMsg);

                throw ex;

                //Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('System Error.GenerateReport Problem');</script>");
            }
        }
        private void button1ok_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                SqlCommand     cmd          = new SqlCommand();
                SqlConnection  myConnection = default(SqlConnection);
                SqlDataAdapter myDA         = new SqlDataAdapter();
                DataSet        myDS         = new DataSet();

                myConnection   = new SqlConnection(cs.DBConn);
                cmd.Connection = myConnection;

                myConnection.Open();

                string cmdStrinzz = "SELECT  TFinancials.FDate, TFinancials.Particular, TFinancials.FCredit," +
                                    " TFinancials.FDebit, TFinancials.Names, Accounts.Account_type, Cash_Bank.Cash_type," +
                                    " CASE WHEN TFinancials.FDebit > 0 THEN 'Expense' ELSE 'Income' END AS Transaction_type " +//take note of the if else statement in there use for the p/l statement
                                    " FROM            TFinancials INNER JOIN " +
                                    "   Cash_Bank ON TFinancials.Id = Cash_Bank.Id INNER JOIN " +
                                    "  Accounts ON TFinancials.Account_id = Accounts.Account_id" +
                                    "  where (TFinancials.FDate >= @a2) AND (TFinancials.FDate <= @a3)  ";
                cmd = new SqlCommand(cmdStrinzz, myConnection);

                cmd.Parameters.AddWithValue("@a2", SqlDbType.Date).Value = (dateTimePicker1.Value.Date);
                cmd.Parameters.AddWithValue("@a3", SqlDbType.Date).Value = (dateTimePicker2.Value.Date);


                myDA.SelectCommand = cmd;
                myDA.Fill(myDS, "S_And_C_statment");

                rptpandlst rpt3 = new rptpandlst();

                rpt3.SetDataSource(myDS);



                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition  crParameterFieldDefinition;
                ParameterValues           crParameterValues        = new ParameterValues();
                ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();


                crParameterDiscreteValue.Value = "BIG LTD Profit And Loss Statement "
                                                 + Environment.NewLine + " For the period of " + dateTimePicker1.Value.ToShortDateString() + " To " + dateTimePicker2.Value.ToShortDateString();

                crParameterFieldDefinitions = rpt3.DataDefinition.ParameterFields;



                crParameterFieldDefinition = crParameterFieldDefinitions["My Parameter"];
                crParameterValues          = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);


                //frmcashsummary frm2 = new frmcashsummary();
                crystalReportViewer1.ReportSource = rpt3;

                //frm2.ShowDialog();


                myConnection.Close();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Error " + ex);
            }
        }
Пример #35
0
        private static void WriteData(Session session, Parameter parameter, ParameterDataAccessBase pdaNewParameter, ParameterValues samples)
        {
            // add data to new created parameter
            for (var j = samples.SampleCount - 1; j >= 0; j--)
            {
                var newTimestamp = samples.Timestamp[j];
                var newValue     = samples.Data[j] + 10;

                session.AddChannelData(
                    parameter.ChannelIds.FirstOrDefault(),
                    newTimestamp,
                    1, //value of 1 param
                    BitConverter.GetBytes(newValue));

                Console.WriteLine($"Written sample. Timestamp: {newTimestamp.ToTimeString()} Value:{newValue}");
            }

            // read data back to verify the data added
            pdaNewParameter.GoTo(session.EndTime);
            var samplesNewParameter = pdaNewParameter.GetNextSamples(10, StepDirection.Reverse);

            for (var j = 0; j < samplesNewParameter.SampleCount; j++)
            {
                Console.WriteLine($"{parameter.Identifier} {samplesNewParameter.Timestamp[j].ToTimeString()} {samplesNewParameter.Data[j]}");
            }
        }
Пример #36
0
        public Boolean printReport(CrystalDecisions.CrystalReports.Engine.ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param, String ParamName)
        {
            bool success=false;
            if (PrinterName!="none")
            {
                try
                {
                    paramField.ParameterFieldName = ParamName;
                    discreteVal.Value = param;
                    paramField.CurrentValues.Add (discreteVal);
                    paramFields.Add (paramField);

                    crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal);
                    CrystalReportViewer1.ReportSource = crReport;
                    CrystalReportViewer1.ParameterFieldInfo = paramFields;
                    CrystalReportViewer1.RefreshReport();

                    ParameterValues tmpParam = new ParameterValues();
                    tmpParam.Add(discreteVal);
                    crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(tmpParam);
                    crReport.PrintOptions.PrinterName = PrinterName;
                    //crReport.PrintToPrinter(1,false,1,1);
                    crReport.PrintToPrinter(1,false,1,99);
                    success=true;
                }
                catch{}
            }
            return success;
        }
        /// <summary>
        /// IMPR: Reduce complexity by creating a 'result' structure and split method in several parts.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="combi"></param>
        /// <param name="index"></param>
        private void PrintTimbre(TextWriter writer, ICombi combi, int index)
        {
            var timbre     = combi.Timbres.TimbresCollection[index];
            var status     = timbre.GetParam(ParameterNames.TimbreParameterName.Status).Value;
            var muteParam  = timbre.GetParam(ParameterNames.TimbreParameterName.Mute);
            var mute       = muteParam != null && (bool)muteParam.Value;
            var muteString = mute.ToYesNo();

            if (!ShowTimbre(timbre))
            {
                return;
            }

            var usedProgram = timbre.UsedProgram;
            var timbreId    = (usedProgram == null) ? "???" : timbre.ColumnProgramId;

            var isGmProgram    = (usedProgram != null) && ((ProgramBank)(timbre.UsedProgram.Parent)).Type == BankType.EType.Gm;
            var byteOffset     = (usedProgram == null) ? 0 : timbre.UsedProgram.ByteOffset;
            var name           = isGmProgram ? "-" : (byteOffset == 0) ? "???" : timbre.ColumnProgramName;
            var category       = isGmProgram ? "-" : (byteOffset == 0) ? "???" : timbre.UsedProgram.CategoryAsName;
            var subCategory    = isGmProgram ? "-" : ((byteOffset == 0) ? "???" : timbre.UsedProgram.SubCategoryAsName);
            var volume         = (string)(timbre.GetParam(ParameterNames.TimbreParameterName.Volume).Value.ToString());
            var priority       = timbre.GetParam(ParameterNames.TimbreParameterName.Priority);
            var priorityString = (isGmProgram || (priority == null))
                ? "No"
                : ((byteOffset == 0) ? "???" : ((bool)priority.Value).ToYesNo());

            var midiChannelString = ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.MidiChannel,
                                                                   (int)timbre.GetParam(ParameterNames.TimbreParameterName.MidiChannel).Value);

            var bottomKey = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.BottomKey,
                                                                   timbre.GetParam(ParameterNames.TimbreParameterName.BottomKey).Value);

            var topKey = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.TopKey,
                                                                timbre.GetParam(ParameterNames.TimbreParameterName.TopKey).Value);

            var bottomVelocity = (string)timbre.GetParam(ParameterNames.TimbreParameterName.BottomVelocity).Value.ToString();
            var topVelocity    = (string)timbre.GetParam(ParameterNames.TimbreParameterName.TopVelocity).Value.ToString();

            var paramOscMode = timbre.GetParam(ParameterNames.TimbreParameterName.OscMode);
            var oscMode      = (paramOscMode == null) ? "-" : (string)paramOscMode.Value;

            var paramOscSelect = timbre.GetParam(ParameterNames.TimbreParameterName.OscSelect);
            var oscSelect      = (paramOscSelect == null) ? "-" : (string)paramOscSelect.Value;

            var transpose = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.Transpose,
                                                                   timbre.GetParam(ParameterNames.TimbreParameterName.Transpose).Value);

            var paramDetune = timbre.GetParam(ParameterNames.TimbreParameterName.Detune);
            var detune      = (paramDetune == null) ? "-" : (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.Detune, paramDetune.Value);

            var paramPortamento = timbre.GetParam(ParameterNames.TimbreParameterName.Portamento);
            var portamento      = (paramPortamento == null)
                ? "-"
                : (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.Portamento, paramPortamento.Value);

            var bendRange = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.BendRange,
                                                                   timbre.GetParam(ParameterNames.TimbreParameterName.BendRange).Value);

            writer.Write(
                $"|{index + 1,2} |{timbreId,-10}|{name,-24}|{category,-24}|{subCategory,-24}|{volume,3}|{status,-3}|{muteString,-4}|{priorityString,-4}|{midiChannelString,-4}|");

// ReSharper disable RedundantStringFormatCall
            writer.WriteLine(
                $"{bottomKey,-4}~{topKey,-4}|{bottomVelocity,3}~{topVelocity,3}|{oscMode,-4}|{oscSelect,-4}|{transpose,3}|{detune,5}|{portamento,3}|{bendRange,-3} |");
        }
Пример #38
0
        private void frmRDctoTrabajador_Load(object sender, EventArgs e)
        {
            try
            {
                ExcelFormatOptions objExcel = new ExcelFormatOptions();

                string fechaInicio  = "";
                string fechaFin     = "";
                int    idTrabajador = 0;
                string estado       = frmReporteDctoTrabajador.f1.cbEstado.Text;
                if (frmReporteDctoTrabajador.f1.cbTrabajador.Checked == true)
                {
                    idTrabajador = Convert.ToInt32(frmReporteDctoTrabajador.f1.cbEmpleado.SelectedValue);
                }
                else if (frmReporteDctoTrabajador.f1.cbTrabajador.Checked == false)
                {
                    idTrabajador = 0;
                }


                fechaInicio = frmReporteDctoTrabajador.f1.dtpFechaInicio.Value.ToString("yyyy-MM-dd" + " 00:00:00");
                fechaFin    = frmReporteDctoTrabajador.f1.dtpFechaFin.Value.ToString("yyyy-MM-dd" + " 23:59:59");

                //int idProducto = Convert.ToInt32(frmReporteVentasProducto.f1.cbProducto.SelectedValue);

                ReportDocument repdoc = new ReportDocument();
                // repdoc.Load(@"C:\Users\vioma\OneDrive\Documentos\Visual Studio 2017\Projects\SisVentas_ResAlm\CapaPresentacion\Reportes/RVentaProducto.rpt");
                repdoc.Load(@"D:\Reportes\RDescuentoTrabajador.rpt");

                ParameterFieldDefinitions pfds;
                ParameterFieldDefinition  pfd;

                ParameterValues        pvs = new ParameterValues();
                ParameterDiscreteValue pdv = new ParameterDiscreteValue();

                pdv.Value = Convert.ToDateTime(fechaInicio);
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaInicio"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);


                pdv.Value = Convert.ToDateTime(fechaFin);
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaFin"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                pdv.Value = idTrabajador;
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@idTrabajador"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                pdv.Value = estado;
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@estado"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);



                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo  crtableLogoninfo  = new TableLogOnInfo();
                ConnectionInfo  crConnectionInfo  = new ConnectionInfo();
                Tables          CrTables;
                crConnectionInfo.ServerName   = @"EQUIPO\SQLEXPRESS";
                crConnectionInfo.DatabaseName = "BD_RESTAURANTE";
                crConnectionInfo.UserID       = "admin";
                crConnectionInfo.Password     = "******";

                CrTables = repdoc.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }


                cvVentas.ReportSource = repdoc;
                cvVentas.Refresh();
                objExcel.ExcelUseConstantColumnWidth = false;
            }

            catch (Exception ex)
            {
                MessageBox.Show("ERROR" + ex);
            }
        }
Пример #39
0
        //Generar pdf
        private void GenerarReporte(int agencia, DateTime fecha, string responsable)
        {
            ExportOptions exportOpts                 = new ExportOptions();
            DiskFileDestinationOptions diskOpts      = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    PDFFormatOpts = new PdfRtfWordFormatOptions();
            ExcelFormatOptions         EXCFormatOpts = new ExcelFormatOptions();
            TableLogOnInfo             InfoConexBd;

            Ver.Visible = false;
            //FormulaFieldDefinitions crFormulas;
            try
            {
                string nomuser  = ConfigurationManager.AppSettings["UID"];
                string password = ConfigurationManager.AppSettings["PWD"];
                AMS.CriptoServiceProvider.Crypto miCripto = new Crypto(AMS.CriptoServiceProvider.Crypto.CryptoProvider.TripleDES);
                miCripto.IV  = ConfigurationManager.AppSettings["VectorInicialEncriptacion"];
                miCripto.Key = ConfigurationManager.AppSettings["ValorConcatClavePrivada"];
                string passw = miCripto.DescifrarCadena(password);

                ReportDocument oRpt          = new ReportDocument();
                string         NombreReporte = ConfigurationManager.AppSettings["PathToReportsSource"] + "AMS.Comercial.ReporteAgenciaTaquillero.rpt";
                oRpt.Load(NombreReporte);


                /*for(int i=0;i<oRpt.DataDefinition.ParameterFields.Count;i++)
                 * {
                 *      string nombreReportePadre=oRpt.DataDefinition.ParameterFields[i].ReportName;
                 *      if(nombreReportePadre=="")
                 *              lblError.Text+=oRpt.DataDefinition.ParameterFields[i].Name+"<BR>";
                 * }*/

                string tem = "";
                foreach (CrystalDecisions.CrystalReports.Engine.Table tabla1 in oRpt.Database.Tables)
                {
                    tem         = tabla1.Name.ToString();
                    InfoConexBd = tabla1.LogOnInfo;
                    InfoConexBd.ConnectionInfo.UserID     = nomuser;
                    InfoConexBd.ConnectionInfo.Password   = passw;
                    InfoConexBd.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["DataBase"];
                    tabla1.ApplyLogOnInfo(InfoConexBd);
                }
                try
                {
                    ParameterDiscreteValue paramAgencia       = new ParameterDiscreteValue();
                    ParameterDiscreteValue paramFecha         = new ParameterDiscreteValue();
                    ParameterDiscreteValue paramResponsable   = new ParameterDiscreteValue();
                    ParameterValues        currentAgencia     = new ParameterValues();
                    ParameterValues        currentFecha       = new ParameterValues();
                    ParameterValues        currentResponsable = new ParameterValues();
                    paramAgencia.Value     = agencia;
                    paramFecha.Value       = fecha;
                    paramResponsable.Value = responsable;
                    currentAgencia.Add(paramAgencia);
                    currentFecha.Add(paramFecha);
                    currentResponsable.Add(paramResponsable);
                    oRpt.DataDefinition.ParameterFields["CODIGO_AGENCIA"].ApplyCurrentValues(currentAgencia);
                    oRpt.DataDefinition.ParameterFields["FECHA"].ApplyCurrentValues(currentFecha);
                    oRpt.DataDefinition.ParameterFields["NIT"].ApplyCurrentValues(currentResponsable);
                }
                catch (Exception e)
                {
                    lblError.Text += e.Message;
                }

                exportOpts = oRpt.ExportOptions;
                exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
                //exportOpts.ExportFormatType = ExportFormatType.ExcelRecord;
                exportOpts.FormatOptions = PDFFormatOpts;
                //exportOpts.FormatOptions = EXCFormatOpts;

                exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
                diskOpts.DiskFileName            = ConfigurationManager.AppSettings["PathToReports"] + "ReporteDiarioAgencia" + agencia + "_" + fecha.ToString("yyyy-MM-dd") + ".pdf";
                //diskOpts.DiskFileName = ConfigurationManager.AppSettings["PathToReports"] + "ReporteDiarioAgencia"+agencia+"_"+fecha.ToString("yyyy-MM-dd")+ ".xls";
                exportOpts.DestinationOptions = diskOpts;
                oRpt.Export();
                Ver.NavigateUrl = ConfigurationManager.AppSettings["PathToPreviews"] + "ReporteDiarioAgencia" + agencia + "_" + fecha.ToString("yyyy-MM-dd") + ".pdf";
                //Ver.NavigateUrl=ConfigurationManager.AppSettings["PathToPreviews"]+"ReporteDiarioAgencia"+agencia+"_"+fecha.ToString("yyyy-MM-dd")+ ".xls";
                Ver.Visible = true;
            }
            catch (Exception ex)
            {
                lblError.Text += ex.Message;
            }
        }
Пример #40
0
        public override Expression VisitSqlFunction(SqlFunctionExpression sqlFunctionExpression)
        {
            switch (sqlFunctionExpression.FunctionName)
            {
            case "EXTRACT":
            {
                Sql.Append(sqlFunctionExpression.FunctionName);
                Sql.Append("(");

                Visit(sqlFunctionExpression.Arguments[0]);

                Sql.Append(" FROM ");

                Visit(sqlFunctionExpression.Arguments[1]);

                Sql.Append(")");

                return(sqlFunctionExpression);
            }

            case "CAST":
            {
                Sql.Append(sqlFunctionExpression.FunctionName);
                Sql.Append("(");

                Visit(sqlFunctionExpression.Arguments[0]);

                Sql.Append(" AS ");

                Visit(sqlFunctionExpression.Arguments[1]);

                Sql.Append(")");

                return(sqlFunctionExpression);
            }

            case "AVG" when sqlFunctionExpression.Type == typeof(decimal):
            case "SUM" when sqlFunctionExpression.Type == typeof(decimal):
            {
                Sql.Append("CAST(");

                base.VisitSqlFunction(sqlFunctionExpression);

                Sql.Append(" AS DECIMAL(29,4))");

                return(sqlFunctionExpression);
            }

            case "INSTR":
            {
                if (sqlFunctionExpression.Arguments[1] is ParameterExpression parameterExpression &&
                    ParameterValues.TryGetValue(parameterExpression.Name, out var value) &&
                    (string)value == string.Empty)
                {
                    return(Visit(Expression.Constant(1)));
                }

                break;
            }

            case "ADD_MONTHS":
            {
                Sql.Append("CAST(");

                base.VisitSqlFunction(sqlFunctionExpression);

                Sql.Append(" AS TIMESTAMP)");

                return(sqlFunctionExpression);
            }
            }

            return(base.VisitSqlFunction(sqlFunctionExpression));
        }
 public override string ToString() => Function.Name.ToString() + (ParameterValues.Length == 0 ? "" : "(" + string.Join(", ", ParameterValues.Select(v => v.ToString())) + ")");
        public void GenerateReport(string parameter)
        {
            string _Report = string.Empty;

            if (_reportType == "Normal")
            {
                _Report = _reportName_Outside;
            }
            else if (_reportType == "Replacement")
            {
                _Report = _reportName_Outside_Replacement;
            }
            else
            {
                _Report = _reportName_Outside_Sample;
            }

            ReportDocument objReport1 = new ReportDocument();

            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();

            TableLogOnInfo ConInfo = new TableLogOnInfo();

            ConnectionInfo crConnectionInfo = new ConnectionInfo();

            Tables CrTables;

            ParameterFieldDefinitions crParameterFieldDefinitions;

            ParameterFieldDefinition crParameterFieldDefinition;

            ParameterValues crParameterValues = new ParameterValues();

            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();


            if (File.Exists(_path + _Report))
            {
                objReport1.Load(_path + _Report);
            }
            else
            {
                objReport1.Load(ClsConfig.LotCardCantierReportPath_Trial + _Report);
            }

            crParameterDiscreteValue.Value = parameter;
            crParameterFieldDefinitions    = objReport1.DataDefinition.ParameterFields;
            crParameterFieldDefinition     = crParameterFieldDefinitions["@LotCardGroupNo"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            string sUserID       = ClsConfig.ReportUser;
            string sPassword     = ClsConfig.ReportPassword;
            string sServerName   = ClsConfig.ReportServer;
            string sDatabaseName = ClsConfig.ReportDatabase_LotCard;


            crConnectionInfo.ServerName   = sServerName;
            crConnectionInfo.DatabaseName = sDatabaseName;
            crConnectionInfo.UserID       = sUserID;
            crConnectionInfo.Password     = sPassword;

            CrTables = objReport1.Database.Tables;

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

            docA = objReport1;

            reportViewer.ViewerCore.ReportSource = docA;
        }
Пример #43
0
        private ReportDocument SetReport_JP()
        {
            //ReportDocument rptDoc = new ReportDocument();
            ReportDocument rptDoc = null;

            ParameterValues pvFromDate = new ParameterValues();
            ParameterValues pvToDate = new ParameterValues();
            ParameterValues pvMonth = new ParameterValues();
            ParameterValues pvYear = new ParameterValues();
            ParameterValues pvUserName = new ParameterValues();
            ParameterValues pvPicURL = new ParameterValues();
            ParameterDiscreteValue pdvFromDate = new ParameterDiscreteValue();
            ParameterDiscreteValue pdvToDate = new ParameterDiscreteValue();
            ParameterDiscreteValue pdvMonth = new ParameterDiscreteValue();
            ParameterDiscreteValue pdvYear = new ParameterDiscreteValue();
            ParameterDiscreteValue pdvUserName = new ParameterDiscreteValue();
            ParameterDiscreteValue pdvPicURL = new ParameterDiscreteValue();
            ParameterValues pvDepartmentID = new ParameterValues();
            ParameterDiscreteValue pdvDepartmentID = new ParameterDiscreteValue();
            if (optGlobal.Checked)
            {
                pdvDepartmentID.Value = 1;//mac dinh ban dau chon ca cong ty
            }
            else
            {
                pdvDepartmentID.Value = cboDepartment.SelectedValue;
            }
            pdvUserName.Value = WorkingContext.Username;
            pvUserName.Add(pdvUserName);
            switch (lstGroupReport.SelectedIndex)
            {

                #region  báo cáo nhân sự
                case 0:
                    switch (lstDetailReport.SelectedIndex)
                    {
                        case 0:// Báo cáo danh sách nhân viên
                            //rptDoc = new Reports_JP.EmployeeDepartment();
                            //rptDoc.Load(@"Reports_JP\EmployeeDepartment.rpt");
                            rptDoc = new Reports_JP.EmployeeDepartment();
                            reportName = "EmployeeDepartment";

                            break;
                        case 1:// Thông tin chi tiết nhân viên
                            dtpFromDate.Enabled = false;
                            dtpToDate.Enabled = false;
                            //rptDoc.Load(@"Reports_JP\AllEmployeeInfo.rpt");
                            rptDoc = new Reports_JP.AllEmployeeInfo();
                            //							pdvUserName.Value = WorkingContext.Username;
                            //							pvUserName.Add(pdvUserName);
                            pdvPicURL.Value = WorkingContext.Setting.PicturePath;
                            pvPicURL.Add(pdvPicURL);
                            //MessageBox.Show(pdvPicURL.Value.ToString());
                            pvDepartmentID.Add(pdvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["PicURL"].ApplyCurrentValues(pvPicURL);
                            rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                            reportName = "AllEmployeeInfo";

                            break;

                        case 2:// Danh sách nhân viên nghỉ
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\RestEmployee.rpt");
                                rptDoc = new Reports_JP.RestEmployee();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                //								pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                pvToDate.Add(pdvToDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@dtpFrom"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@dtpTo"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "RestEmployee";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }

                            //							MessageBox.Show("OK");

                            break;
                        case 3:// Bảng theo dõi cơm trưa
                            try
                            {
                                rptDoc = new Reports_JP.LunchSheet();

                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;

                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);

                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "LunchSheet";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 4:// Danh sách làm thêm giờ
                            try
                            {
                                rptDoc = new Reports_JP.RegOverTime();

                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pvFromDate.Add(pdvFromDate);
                                pvDepartmentID.Add(pdvDepartmentID);

                                rptDoc.DataDefinition.ParameterFields["@WorkingDay"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "RegOverTime";
                                reportDate = dtpFromDate.Value;
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //
                            break;

                        case 5://Danh sách nhân viên đi công tác

                            try
                            {
                                rptDoc = new Reports_JP.LeaveSchedule();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                pvToDate.Add(pdvToDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@dtpFrom"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@dtpEnd"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "LeaveSchedule";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 6:// Theo dõi thay đổi phòng ban
                            //rptDoc.Load(@"Reports_JP\DepartmentHistory.rpt");
                            rptDoc = new Reports_JP.DepartmentHistory();
                            pvDepartmentID.Add(pdvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                            reportName = "DepartmentHistory";

                            break;
                        case 7:// Theo dõi thay đổi chức vụ
                            rptDoc = new Reports_JP.PositionHistory();
                            pvDepartmentID.Add(pdvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                            reportName = "PositionHistory";

                            break;
                        case 8:// Theo dõi diễn biến lương nhân viên;
                            rptDoc = new Reports_JP.SalaryHistory();
                            pvDepartmentID.Add(pdvDepartmentID);
                            rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                            //							pvUserName.Add(pdvUserName);
                            rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                            reportName = "SalaryHistory";

                            break;
                        case 9://Thanh toán tiền phép theo phòng ban
                            try
                            {
                                rptDoc = new Reports_JP.RestSheet();
                                pvDepartmentID.Add(pdvDepartmentID);
                                pdvYear.Value = dtpFromDate.Value.Year;
                                pvYear.Add(pdvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "RestSheet";
                                reportDate = dtpFromDate.Value;
                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 10:// Danh sách suất ăn làm thêm
                            try
                            {
                                //rptDoc.Load(@"Reports_JP\LunchOverTime.rpt");
                                rptDoc = new Reports_JP.LunchOverTime();
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pvFromDate.Add(pdvFromDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                //								pdvUserName.Value = WorkingContext.Username;
                                //								pvUserName.Add(pdvUserName);
                                rptDoc.DataDefinition.ParameterFields["@WorkingDay"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);

                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "LunchOverTime";
                                reportDate = dtpFromDate.Value;
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //
                            break;
                        case 11:// Danh sách suất ăn làm thêm theo thang
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP/LunchOverTimeInMonth.rpt");
                                rptDoc = new Reports_JP.LunchOverTimeInMonth();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "LunchOverTimeInMonth";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;

                        case 12:// Danh sách nhân viên được thưởng
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports\PunishEmployee.rpt");
                                rptDoc = new Reports.AverageEmployee();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                //pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                //								pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                //pvToDate.Add(pdvToDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@dtpFromDate"].ApplyCurrentValues(pvFromDate);
                                //rptDoc.DataDefinition.ParameterFields["@dtpToDate"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "AverageEmployee";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //	MessageBox.Show("OK");

                            break;
                    }
                    break;
                #endregion
                #region báo cáo chấm công
                case 1:
                    switch (lstDetailReport.SelectedIndex)
                    {
                        case 0:// Báo cáo chấm công chi tiết ngày
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\DetailAttendance.rpt");
                                rptDoc = new Reports_JP.DetailAttendance();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                pvToDate.Add(pdvToDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@FromDate"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@ToDate"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "DetailAttendance";
                                reportDate = dtpFromDate.Value;
                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 1:// báo cáo chấm công tháng
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\TimeSheet.rpt");
                                rptDoc = new Reports_JP.TimeSheet();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                //								pdvUserName.Value = WorkingContext.Username;
                                //								pvUserName.Add(pdvUserName);
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "TimeSheet";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 2:// Danh sách nhân viên không quẹt thẻ
                            try
                            {
                                //rptDoc.Load(@"Reports_JP\InvalidStrike.rpt");
                                rptDoc = new Reports_JP.InvalidStrike();
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pvFromDate.Add(pdvFromDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@WorkingDay"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "InvalidStrike";
                                reportDate = dtpFromDate.Value;
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //
                            break;
                        case 3:// Tổng hợp nhân viên trong ngày
                            try
                            {
                                //rptDoc.Load(@"Reports_JP\EmployeeSummary.rpt");
                                rptDoc = new Reports_JP.EmployeeSummary();
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pvFromDate.Add(pdvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                rptDoc.DataDefinition.ParameterFields["@Date"].ApplyCurrentValues(pvFromDate);
                                reportName = "EmployeeSummary";
                                reportDate = dtpFromDate.Value;
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //
                            break;
                        case 4:// báo cáo tổng hợp dữ liệu của một nhân viên trong tháng
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\EmployeeSummaryInMonth.rpt");
                                rptDoc = new Reports_JP.EmployeeSummaryInMonth();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                //								pdvUserName.Value = WorkingContext.Username;
                                //								pvUserName.Add(pdvUserName);
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "EmployeeSummaryInMonth";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 5:// báo cáo tổng hợp dữ liệu của nhân viên trong một năm
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\EmployeeSummaryInYear.rpt");
                                rptDoc = new Reports_JP.EmployeeSummaryInYear();
                                // Set the discreet value to the customers name.
                                pdvYear.Value = dtpFromDate.Value.Year;
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "EmployeeSummaryInYear";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 6:// báo cáo chi tiết của từng nhân viên trong tháng
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\AttendanceRecord.rpt");
                                rptDoc = new Reports_JP.AttendanceRecord();
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value;
                                pvFromDate.Add(pdvFromDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "AttendanceRecord";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;

                        case 7:// Danh sách nhân viên không quẹt thẻ
                            try
                            {
                                //rptDoc.Load(@"Reports\InvalidStrike.rpt");
                                rptDoc = new Reports.InvalidStrikeYesterday();
                                //rptDoc = new Reports.InvalidStrikeYesterday();
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pvFromDate.Add(pdvFromDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@WorkingDay"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "InvalidStrikeYesterday";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //
                            break;

                        case 8://Bảng thanh toán lương tổng hợp theo phòng ban
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports\SalarySummary.rpt");
                                rptDoc = new Reports.TimeSheetSummary();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "Bao cao cham cong theo phong ban";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //
                            break;
                    }
                    break;
                #endregion
                #region báo cáo lương
                case 2:
                    switch (lstDetailReport.SelectedIndex)
                    {
                        case 0://Bảng thanh toán lương tổng hợp
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\SalarySheet.rpt");
                                rptDoc = new Reports_JP.SalarySheet();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "SalarySheet";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 1://Bảng thanh toán lương chi tiết nhân viên
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\DetailSalary.rpt");
                                rptDoc = new Reports_JP.DetailSalary();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                //							pdvUserName.Value = WorkingContext.Username;
                                //							pvUserName.Add(pdvUserName);
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "DetailSalary";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 2://Bảng tóm tắt lương nhân viên=> in lên phong bì
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\BriefSalary.rpt");
                                rptDoc = new Reports_JP.BriefSalary();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "BriefSalary";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 3://Bảng thanh toán lương tổng hợp theo phòng ban
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\SalarySummary.rpt");
                                rptDoc = new Reports_JP.SalarySummary();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "SalarySummary";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                        case 4://Bảng lương chi tiết từng nhân viên
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\SalaryPerEmployee.rpt");
                                rptDoc = new Reports_JP.SalaryPerEmployee();
                                // Set the discreet value to the customers name.
                                pdvMonth.Value = dtpFromDate.Value.Month;
                                pdvYear.Value = dtpFromDate.Value.Year;
                                //							pdvUserName.Value = WorkingContext.Username;
                                //							pvUserName.Add(pdvUserName);
                                // Add it to the parameter collection.
                                pvMonth.Add(pdvMonth);
                                pvYear.Add(pdvYear);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvMonth);
                                rptDoc.DataDefinition.ParameterFields["@Year"].ApplyCurrentValues(pvYear);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "SalaryPerEmployee";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            break;
                    }
                    break;
                #endregion
                #region báo cáo thưởng phạt
                case 3:
                    switch (lstDetailReport.SelectedIndex)
                    {
                        case 0:// Danh sách nhân viên được thưởng
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\PunishEmployee.rpt");
                                rptDoc = new Reports_JP.PunishEmployee();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                //								pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                pvToDate.Add(pdvToDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@dtpFromDate"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@dtpToDate"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "PunishEmployee";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //	MessageBox.Show("OK");

                            break;
                    }
                    break;
                #endregion
                #region Bảo hiểm Xã hội
                case 4:
                    switch (lstDetailReport.SelectedIndex)
                    {
                        case 0:// Danh sách nhân viên đóng BHXH theo tháng
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\SocialInsurance.rpt");
                                rptDoc = new Reports_JP.SocialInsurance();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                //							pdvFromDate.Value = dtpFromDate.Value.ToShortDateString();
                                //							pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                //							// Add it to the parameter collection.
                                //							pvFromDate.Add(pdvFromDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                //							rptDoc.DataDefinition.ParameterFields["@dtpFromDate"].ApplyCurrentValues(pvFromDate);
                                //							rptDoc.DataDefinition.ParameterFields["@dtpToDate"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                reportName = "SocialInsurance";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //	MessageBox.Show("OK");

                            break;
                        case 1:// Danh sách nhân viên điều chỉnh BHXH
                            try
                            {
                                // Load the report
                                //rptDoc.Load(@"Reports_JP\SocialInsuranceAdjust.rpt");
                                rptDoc = new Reports_JP.SocialInsuranceAdjust();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value;
                                //							pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                //								pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                //							pvToDate.Add(pdvToDate);
                                //							pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Month"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                //							rptDoc.DataDefinition.ParameterFields["@dtpToDate"].ApplyCurrentValues(pvToDate);
                                //							rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                optLocal.Enabled = false;
                                reportName = "SocialInsuranceAdjust";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //	MessageBox.Show("OK");

                            break;

                        case 2:// Danh sách lao động và quỹ tiền lương trích nộp BHXH
                            try
                            {
                                optLocal.Enabled = false;
                                // Load the report
                                //rptDoc.Load(@"Reports\BHXH\InsuranceC45.rpt");
                                rptDoc = new Reports.BHXH.InsuranceC45();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value;
                                //							pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                //								pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                //							pvToDate.Add(pdvToDate);
                                //							pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Date"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                //							rptDoc.DataDefinition.ParameterFields["@dtpToDate"].ApplyCurrentValues(pvToDate);
                                //							rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "InsuranceC45";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //	MessageBox.Show("OK");

                            break;

                        case 3:// Xác nhận người lao động nghỉ việc trông con ốm
                            try
                            {
                                optLocal.Enabled = true;
                                // Load the report
                                //rptDoc.Load(@"Reports\BHXH\RestLookChildEmployee.rpt");
                                rptDoc = new Reports.BHXH.RestLookChildEmployee();
                                // Set the connection information for all the tables used in the report
                                // Set the discreet value to the customers name.
                                pdvFromDate.Value = dtpFromDate.Value;
                                //							pdvToDate.Value = dtpToDate.Value.ToShortDateString();
                                //pdvDepartmentID.Value = cboDepartment.SelectedValue;
                                // Add it to the parameter collection.
                                pvFromDate.Add(pdvFromDate);
                                //							pvToDate.Add(pdvToDate);
                                pvDepartmentID.Add(pdvDepartmentID);
                                // Apply the current parameter values.
                                rptDoc.DataDefinition.ParameterFields["@Date"].ApplyCurrentValues(pvFromDate);
                                rptDoc.DataDefinition.ParameterFields["@UserName"].ApplyCurrentValues(pvUserName);
                                //							rptDoc.DataDefinition.ParameterFields["@dtpToDate"].ApplyCurrentValues(pvToDate);
                                rptDoc.DataDefinition.ParameterFields["@DepartmentID"].ApplyCurrentValues(pvDepartmentID);
                                reportName = "RestLookChildEmployee";
                                reportDate = dtpFromDate.Value;

                            }
                            catch (LoadSaveReportException Exp)
                            {
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                                string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                                //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                                MessageBox.Show(str, str1);
                            }
                            catch (Exception Exp)
                            {
                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                                //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                                MessageBox.Show(Exp.Message, str2);
                            }
                            //	MessageBox.Show("OK");

                            break;
                    }
                    break;
                #endregion
            }
            if (rptDoc != null)
            {
                SetDBLogonForReport(rptDoc);
            }
            return rptDoc;
        }
Пример #44
0
        protected void ConnectLeftoversToParameters(ModelOutput mf, ParameterValues parameters)
        {
            var parametersToFindValueFor = from component in Components
                                           from parameter in component.Parameters
                                           where parameter.Binding is ParameterValueFile
                                           select new
            {
                ComponentName  = component.Name,
                ParameterName  = parameter.Name,
                DimensionTypes = parameter.DimensionTypes,
                DataType       = parameter.DataType,
                DefaultValue   = parameter.Binding.DefaultValue,
                paer           = parameter
            };

            var parametersWithManualValues = from component in Components
                                             from parameter in component.Parameters
                                             where parameter.Binding is ParameterValueManualConstant
                                             select new
            {
                ComponentName  = component.Name,
                ParameterName  = parameter.Name,
                DimensionTypes = parameter.DimensionTypes,
                DataType       = parameter.DataType,
                Value          = ((ParameterValueManualConstant)parameter.Binding).Value,
                paer           = parameter
            };

            var parametersWithLambdas = from component in Components
                                        from parameter in component.Parameters
                                        where parameter.Binding is ParameterValueManuelLambda
                                        select new
            {
                ComponentName  = component.Name,
                ParameterName  = parameter.Name,
                DimensionTypes = parameter.DimensionTypes,
                DataType       = parameter.DataType,
                Value          = ((ParameterValueManuelLambda)parameter.Binding).Lambda,
                paer           = parameter
            };

            var parametersInFileThatAreNotBound = from p in parameters
                                                  let pName = p.Name.ToLowerInvariant()
                                                              where !parametersToFindValueFor.Any(i => pName == i.ParameterName.ToLowerInvariant()) && pName != "region"
                                                              select p.Name;



            foreach (var p in parametersWithManualValues)
            {
                mf.AddNonDimensionalVariable(p.ComponentName, p.ParameterName, p.Value);
            }

            foreach (var p in parametersWithLambdas)
            {
                if (p.Value.GetType().GetGenericTypeDefinition() == typeof(Func <, ,>))
                {
                    var types = p.Value.GetType().GetGenericArguments();

                    var method = mf.GetType().GetMethod("Add2DimensionalParameterLambda").MakeGenericMethod(types);
                    method.Invoke(mf, new object[] { p.ComponentName, p.ParameterName, p.Value });
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            foreach (var p in parametersToFindValueFor)
            {
                if (parameters.Contains(p.ParameterName))
                {
                    mf.LoadVariableFromParameter(p.ComponentName, p.ParameterName, parameters, p.DataType, p.DimensionTypes.ToArray());
                }
                else if (p.DefaultValue != null)
                {
                    mf.AddNonDimensionalVariable(p.ComponentName, p.ParameterName, p.DefaultValue);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
        }
        private void btnInPhieu_Click_1(object sender, EventArgs e)
        {
            expandableSplitter1.Expanded = true;
            btnInPhieu.Visible = false;
            btnTroLai.Visible = true;

            PhieuThu rp = new PhieuThu();
            ParameterValues a = new ParameterValues();
            ParameterDiscreteValue b = new ParameterDiscreteValue();
            b.Value = txtHoBenhNhan.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["HoBenhNhan"].ApplyCurrentValues(a);

            b.Value = txtTenBenhNhan.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["TenBenhNhan"].ApplyCurrentValues(a);

            b.Value = dtPicker_NgaySinh.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["NgaySinh"].ApplyCurrentValues(a);

            b.Value = txtNgheNghiep.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["NgheNghiep"].ApplyCurrentValues(a);

            b.Value = txtDiaChi.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["DiaChi"].ApplyCurrentValues(a);

            b.Value = txtTenDichVu.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["TenDichVu"].ApplyCurrentValues(a);

            b.Value = txtDonGia.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["DonGia"].ApplyCurrentValues(a);

            b.Value = txtMaPhieuThu.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["MaPhieuThu"].ApplyCurrentValues(a);

            b.Value = txtHoNhanVien.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["HoNhanVien"].ApplyCurrentValues(a);

            b.Value = txtTenNhanVien.Text;
            a.Add(b);
            rp.DataDefinition.ParameterFields["TenNhanVien"].ApplyCurrentValues(a);

            string tongtien = txtDonGia.Text.ToString();
            long tien = long.Parse(tongtien);
            So_chu(tien);

            b.Value = So_chu(tien).ToString();
            a.Add(b);
            rp.DataDefinition.ParameterFields["TongTien"].ApplyCurrentValues(a);

            crystalReportViewer1.ReportSource = rp;
        }
Пример #46
0
 private void addPercentileValues(ParameterValues parameterValues, double[] allPercentiles)
 {
     parameterValues.Percentiles = new List <double>(allPercentiles);
 }
Пример #47
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                isNavigated = false;
                string UserId = EventFunctions.Functions.GetSessionUserId();
                if (UserId == "")
                {
                    return;
                }

                HideWindow();
                string sCmd = ("" + Request.QueryString["cmd"]).ToString();
                if ((Request.QueryString["ReportName"] != null) && (Request.QueryString["DataSource"] != null) && sCmd != "finished")
                {
                    //BL.Report repObj = new BL.Report();
                    string      _reportname             = null;
                    DataTable   _datasource             = null;
                    string      _reportselectionformula = null;
                    bool        _grouptree   = false;
                    string      _reporttitle = null;
                    string      _printType   = null;
                    DataTable[] _dt          = new DataTable[10];
                    _reportname = Request.QueryString["ReportName"];
                    if (Request.QueryString["ReportSelectionFormula"] != null)
                    {
                        _reportselectionformula = Request.QueryString["ReportSelectionFormula"];
                        _reportselectionformula = _reportselectionformula.Replace("~", "'");
                    }
                    _grouptree   = Convert.ToBoolean(Request.QueryString["GroupTree"]);
                    _reporttitle = Request.QueryString["ReportTitle"];
                    _printType   = Request.QueryString["PrintType"];

                    /*repObj.DateParameter1 = Request.QueryString["DateParameter1"];
                     * repObj.DateParameter2 = Request.QueryString["DateParameter2"];
                     * repObj.DateParameter3 = Request.QueryString["DateParameter3"];
                     * repObj.DateParameter4 = Request.QueryString["DateParameter4"];
                     * repObj.DecimalParameter1 = Request.QueryString["DecimalParameter1"];
                     * repObj.DecimalParameter2 = Request.QueryString["DecimalParameter2"];
                     * repObj.StringParameter1 = "" + Request.QueryString["sP1"];
                     * repObj.StringParameter2 = "" + Request.QueryString["sP2"];
                     * repObj.StringParameter3 = "" + Request.QueryString["sP3"];
                     * repObj.StringParameter4 = "" + Request.QueryString["sP4"];
                     * repObj.StringParameter5 = "" + Request.QueryString["sP5"];
                     * repObj.StringParameter6 = "" + Request.QueryString["sP6"];
                     * repObj.BoolParameter1 = Request.QueryString["BoolParameter1"];
                     * repObj.BoolParameter2 = Request.QueryString["BoolParameter2"];
                     * if (("" + Request.QueryString["StringArray"]).ToString().Trim() != "")
                     *  repObj.StringArray = Request.QueryString["StringArray"].Trim().Split(',');
                     * int iSubRptCnt = System.Common.Functions.ToInt(Request.QueryString["SubReports"]);
                     * if (iSubRptCnt > 0)
                     *  _dt = repObj.LoadReportDatasourceArray(Request.QueryString["DataSource"]);
                     * else
                     *  _datasource = repObj.LoadReportDatasource(Request.QueryString["DataSource"]);*/
                    int                    SalesId              = Functions.ToInt(Request.QueryString["SalesId"]);
                    int                    iSubRptCnt           = 0;
                    ParameterValues        myparameterValues    = new ParameterValues();
                    ParameterDiscreteValue myparamDiscreteValue = new ParameterDiscreteValue();

                    DBConnection DBConn = new DBConnection();
                    switch (_reportname)
                    {
                    case "Receipt":
                        string sql       = "select count(*) as cnt from ProductDetail P, SalesDetails S where P.SalesDetailId = S.SalesDetailId and status = 3 and S.SalesMasterId = " + SalesId;
                        string returnCnt = DBConn.RetData(sql, CommandType.Text);

                        _datasource = DBConn.ExecuteDataSet("SELECT SalesMaster.SalesMasterId SalesId,DATE_FORMAT(SalesDate,'%m/%d/%Y') SalesDate,CustomerName,DATE_FORMAT(SalesDate,'%h:%i %p')  as `SalesTime`,concat(IFNULL((SELECT Name FROM ProductMaster WHERE ProductMaster.ProductId = SalesDetails.ProductId),''), IFNULL(SalesDetails.ProductName,''), IFNULL(concat(' (SD Order #: ',SDOrderNo,')'),'')) as Description,Count as Quantity,SalesAmount as Price,'' as PayType,0 as PayAmount, " + returnCnt + " as ReturnCount FROM SalesMaster,SalesDetails where SalesMaster.SalesMasterId = SalesDetails.SalesMasterId and SalesMaster.SalesMasterId= " + SalesId, CommandType.Text).Tables[0];
                        _reportname = "Receipt.rpt";
                        break;

                    case "Sales":
                        string   sFrom = "" + Request.QueryString["fromd"];
                        string   sTo   = "" + Request.QueryString["tod"];
                        DateTime dt1;
                        sql = "SELECT '0' as type, 0 as SRID, SalesMasterId ID, DATE_FORMAT(SalesDate,'%m/%d/%Y %h:%i %p') SalesDate, SalesDate sdt, PurchaseAmount as Amount, GrandTotal GT, (SELECT Name FROM LocationMaster WHERE LocationMaster.LocationId = SalesMaster.LocationId) as Location, (SELECT UserName FROM UserMaster WHERE UserMaster.UserId = SalesMaster.ClerkId) as Clerk, CustomerName, (SELECT SUM(COUNT) FROM SalesDetails WHERE SalesMasterId = SalesMaster.SalesMasterId) ticket,  ";
                        if (sFrom.Trim() != "" && sTo.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'" + sTo + "' sTo FROM SalesMaster where 1=1";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            dt1   = DateTime.Parse(sTo);
                            sTo   = dt1.ToString("yyyy-MM-dd");
                            sql  += " and (SalesDate between '" + sFrom + " 00:00:01' and '" + sTo + " 23:59:59')";
                        }
                        else if (sFrom.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'' sTo FROM SalesMaster where 1=1";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            sql  += " and SalesDate >= '" + sFrom + " 00:00:01'";
                        }
                        else if (sTo.Trim() != "")
                        {
                            sql += "'' sFrom,'" + sTo + "' sTo FROM SalesMaster where 1=1";
                            dt1  = DateTime.Parse(sTo);
                            sTo  = dt1.ToString("yyyy-MM-dd");
                            sql += " and SalesDate <= '" + sTo + " 23:59:59'";
                        }
                        else
                        {
                            sql += "'' sFrom,'' sTo FROM SalesMaster where 1=1";
                        }
                        //sql += " order by sdt";

                        sql += " union SELECT '1' as type, SalesReturnMasterId SRID, (SELECT SalesMasterId from SalesDetails, SalesReturnDetails WHERE SalesDetails.SalesDetailId = SalesReturnDetails.SalesDetailId and SalesReturnDetails.SalesReturnMasterId = SalesReturnMaster.SalesReturnMasterId limit 1) as ID, DATE_FORMAT(SalesReturnDate,'%m/%d/%Y %h:%i %p') SalesDate, SalesReturnDate sdt, 0 as Amount, Amount GT, (SELECT Name FROM LocationMaster WHERE LocationMaster.LocationId = SalesReturnMaster.LocationId) as Location, (SELECT UserName FROM UserMaster WHERE UserMaster.UserId = SalesReturnMaster.ClerkId) as Clerk, '' as CustomerName, (SELECT SUM(Qty) FROM SalesReturnDetails WHERE SalesReturnMasterId = SalesReturnMaster.SalesReturnMasterId) ticket,  ";
                        if (sFrom.Trim() != "" && sTo.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster where 1=1";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            dt1   = DateTime.Parse(sTo);
                            sTo   = dt1.ToString("yyyy-MM-dd");
                            sql  += " and (SalesReturnDate between '" + sFrom + " 00:00:01' and '" + sTo + " 23:59:59')";
                        }
                        else if (sFrom.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'' sTo FROM SalesReturnMaster where 1=1";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            sql  += " and SalesReturnDate >= '" + sFrom + " 00:00:01'";
                        }
                        else if (sTo.Trim() != "")
                        {
                            sql += "'' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster where 1=1";
                            dt1  = DateTime.Parse(sTo);
                            sTo  = dt1.ToString("yyyy-MM-dd");
                            sql += " and SalesReturnDate <= '" + sTo + " 23:59:59'";
                        }
                        else
                        {
                            sql += "'' sFrom,'' sTo FROM SalesReturnMaster where 1=1";
                        }
                        sql += " order by type, sdt";

                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "Sales.rpt";
                        break;

                    case "SalesDetails":
                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];
                        sql   = @"SELECT '0' as type, 0 as SalesMasterId, SalesMaster.SalesMasterId SalesId,DATE_FORMAT(SalesDate,'%m/%d/%Y %h:%i %p') SalesDate,PurchaseAmount AS Amount,
                                    DATE_FORMAT(SalesDate,'%m/%d/%Y') SD,SalesDetails.SerialNo,
                                    (SELECT NAME FROM LocationMaster WHERE LocationMaster.LocationId = SalesMaster.LocationId) AS Location,
                                    (SELECT UserName FROM UserMaster WHERE UserMaster.UserId = SalesMaster.ClerkId) AS Clerk,CustomerName,
                                    concat(IFNULL((SELECT Name FROM ProductMaster WHERE ProductMaster.ProductId = SalesDetails.ProductId),''), IFNULL(SalesDetails.ProductName,'')) AS Description,
                                    COUNT AS Quantity,SalesAmount AS Price,
                                    (SELECT CASE WHEN PaymentType=1 THEN 'Cash' WHEN PaymentType=2 THEN 'Card' Else 'Vouher' END FROM PaymentDetails WHERE SalesMasterId = SalesMaster.SalesMasterId) paytype,
                                    (SELECT CardAuthorizationId FROM PaymentDetails WHERE SalesMasterId = SalesMaster.SalesMasterId) authcode,";
                        if (sFrom.Trim() != "" && sTo.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'" + sTo + "' sTo FROM SalesMaster,SalesDetails WHERE SalesMaster.SalesMasterId = SalesDetails.SalesMasterId ";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            dt1   = DateTime.Parse(sTo);
                            sTo   = dt1.ToString("yyyy-MM-dd");
                            sql  += " and (SalesMaster.SalesDate between '" + sFrom + " 00:00:01' and '" + sTo + " 23:59:59')";
                        }
                        else if (sFrom.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'' sTo FROM SalesMaster,SalesDetails WHERE SalesMaster.SalesMasterId = SalesDetails.SalesMasterId";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            sql  += " and SalesMaster.SalesDate >= '" + sFrom + " 00:00:01'";
                        }
                        else if (sTo.Trim() != "")
                        {
                            sql += "'' sFrom,'" + sTo + "' sTo FROM SalesMaster,SalesDetails WHERE SalesMaster.SalesMasterId = SalesDetails.SalesMasterId";
                            dt1  = DateTime.Parse(sTo);
                            sTo  = dt1.ToString("yyyy-MM-dd");
                            sql += " and SalesMaster.SalesDate <= '" + sTo + " 23:59:59'";
                        }
                        else
                        {
                            sql += "'' sFrom,'' sTo FROM SalesMaster,SalesDetails WHERE SalesMaster.SalesMasterId = SalesDetails.SalesMasterId";
                        }
                        //sql += " order by SalesMaster.SalesDate";


                        sql += @" union SELECT '1' as type, SalesReturnMaster.SalesReturnMasterId SalesMasterId, (select SalesMasterId from SalesDetails where SalesDetailId = SalesReturnDetails.SalesDetailId limit 1) as SalesId, DATE_FORMAT(SalesReturnDate,'%m/%d/%Y %h:%i %p') SalesDate, SalesReturnMaster.Amount AS Amount,
                                    DATE_FORMAT(SalesReturnDate,'%m/%d/%Y') SD, SalesReturnDetails.SerialNo,
                                    (SELECT NAME FROM LocationMaster WHERE LocationMaster.LocationId = SalesReturnMaster.LocationId) AS Location,
                                    (SELECT UserName FROM UserMaster WHERE UserMaster.UserId = SalesReturnMaster.ClerkId) AS Clerk, '' as CustomerName,
                                    (SELECT NAME FROM ProductMaster WHERE ProductMaster.ProductId = SalesReturnDetails.ProductId) AS Description,
                                    Qty AS Quantity, SalesReturnDetails.Amount AS Price,
                                    (SELECT CASE WHEN PaymentType=1 THEN 'Cash' WHEN PaymentType=2 THEN 'Card' Else 'Vouher' END FROM PaymentDetails WHERE SalesMasterId = SalesReturnMaster.SalesReturnMasterId) paytype,
                                    '' as authcode,";
                        if (sFrom.Trim() != "" && sTo.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster, SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId ";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            dt1   = DateTime.Parse(sTo);
                            sTo   = dt1.ToString("yyyy-MM-dd");
                            sql  += " and (SalesReturnMaster.SalesReturnDate between '" + sFrom + " 00:00:01' and '" + sTo + " 23:59:59')";
                        }
                        else if (sFrom.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'' sTo FROM SalesReturnMaster,SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            sql  += " and SalesReturnMaster.SalesReturnDate >= '" + sFrom + " 00:00:01'";
                        }
                        else if (sTo.Trim() != "")
                        {
                            sql += "'' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster,SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId";
                            dt1  = DateTime.Parse(sTo);
                            sTo  = dt1.ToString("yyyy-MM-dd");
                            sql += " and SalesReturnMaster.SalesReturnDate <= '" + sTo + " 23:59:59'";
                        }
                        else
                        {
                            sql += "'' sFrom,'' sTo FROM SalesReturnMaster,SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId";
                        }
                        sql += " order by SalesDate";


                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "SalesDetails.rpt";
                        break;

                    case "EventSoldCount":
                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];
                        sql   = @"select '0' as type, L.Name as location_name, count(*) as product_count, P.Name as product_name, '" + sFrom + "' as from_date, '" + sTo + @"' as to_date from SalesMaster S, SalesDetails D, LocationMaster L, ProductMaster P, ProductDetail PD
                                            where S.LocationId = L.LocationId and S.SalesMasterId = D.SalesMasterId and D.ProductId = P.ProductId and P.ProductId = PD.ProductId and PD.SalesDetailId = D.SalesDetailId";

                        if (sFrom != "")
                        {
                            sql += " and S.SalesDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                        }
                        if (sTo != "")
                        {
                            sql += " and S.SalesDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                        }
                        sql += " group by L.LocationId, L.Name, P.ProductId, P.Name ";

                        sql += @" union select '1' as type, L.Name as location_name, count(*) as product_count, P.Name as product_name, '" + sFrom + "' as from_date, '" + sTo + @"' as to_date from SalesReturnMaster S, SalesReturnDetails D, LocationMaster L, ProductMaster P, ProductDetail PD
                                            where S.LocationId = L.LocationId and S.SalesReturnMasterId = D.SalesReturnMasterId and D.ProductId = P.ProductId and P.ProductId = PD.ProductId and PD.SalesReturnDetailId = D.SalesReturnDetailId";

                        if (sFrom != "")
                        {
                            sql += " and S.SalesReturnDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                        }
                        if (sTo != "")
                        {
                            sql += " and S.SalesReturnDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                        }
                        sql += " group by type, L.LocationId, L.Name, P.ProductId, P.Name order by type, location_name, product_name";

                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "EventSoldCount.rpt";
                        break;

                    case "CategorySummary":
                        string CategoryId   = "" + Request.QueryString["category_id"];
                        string CategoryName = "" + Request.QueryString["category_name"];
                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];

                        sql = "select * from Category where CategoryId = " + CategoryId;
                        DataTable dt = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        if (("" + dt.Rows[0]["IsPhysicalInventory"].ToString()).ToString() == "1")
                        {
                            sql = @"select '0' as type, '" + CategoryName + " Pass Summary by Date' as Title, '" + sFrom + "' as from_date, '" + sTo + @"' as to_date, S.SalesDate as purchase_date, P.Name as product_name, 1 as product_count, '' as voucher_no, PD.SerialNo as serial_no, D.SalesAmount as purchase_price
                                    from SalesMaster S, SalesDetails D, ProductMaster P, ProductDetail PD
                                    where S.SalesMasterId = D.SalesMasterId and D.ProductId = P.ProductId and P.ProductId = PD.ProductId and PD.SalesDetailId = D.SalesDetailId and P.CategoryId = " + CategoryId;
                            if (sFrom != "")
                            {
                                sql += " and S.SalesDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                            }
                            if (sTo != "")
                            {
                                sql += " and S.SalesDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                            }

                            sql += @" union select '1' as type, '" + CategoryName + " Pass Summary by Date' as Title, '" + sFrom + "' as from_date, '" + sTo + @"' as to_date, S.SalesReturnDate as purchase_date, P.Name as product_name, 1 as product_count, '' as voucher_no, PD.SerialNo as serial_no, D.Amount as purchase_price
                                    from SalesReturnMaster S, SalesReturnDetails D, ProductMaster P, ProductDetail PD
                                    where S.SalesReturnMasterId = D.SalesReturnMasterId and D.ProductId = P.ProductId and P.ProductId = PD.ProductId and PD.SalesReturnDetailId = D.SalesReturnDetailId and P.CategoryId = " + CategoryId;
                            if (sFrom != "")
                            {
                                sql += " and S.SalesReturnDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                            }
                            if (sTo != "")
                            {
                                sql += " and S.SalesReturnDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                            }
                            sql += " order by type, purchase_date, product_name, serial_no";
                        }
                        else
                        {
                            sql = @"select '0' as type, '" + CategoryName + " Pass Summary by Date' as Title, '" + sFrom + "' as from_date, '" + sTo + @"' as to_date, S.SalesDate as purchase_date, 
                                    concat(IFNULL((SELECT Name FROM ProductMaster WHERE ProductMaster.ProductId = D.ProductId),''), IFNULL(D.ProductName,'')) as product_name, 
                                    1 as product_count, '' as voucher_no, 
                                    case when IsSmartDest = 0 then (select SerialNo from ProductDetail where ProductId = D.ProductId and SalesDetailId = D.SalesDetailId) else '' as serial_no, D.SalesAmount as purchase_price
                                    from SalesMaster S, SalesDetails D, ProductDetail PD
                                    where S.SalesMasterId = D.SalesMasterId and D.ProductId = PD.ProductId and PD.SalesDetailId = D.SalesDetailId and P.CategoryId = " + CategoryId;
                            if (sFrom != "")
                            {
                                sql += " and S.SalesDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                            }
                            if (sTo != "")
                            {
                                sql += " and S.SalesDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                            }

                            sql += @" union select '1' as type, '" + CategoryName + " Pass Summary by Date' as Title, '" + sFrom + "' as from_date, '" + sTo + @"' as to_date, S.SalesReturnDate as purchase_date, concat(IFNULL((SELECT Name FROM ProductMaster WHERE ProductMaster.ProductId = D.ProductId),''), IFNULL(D.ProductName,'')) as product_name, 1 as product_count, '' as voucher_no, PD.SerialNo as serial_no, D.Amount as purchase_price
                                    from SalesReturnMaster S, SalesReturnDetails D, ProductDetail PD
                                    where S.SalesReturnMasterId = D.SalesReturnMasterId and D.ProductId = P.ProductId and P.ProductId = PD.ProductId and PD.SalesReturnDetailId = D.SalesReturnDetailId and P.CategoryId = " + CategoryId;
                            if (sFrom != "")
                            {
                                sql += " and S.SalesReturnDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                            }
                            if (sTo != "")
                            {
                                sql += " and S.SalesReturnDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                            }
                            sql += " order by purchase_date, product_name, serial_no";
                        }
                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "CategorySummary.rpt";
                        break;

                    case "ClerkSummary":
                        string LocationId = "" + Request.QueryString["location_id"];
                        sFrom = "" + Request.QueryString["fromd"];
                        //sTo = "" + Request.QueryString["tod"];

                        sql = @"SELECT '0' as type, '" + sFrom + @"' as from_date, '' as to_date, L.Name as location_name, U.UserName as user_name,
                                    Sum(case when PaymentType = 1 then 1 else 0 end) as cash_count, Sum(case when PaymentType = 1 then P.Amount else 0 end) as cash_total,
                                    Sum(case when PaymentType = 2 then 1 else 0 end) as credit_count, Sum(case when PaymentType = 2 then P.Amount else 0 end) as credit_total,
                                    Sum(case when PaymentType = 3 then 1 else 0 end) as voucher_count, Sum(case when PaymentType = 3 then P.Amount else 0 end) as voucher_total
                                    FROM SalesMaster S, PaymentDetails P, LocationMaster L, UserMaster U
                                    WHERE S.SalesMasterId = P.SalesMasterId and P.TransType = 0 and S.LocationId = L.LocationId and S.ClerkId = U.UserId and S.LocationId = " + LocationId;
                        if (sFrom != "")
                        {
                            sql += " and S.SalesDate between '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' and  '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 23:59:59'";
                        }
                        sql += " group by L.Name, U.UserName  ";
                        sql += " union ";

                        sql += @"SELECT '1' as type, '" + sFrom + @"' as from_date, '' as to_date, L.Name as location_name, U.UserName as user_name,
                                    Sum(case when PaymentType = 1 then 1 else 0 end) as cash_count, Sum(case when PaymentType = 1 then P.Amount else 0 end) as cash_total,
                                    Sum(case when PaymentType = 2 then 1 else 0 end) as credit_count, Sum(case when PaymentType = 2 then P.Amount else 0 end) as credit_total,
                                    Sum(case when PaymentType = 3 then 1 else 0 end) as voucher_count, Sum(case when PaymentType = 3 then P.Amount else 0 end) as voucher_total
                                    FROM SalesReturnMaster S, PaymentDetails P, LocationMaster L, UserMaster U
                                    WHERE S.SalesReturnMasterId = P.SalesMasterId and P.TransType = 1 and S.LocationId = L.LocationId and S.ClerkId = U.UserId and S.LocationId = " + LocationId;
                        if (sFrom != "")
                        {
                            sql += " and S.SalesReturnDate between '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' and  '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 23:59:59'";
                        }
                        sql += " group by L.Name, U.UserName  ";

                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "ClerkSummary.rpt";
                        break;

                    case "VoucherSummary":
                        CategoryId   = "" + Request.QueryString["category_id"];
                        CategoryName = "" + Request.QueryString["category_name"];
                        sFrom        = "" + Request.QueryString["fromd"];
                        sTo          = "" + Request.QueryString["tod"];
                        if (sTo == "")
                        {
                            sTo = sFrom;
                        }
                        sql = @"select '" + CategoryName + "' as Title, '" + sFrom + "' FromDate, '" + sTo + @"' ToDate, SM.SalesMasterId, SM.SalesDate as `Date`, PD.CardCheckNo as VoucherNumber, PM.Name, SD.SerialNo as SerialNumber from
                                    SalesMaster SM, PaymentDetails PD, ProductMaster PM, SalesDetails SD where
                                    SM.SalesMasterId = PD.SalesMasterId AND SD.SalesMasterId = SM.SalesMasterId AND
                                    SD.ProductId = PM.ProductId AND PD.PaymentType = 3 AND PM.CategoryId = " + CategoryId;
                        if (sFrom != "")
                        {
                            sql += " and SM.SalesDate  between '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' and '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                        }
                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "VoucherSummary.rpt";
                        break;

                    case "SDReturns":

                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];
                        sql   = @"SELECT 'Smart Destination Returns' as title, '" + sFrom + @"' as from_date, '" + sTo + @"' as to_date, SD.SalesMasterId as sales_id, date_format(SR.SalesReturnDate,'%m/%d/%Y') as return_date, 
                                    SD.ProductName as product_name, SRD.qty, SRD.amount, UM.UserName as user_name, concat(' ',SDOrderNo) as SDOrderNo
                                    FROM SalesReturnMaster SR, SalesReturnDetails SRD, SalesMaster SM, SalesDetails SD, UserMaster UM
                                    WHERE SR.SalesReturnMasterId = SRD.SalesReturnMasterId and SRD.SalesDetailId = SD.SalesDetailId and SM.SalesMasterId = SD.SalesMasterId and SD.IsSmartDest = 1 and SRD.ProductId = SD.ProductId and SR.ClerkId = UM.UserId and SR.LocationId = " + Session["LocationId"].ToString();
                        if (sFrom != "")
                        {
                            sql += " and SR.SalesReturnDate >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                        }
                        if (sTo != "")
                        {
                            sql += " and SR.SalesReturnDate <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                        }
                        sql += "";
                        sql += " order by SR.SalesReturnDate";

                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "SDReturns.rpt";

                        break;

                    case "UserLog":
                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];
                        sql   = @"SELECT username as user_name, LoginDateTime AS login_date, LogoutDatetime AS logout_date, IP
                                    FROM UserLog, UserMaster
                                    WHERE UserLog.UserId = UserMaster.UserId ";
                        if (sFrom != "")
                        {
                            sql += " and LoginDateTime >= '" + Convert.ToDateTime(sFrom).ToString("yyyy-MM-dd") + " 00:00:00' ";
                        }
                        if (sTo != "")
                        {
                            sql += " and LoginDateTime <= '" + Convert.ToDateTime(sTo).ToString("yyyy-MM-dd") + @" 23:59:59'";
                        }
                        sql        += " ORDER BY UserName, LoginDateTime";
                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "UserLog.rpt";

                        break;

                    case "SalesReturn":
                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];
                        sql   = " SELECT SalesReturnMasterId SRID, (SELECT SalesMasterId from SalesDetails, SalesReturnDetails WHERE SalesDetails.SalesDetailId = SalesReturnDetails.SalesDetailId and SalesReturnDetails.SalesReturnMasterId = SalesReturnMaster.SalesReturnMasterId limit 1) as ID, (select DATE_FORMAT(SalesDate,'%m/%d/%Y %h:%i %p') from SalesDetails, SalesReturnDetails, SalesMaster WHERE SalesMaster.`SalesMasterId` = SalesDetails.`SalesMasterId` AND SalesDetails.SalesDetailId = SalesReturnDetails.SalesDetailId and SalesReturnDetails.SalesReturnMasterId = SalesReturnMaster.SalesReturnMasterId limit 1) SalesDate, DATE_FORMAT(SalesReturnDate,'%m/%d/%Y %h:%i %p') SalesReturnDate, Amount, (SELECT Name FROM LocationMaster WHERE LocationMaster.LocationId = SalesReturnMaster.LocationId) as Location, (SELECT UserName FROM UserMaster WHERE UserMaster.UserId = SalesReturnMaster.ClerkId) as Clerk, '' as CustomerName, (SELECT SUM(Qty) FROM SalesReturnDetails WHERE SalesReturnMasterId = SalesReturnMaster.SalesReturnMasterId) ticket,  ";
                        if (sFrom.Trim() != "" && sTo.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster where 1=1";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            dt1   = DateTime.Parse(sTo);
                            sTo   = dt1.ToString("yyyy-MM-dd");
                            sql  += " and (SalesReturnDate between '" + sFrom + " 00:00:01' and '" + sTo + " 23:59:59')";
                        }
                        else if (sFrom.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'' sTo FROM SalesReturnMaster where 1=1";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            sql  += " and SalesReturnDate >= '" + sFrom + " 00:00:01'";
                        }
                        else if (sTo.Trim() != "")
                        {
                            sql += "'' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster where 1=1";
                            dt1  = DateTime.Parse(sTo);
                            sTo  = dt1.ToString("yyyy-MM-dd");
                            sql += " and SalesReturnDate <= '" + sTo + " 23:59:59'";
                        }
                        else
                        {
                            sql += "'' sFrom,'' sTo FROM SalesReturnMaster where 1=1";
                        }
                        sql += " order by SalesReturnDate";

                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "SalesReturn.rpt";
                        break;

                    case "SalesReturnDetails":
                        sFrom = "" + Request.QueryString["fromd"];
                        sTo   = "" + Request.QueryString["tod"];
                        sql   = @" SELECT '1' as type, SalesReturnMaster.SalesReturnMasterId SalesMasterId, (select SalesMasterId from SalesDetails where SalesDetailId = SalesReturnDetails.SalesDetailId limit 1) as SalesId, DATE_FORMAT(SalesReturnDate,'%m/%d/%Y %h:%i %p') SalesReturnDate, SalesReturnMaster.Amount AS Amount,
                                    (select DATE_FORMAT(SalesDate,'%m/%d/%Y %h:%i %p') from SalesDetails, SalesReturnDetails, SalesMaster WHERE SalesMaster.`SalesMasterId` = SalesDetails.`SalesMasterId` AND SalesDetails.SalesDetailId = SalesReturnDetails.SalesDetailId and SalesReturnDetails.SalesReturnMasterId = SalesReturnMaster.SalesReturnMasterId limit 1) SalesDate, SalesReturnDetails.SerialNo,
                                    (SELECT NAME FROM LocationMaster WHERE LocationMaster.LocationId = SalesReturnMaster.LocationId) AS Location,
                                    (SELECT UserName FROM UserMaster WHERE UserMaster.UserId = SalesReturnMaster.ClerkId) AS Clerk, '' as CustomerName,
                                    (SELECT NAME FROM ProductMaster WHERE ProductMaster.ProductId = SalesReturnDetails.ProductId) AS Description,
                                    Qty AS Quantity, SalesReturnDetails.Amount AS Price,
                                    (SELECT CASE WHEN PaymentType=1 THEN 'Cash' WHEN PaymentType=2 THEN 'Card' Else 'Vouher' END FROM PaymentDetails WHERE SalesMasterId = SalesReturnMaster.SalesReturnMasterId) paytype,
                                    '' as authcode,";
                        if (sFrom.Trim() != "" && sTo.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster, SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId ";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            dt1   = DateTime.Parse(sTo);
                            sTo   = dt1.ToString("yyyy-MM-dd");
                            sql  += " and (SalesReturnMaster.SalesReturnDate between '" + sFrom + " 00:00:01' and '" + sTo + " 23:59:59')";
                        }
                        else if (sFrom.Trim() != "")
                        {
                            sql  += "'" + sFrom + "' sFrom,'' sTo FROM SalesReturnMaster,SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId";
                            dt1   = DateTime.Parse(sFrom);
                            sFrom = dt1.ToString("yyyy-MM-dd");
                            sql  += " and SalesReturnMaster.SalesReturnDate >= '" + sFrom + " 00:00:01'";
                        }
                        else if (sTo.Trim() != "")
                        {
                            sql += "'' sFrom,'" + sTo + "' sTo FROM SalesReturnMaster,SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId";
                            dt1  = DateTime.Parse(sTo);
                            sTo  = dt1.ToString("yyyy-MM-dd");
                            sql += " and SalesReturnMaster.SalesReturnDate <= '" + sTo + " 23:59:59'";
                        }
                        else
                        {
                            sql += "'' sFrom,'' sTo FROM SalesReturnMaster,SalesReturnDetails WHERE SalesReturnMaster.SalesReturnMasterId = SalesReturnDetails.SalesReturnMasterId";
                        }
                        sql += " order by SalesDate";


                        _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                        _reportname = "SalesReturnDetails.rpt";
                        break;

                    case "Users":
                        Users objUsers = new Users();
                        _datasource = objUsers.GetUsers();
                        _reportname = "Users.rpt";

                        break;
                    }
                    doc.Load(Server.MapPath("") + @"\" + _reportname);
                    if (_datasource != null)
                    {
                        doc.SetDataSource(_datasource);
                        if (_reportname == "Receipt.rpt")
                        {
                            string sql = "SELECT SalesDate, CustomerName,'' as `SalesTime`,CASE PaymentType WHEN 1 THEN 'Cash' WHEN 2 THEN CONCAT(CardType, ' ....',CardCheckNo) ELSE concat('Voucher No. ',CardCheckNo) END as PayType,case when CardAuthorizationId != 0 then CONCAT('Authorization:',CardAuthorizationId) else '' end as Authorization,Amount as PayAmount FROM SalesMaster,PaymentDetails  where SalesMaster.SalesMasterId = PaymentDetails.SalesMasterId and SalesMaster.SalesMasterId= " + SalesId;
                            _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                            doc.Subreports[0].SetDataSource(_datasource);

                            sql = @"SELECT concat(IFNULL((SELECT Name FROM ProductMaster WHERE ProductMaster.ProductId = SD.ProductId),''), IFNULL(SD.ProductName,'')) as Description, SUM(D.Qty) as Quantity, D.Amount as Price
                                    FROM SalesReturnDetails D, SalesDetails SD
                                    where D.SalesDetailId = SD.SalesDetailId and SD.SalesMasterId = " + SalesId + " GROUP by D.SalesDetailId";

                            _datasource = DBConn.ExecuteDataSet(sql, CommandType.Text).Tables[0];
                            doc.Subreports[1].SetDataSource(_datasource);
                            if (Request.QueryString["Dup"] == "yes")
                            {
                                doc.Subreports[0].ReportDefinition.Sections["ReportFooterSection1"].SectionFormat.EnableSuppress = true;
                            }
                        }
                    }

                    doc.SummaryInfo.ReportTitle = _reporttitle;
                    doc.RecordSelectionFormula  = _reportselectionformula;

                    if (_reportname == "CategorySummary.rpt" || _reportname == "VoucherSummary.rpt")
                    {
                        ((TextObject)doc.ReportDefinition.Sections["Section1"].ReportObjects["title"]).Text = "" + Request.QueryString["category_name"] + " Voucher Summary by Date";
                    }

                    CrViewer.HyperlinkTarget = "_blank";
                    //repObj.LoadParameterFields(doc, Request.QueryString["DataSource"]);
                    MaximizeWindow();
                    if (_printType == "DirectPrint")// Report.ReportOutPutEnum.DirectPrint.ToString())
                    {
                        CrViewer.SeparatePages = false;
                        //CrViewer.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
                    }

                    /*else if (_printType == Report.ReportOutPutEnum.ExportToPDF.ToString())
                     * {
                     *  MemoryStream oStream; // using System.IO
                     *  oStream = (MemoryStream)
                     *  doc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                     *  Response.Clear();
                     *  Response.Buffer = true;
                     *  if ("" + Request.QueryString["DataSource"] == "SIBREPORT")
                     *  {
                     *      string sFileName = "";
                     *      if ("" + ConfigurationManager.AppSettings["ExchId"] == "LULU")
                     *          sFileName = "LNF";
                     *      else
                     *          sFileName = "ANF";
                     *      sFileName = sFileName + DateTime.Parse(repObj.DateParameter1).ToString("ddMMyyyy") + repObj.StringParameter2; //objFgen.GetSIBFileName(tFun.Text);
                     *      sFileName = sFileName.Replace("/", "");
                     *      string fileName = Server.MapPath("files") + "\\" + sFileName;
                     *      Response.AddHeader("content-disposition", "attachment; filename=" + sFileName);
                     *  }
                     *  Response.ContentType = "application/pdf";
                     *  Response.BinaryWrite(oStream.ToArray());
                     *  Response.End();
                     * }
                     * else if (_printType == Report.ReportOutPutEnum.ExportToExcel.ToString())
                     * {
                     *  MemoryStream oStream; // using System.IO
                     *  oStream = (MemoryStream)
                     *  doc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                     *  Response.Clear();
                     *  Response.Buffer = true;
                     *  Response.ContentType = "application/vnd.ms-excel";
                     *  Response.BinaryWrite(oStream.ToArray());
                     *  Response.End();
                     * }
                     * else if (_printType == Report.ReportOutPutEnum.ExportToDoc.ToString())
                     * {
                     *  MemoryStream oStream; // using System.IO
                     *  oStream = (MemoryStream)
                     *  doc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.WordForWindows);
                     *  Response.Clear();
                     *  Response.Buffer = true;
                     *  Response.ContentType = "application/vnd.ms-word";
                     *  Response.BinaryWrite(oStream.ToArray());
                     *  Response.End();
                     * }*/
                    CrViewer.ReportSource = doc;
                    CrViewer.DataBind();
                }
            }
            catch (Exception E)
            {
                Response.Write(E.ToString());
            }
        }
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //Conexion a la base de datos
            MySqlConnection myConexion = new MySqlConnection(clsConexion.ConectionString);
            // Creando el command que ejecutare
            MySqlCommand myCommand = new MySqlCommand();
            // Creando el Data Adapter
            MySqlDataAdapter myAdapter = new MySqlDataAdapter();
            // Creando el String Builder
            StringBuilder sbQuery = new StringBuilder();
            // Otras variables del entorno
            string cWhere   = " WHERE 1 = 1";
            string cUsuario = "";
            string cTitulo  = "";

            try
            {
                // Abro conexion
                myConexion.Open();

                // Creo comando
                myCommand = myConexion.CreateCommand();

                // Adhiero el comando a la conexion
                myCommand.Connection = myConexion;

                // Filtros de la busqueda
                string fechadesde = dtDesde.Value.ToString("yyyy-MM-dd");
                string fechahasta = dtHasta.Value.ToString("yyyy-MM-dd");
                cWhere = cWhere + " AND combustible_salida.fecha >= " + "'" + fechadesde + "'" + " AND combustible_salida.fecha <= " + "'" + fechahasta + "'" + "";
                cWhere = cWhere + " AND movimientocombustible.tipo_movimiento = 'S'";

                // Filtros del tipo de Operaciones
                if (rbTerrestres.Checked == true)
                {
                    cWhere = cWhere + " AND movimientocombustible.operaciones = 'T'";
                }
                else if (rbMaritimas.Checked == true)
                {
                    cWhere = cWhere + " AND movimientocombustible.operaciones = 'M'";
                }

                if (chkDepartamentos.Checked == true)
                {
                    cWhere = cWhere + " AND combustible_salida.beneficiario_depto = " + this.cmbCombustible.SelectedValue + "";
                }

                if (chkAnuladas.Checked == true)
                {
                    cWhere = cWhere + " AND movimientocombustible.anulada = '1'";
                }
                else
                {
                    cWhere = cWhere + " AND movimientocombustible.anulada = '0'";
                }

                sbQuery.Clear();
                sbQuery.Append(" SELECT combustible_salida.id, sum(movimientocombustible.cantidad) as cantidad,");
                sbQuery.Append(" combustible_salida.beneficiario_depto,	combustible_salida.fecha, ");
                sbQuery.Append(" tipo_combustible.combustible as tipo_combustible, departamento_autoriza.departamento as autorizadopor, ");
                sbQuery.Append(" deptobeneficiario.deptobeneficiario as tipobeneficiario, tipo_combustible.medida");
                sbQuery.Append(" FROM combustible_salida");
                sbQuery.Append(" INNER JOIN movimientocombustible ON movimientocombustible.id = combustible_salida.id");
                sbQuery.Append(" INNER JOIN tipo_combustible ON tipo_combustible.id = movimientocombustible.tipo_combustible");
                sbQuery.Append(" INNER JOIN departamento_autoriza ON departamento_autoriza.id = combustible_salida.autorizadopor");
                sbQuery.Append(" INNER JOIN deptobeneficiario ON deptobeneficiario.id = combustible_salida.beneficiario_depto");
                sbQuery.Append(cWhere);
                sbQuery.Append(" GROUP BY tipo_combustible, tipobeneficiario");
                sbQuery.Append(" ORDER BY deptobeneficiario.id");

                // Paso los valores de sbQuery al CommandText
                myCommand.CommandText = sbQuery.ToString();
                // Creo el objeto Data Adapter y ejecuto el command en el
                myAdapter = new MySqlDataAdapter(myCommand);
                // Creo el objeto Data Table
                DataTable dtMovimientoCombustible = new DataTable();
                // Lleno el data adapter
                myAdapter.Fill(dtMovimientoCombustible);
                // Cierro el objeto conexion
                myConexion.Close();

                // Verifico cantidad de datos encontrados
                int nRegistro = dtMovimientoCombustible.Rows.Count;
                if (nRegistro == 0)
                {
                    MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema de Gestion de Combustible", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //1ero.HACEMOS LA COLECCION DE PARAMETROS
                    //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                    ParameterFields oParametrosCR = new ParameterFields();
                    //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                    ParameterValues oParametrosValuesCR = new ParameterValues();

                    //2do.CREAMOS LOS PARAMETROS
                    ParameterField oUsuario      = new ParameterField();
                    ParameterField oFechaInicial = new ParameterField();
                    ParameterField oFechaFinal   = new ParameterField();

                    //parametervaluetype especifica el TIPO de valor de parametro
                    //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                    oUsuario.ParameterValueType      = ParameterValueKind.StringParameter;
                    oFechaInicial.ParameterValueType = ParameterValueKind.DateTimeParameter;
                    oFechaFinal.ParameterValueType   = ParameterValueKind.DateTimeParameter;

                    //3ero.VALORES PARA LOS PARAMETROS
                    //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de
                    //parametros de valores discretos
                    ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                    oUsuarioDValue.Value = cUsuario;
                    ParameterDiscreteValue oFechaDValue = new ParameterDiscreteValue();
                    oFechaDValue.Value = fechadesde;
                    ParameterDiscreteValue oFechaFinDValue = new ParameterDiscreteValue();
                    oFechaFinDValue.Value = fechahasta;

                    //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                    oUsuario.CurrentValues.Add(oUsuarioDValue);
                    oFechaInicial.CurrentValues.Add(oFechaDValue);
                    oFechaFinal.CurrentValues.Add(oFechaFinDValue);

                    //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION
                    oParametrosCR.Add(oUsuario);
                    oParametrosCR.Add(oFechaInicial);
                    oParametrosCR.Add(oFechaFinal);

                    //nombre del parametro en CR (Crystal Reports)
                    oParametrosCR[0].Name = "cUsuario";
                    oParametrosCR[1].Name = "cFechaInicial";
                    oParametrosCR[2].Name = "cFechaFinal";

                    //nombre del TITULO DEL INFORME
                    cTitulo = "Reporte Estadístico de Despacho de Combustible";

                    //6to Instanciamos nuestro REPORTE
                    //Reportes.ListadoDoctores oListado = new Reportes.ListadoDoctores();
                    rptDespachoCombustibleResumido orptDespachoCombustibleResumido = new rptDespachoCombustibleResumido();

                    //pasamos el nombre del TITULO del Listado
                    //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                    // oListado.SummaryInfo.ReportTitle = cTitulo;
                    orptDespachoCombustibleResumido.SummaryInfo.ReportTitle = cTitulo;

                    //7mo. instanciamos nuestro el FORMULARIO donde esta nuestro ReportViewer
                    frmPrinter ofrmPrinter = new frmPrinter(dtMovimientoCombustible, orptDespachoCombustibleResumido, cTitulo);

                    //ParameterFieldInfo Obtiene o establece la colección de campos de parámetros.
                    ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                    ofrmPrinter.ShowDialog();
                }
            }
            catch (Exception myEx)
            {
                MessageBox.Show("Error : " + myEx.Message, "Mostrando Reporte", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                //ExceptionLog.LogError(myEx, false);
                return;
            }
        }
Пример #49
0
 public void AddValue(String name, String value)
 {
     ParameterValues.Add(new SingleParameter(name, value));
 }
Пример #50
0
        private async Task InsertAsync(DbContext context, bool skipSelect)
        {
            _parameters = new string[SqlColumns.Count];
            // var ts = DateTime.UtcNow;
            SqlText.AppendLine("SET NOCOUNT ON;");
            PrepareInsertSql();
            var returned = PrepareSelectSql(skipSelect);

            await ExecSqlAndUpdateBackAsync(SqlText.ToString(), context, Entity, returned, ParameterValues.ToArray());

            //Debug.WriteLine("  sql elapsed " + (DateTime.UtcNow - ts).TotalMilliseconds);

            /*
             *
             *  string sql = @"SET NOCOUNT ON;
             * INSERT INTO [RecipeNodes] ([ArticleId], [EnrichedArticleId], [IsActive], [IsDefault], [MigrationSourceId], [Name])
             * VALUES (@p0, @p1, @p2, @p3, @p4, @p5);
             * SELECT [Id]
             * FROM [RecipeNodes]
             * WHERE @@ROWCOUNT = 1 AND [Id] = scope_identity();";
             */
        }
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //Conexion a la base de datos
            MySqlConnection myConexion = new MySqlConnection(clsConexion.ConectionString);
            // Creando el command que ejecutare
            MySqlCommand myCommand = new MySqlCommand();
            // Creando el Data Adapter
            MySqlDataAdapter myAdapter = new MySqlDataAdapter();
            // Creando el String Builder
            StringBuilder sbQuery = new StringBuilder();
            // Otras variables del entorno
            string cWhere = " WHERE 1 = 1";
            string cUsuario = frmLogin.cUsuarioActual;
            string cTitulo = "";

            try
            {
                // Abro conexion
                myConexion.Open();
                // Creo comando
                myCommand = myConexion.CreateCommand();
                // Adhiero el comando a la conexion
                myCommand.Connection = myConexion;
                // Filtros de la busqueda
                //if (rbTodas.Checked)
                //{
                    string fechadesde = dtDesde.Value.ToString("yyyy-MM-dd");
                    string fechahasta = dtHasta.Value.ToString("yyyy-MM-dd");
                    cWhere = cWhere + " AND secuencia_solicitudcombustible.fecha >= " + "'" + fechadesde + "'" + " AND secuencia_solicitudcombustible.fecha <= " + "'" + fechahasta + "'" + "";
                    if (chkAnuladas.Checked == true)
                    {
                        cWhere = cWhere + " AND secuencia_solicitudcombustible.anulada = 1";
                    }
                    else
                    {
                        cWhere = cWhere + " AND secuencia_solicitudcombustible.anulada = 0";
                    }

                    sbQuery.Clear();
                    sbQuery.Append("SELECT secuencia_solicitudcombustible.id, solicitud.descripcion_combustible as tipocombustible, solicitud.cantidad, ");
                    sbQuery.Append(" secuencia_solicitudcombustible.fecha, secuencia_solicitudcombustible.nota");
                    sbQuery.Append(" FROM secuencia_solicitudcombustible ");
                    sbQuery.Append(" INNER JOIN solicitud ON solicitud.id = secuencia_solicitudcombustible.id");
                    //sbQuery.Append(" INNER JOIN tipo_combustible ON tipo_combustible.id = solicitud.tipo_combustible");
                    sbQuery.Append(cWhere);
                //}
                //else if (rbAprobadas.Checked)
                //{
                    //string fechadesde = dtDesde.Value.ToString("yyyy-MM-dd");
                    //string fechahasta = dtHasta.Value.ToString("yyyy-MM-dd");
                    //cWhere = cWhere + " AND fecha >= " + "'" + fechadesde + "'" + " AND fecha <= " + "'" + fechahasta + "'" + "";
                    //cWhere = cWhere + " AND status = 0";
                    //sbQuery.Clear();
                    //sbQuery.Append("SELECT solicitud.id, tipo_combustible.combustible as tipocombustible, solicitud.cantidad, ");
                    //sbQuery.Append(" solicitud.fecha, solicitud.nota");
                    //sbQuery.Append(" FROM solicitud ");
                    //sbQuery.Append(" INNER JOIN tipo_combustible ON tipo_combustible.id = solicitud.tipo_combustible");
                    //sbQuery.Append(cWhere);
                //}
                //else if (rbPendientes.Checked)
                //{
                    //string fechadesde = dtDesde.Value.ToString("yyyy-MM-dd");
                    //string fechahasta = dtHasta.Value.ToString("yyyy-MM-dd");
                    //cWhere = cWhere + " AND fecha >= " + "'" + fechadesde + "'" + " AND fecha <= " + "'" + fechahasta + "'" + "";
                    //cWhere = cWhere + " AND status = 1";
                    //sbQuery.Clear();
                    //sbQuery.Append("SELECT solicitud.id, tipo_combustible.combustible as tipocombustible, solicitud.cantidad, ");
                    //sbQuery.Append(" solicitud.fecha, solicitud.nota");
                    //sbQuery.Append(" FROM solicitud ");
                    //sbQuery.Append(" INNER JOIN tipo_combustible ON tipo_combustible.id = solicitud.tipo_combustible");
                    //sbQuery.Append(cWhere);
                //}

                // Paso los valores de sbQuery al CommandText
                myCommand.CommandText = sbQuery.ToString();
                // Creo el objeto Data Adapter y ejecuto el command en el
                myAdapter = new MySqlDataAdapter(myCommand);
                // Creo el objeto Data Table
                DataTable dtSolicitudCombustible = new DataTable();
                // Lleno el data adapter
                myAdapter.Fill(dtSolicitudCombustible);
                // Cierro el objeto conexion
                myConexion.Close();

                // Verifico cantidad de datos encontrados
                int nRegistro = dtSolicitudCombustible.Rows.Count;
                if (nRegistro == 0)
                {
                    MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema de Gestion de Combustible", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //1ero.HACEMOS LA COLECCION DE PARAMETROS
                    //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                    ParameterFields oParametrosCR = new ParameterFields();
                    //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                    ParameterValues oParametrosValuesCR = new ParameterValues();

                    //2do.CREAMOS LOS PARAMETROS
                    ParameterField oUsuario = new ParameterField();
                    ParameterField oFechaInicial = new ParameterField();
                    ParameterField oFechaFinal = new ParameterField();
                    //parametervaluetype especifica el TIPO de valor de parametro
                    //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                    oUsuario.ParameterValueType = ParameterValueKind.StringParameter;
                    oFechaInicial.ParameterValueType = ParameterValueKind.DateTimeParameter;
                    oFechaFinal.ParameterValueType = ParameterValueKind.DateTimeParameter;

                    //3ero.VALORES PARA LOS PARAMETROS
                    //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de
                    //parametros de valores discretos
                    ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                    oUsuarioDValue.Value = cUsuario;
                    ParameterDiscreteValue oFechaDValue = new ParameterDiscreteValue();
                    oFechaDValue.Value = fechadesde;
                    ParameterDiscreteValue oFechaFinDValue = new ParameterDiscreteValue();
                    oFechaFinDValue.Value = fechahasta;

                    //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                    oUsuario.CurrentValues.Add(oUsuarioDValue);
                    oFechaInicial.CurrentValues.Add(oFechaDValue);
                    oFechaFinal.CurrentValues.Add(oFechaFinDValue);

                    //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION
                    oParametrosCR.Add(oUsuario);
                    oParametrosCR.Add(oFechaInicial);
                    oParametrosCR.Add(oFechaFinal);
                    //nombre del parametro en CR (Crystal Reports)
                    oParametrosCR[0].Name = "cUsuario";
                    oParametrosCR[1].Name = "cFechaInicial";
                    oParametrosCR[2].Name = "cFechaFinal";

                    //nombre del TITULO DEL INFORME
                    cTitulo = "REPORTE DE SOLICITUDES DE COMBUSTIBLE";

                    //6to Instanciamos nuestro REPORTE
                    //Reportes.ListadoDoctores oListado = new Reportes.ListadoDoctores();
                    rptListadoSolicitudCombustible orptListadoSolicitudCombustible = new rptListadoSolicitudCombustible();

                    //pasamos el nombre del TITULO del Listado
                    //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                    // oListado.SummaryInfo.ReportTitle = cTitulo;
                    orptListadoSolicitudCombustible.SummaryInfo.ReportTitle = cTitulo;

                    //7mo. instanciamos nuestro el FORMULARIO donde esta nuestro ReportViewer
                    frmPrinter ofrmPrinter = new frmPrinter(dtSolicitudCombustible, orptListadoSolicitudCombustible, cTitulo);

                    //ParameterFieldInfo Obtiene o establece la colección de campos de parámetros.
                    ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                    ofrmPrinter.ShowDialog();
                }
            }
            catch (Exception myEx)
            {
                MessageBox.Show("Error : " + myEx.Message, "Mostrando Reporte", MessageBoxButtons.OK,
                                   MessageBoxIcon.Information);
                //ExceptionLog.LogError(myEx, false);
                return;
            }
        }
        private void frmRVentaTipoComprobante_Load(object sender, EventArgs e)
        {
            try
            {
                string   bandera     = frmReporteVentasTipoComprobante.f1.lblBandera.Text;
                string   fechaInicio = "";
                string   fechaFin    = "";
                DateTime fecIn;
                if (bandera == "1")
                {
                    fechaInicio = frmReporteVentasProducto.f1.dtpFechaInicio.Value.ToString("yyyy-MM-dd" + " 00:00:00");
                    fechaFin    = frmReporteVentasProducto.f1.dtpFechaFin.Value.ToString("yyyy-MM-dd" + " 23:59:59");
                }
                else
                {
                    fecIn       = Convert.ToDateTime(frmPrincipal.f1.lblFechaApertura.Text);
                    fechaInicio = fecIn.ToString("yyyy-MM-dd HH:mm:ss");

                    fechaFin = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                string tipo = frmReporteVentasTipoComprobante.f1.cbProducto.SelectedItem.ToString();

                ReportDocument repdoc = new ReportDocument();
                // repdoc.Load(@"C:\Users\vioma\OneDrive\Documentos\Visual Studio 2017\Projects\SisVentas_ResAlm\CapaPresentacion\Reportes/RVentaProducto.rpt");
                repdoc.Load(@"D:\Reportes\RVentaComprobante.rpt");

                ParameterFieldDefinitions pfds;
                ParameterFieldDefinition  pfd;

                ParameterValues        pvs = new ParameterValues();
                ParameterDiscreteValue pdv = new ParameterDiscreteValue();

                pdv.Value = Convert.ToDateTime(fechaInicio);
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaInicio"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);


                pdv.Value = Convert.ToDateTime(fechaFin);
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaFin"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                pdv.Value = tipo;
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@tipo"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);



                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo  crtableLogoninfo  = new TableLogOnInfo();
                ConnectionInfo  crConnectionInfo  = new ConnectionInfo();
                Tables          CrTables;
                crConnectionInfo.ServerName   = @"EQUIPO\SQLEXPRESS";
                crConnectionInfo.DatabaseName = "BD_RESTAURANTE";
                crConnectionInfo.UserID       = "admin";
                crConnectionInfo.Password     = "******";

                CrTables = repdoc.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }


                cvVentas.ReportSource = repdoc;
                cvVentas.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show("ERROR" + ex);
            }
        }
        private void btnImprimir_Click(object sender, EventArgs e)
        {

            //clsConexion a la base de datos
            MySqlConnection myclsConexion = new MySqlConnection(Conexion.ConectionString);
            // Creando el command que ejecutare
            MySqlCommand myCommand = new MySqlCommand();
            // Creando el Data Adapter
            MySqlDataAdapter myAdapter = new MySqlDataAdapter();
            // Creando el String Builder
            StringBuilder sbQuery = new StringBuilder();
            // Otras variables del entorno
            string cWhere = " WHERE 1 = 1";
            string cUsuario = ""; //frmLogin.cUsuarioActual;
            string cTitulo = "";

            try
            {
                // Abro clsConexion
                myclsConexion.Open();
                // Creo comando
                myCommand = myclsConexion.CreateCommand();
                // Adhiero el comando a la clsConexion
                myCommand.Connection = myclsConexion;
                
                // Filtros de la busqueda
                if (rbTodos.Checked)
                {
                    // CREANDO EL QUERY DE CONSULTA
                    //string fechadesde = fechaDesde.Value.ToString("yyyy-MM-dd");
                    //string fechahasta = fechaHasta.Value.ToString("yyyy-MM-dd");
                    //cWhere = cWhere + " AND fechacita >= "+"'"+ fechadesde +"'" +" AND fechacita <= "+"'"+ fechahasta +"'"+"";
                    //cWhere = cWhere + " AND year = '" + txtYear.Text + "'";
                    sbQuery.Clear();
                    sbQuery.Append("SELECT idcosecha as ID, fechacorte as Fecha, semana as Semana, campo as Campo, cinta_verde as Verde,");
                    sbQuery.Append(" cinta_azul as Azul, cinta_amarilla as Amarilla, cinta_marron as Marron, cinta_gris as Gris,");
                    sbQuery.Append(" cinta_roja as Roja, cinta_blanca as Blanca, cinta_negra as Negra, cantidadtotal as CantidadTotal,");
                    sbQuery.Append(" cantidadrechazos as CantidadRechazos");
                    //sbQuery.Append(" doctores.doctores_cedula,upper(CONCAT(doctores.doctores_nombre,' ',doctores.doctores_apellido)) as doctor,departamentos.departamento_descripcion");
                    sbQuery.Append(" FROM cosecha");
                    //sbQuery.Append(" INNER JOIN departamentos ON departamentos.departamento_id = cita.referimiento");
                    sbQuery.Append(cWhere);
                }
                else if (rbFecha.Checked)
                {                    
                    // CREANDO EL QUERY DE CONSULTA
                    string fechadesde = fechaDesde.Value.ToString("yyyy-MM-dd");
                    string fechahasta = fechaHasta.Value.ToString("yyyy-MM-dd");
                    cWhere = cWhere + " AND fechacorte >= "+"'"+ fechadesde +"'" +" AND fechacorte <= "+"'"+ fechahasta +"'"+"";
                    //cWhere = cWhere + " AND year = '" + txtYear.Text + "'";
                    sbQuery.Clear();
                    sbQuery.Append("SELECT idcosecha as ID, fechacorte as Fecha, semana as Semana, campo as Campo, cinta_verde as Verde,");
                    sbQuery.Append(" cinta_azul as Azul, cinta_amarilla as Amarilla, cinta_marron as Marron, cinta_gris as Gris,");
                    sbQuery.Append(" cinta_roja as Roja, cinta_blanca as Blanca, cinta_negra as Negra, cantidadtotal as CantidadTotal,");
                    sbQuery.Append(" cantidadrechazos as CantidadRechazos");
                    //sbQuery.Append(" doctores.doctores_cedula,upper(CONCAT(doctores.doctores_nombre,' ',doctores.doctores_apellido)) as doctor,departamentos.departamento_descripcion");
                    sbQuery.Append(" FROM cosecha");
                    //sbQuery.Append(" INNER JOIN departamentos ON departamentos.departamento_id = cita.referimiento");
                    sbQuery.Append(cWhere);
                }
                else if (rbSemana.Checked)
                {
                    // CREANDO EL QUERY DE CONSULTA
                    //DateTime year = fechaDesde.Value.Date.Year();
                    //cWhere = cWhere + " AND fechacorte >= " + "'" + fechadesde + "'" + " AND fechacorte <= " + "'" + fechahasta + "'" + "";                    
                    cWhere = cWhere + " AND semana = " + cmbSemana.SelectedValue + "";
                    sbQuery.Clear();
                    sbQuery.Append("SELECT idcosecha as ID, fechacorte as Fecha, semana as Semana, campo as Campo, cinta_verde as Verde,");
                    sbQuery.Append(" cinta_azul as Azul, cinta_amarilla as Amarilla, cinta_marron as Marron, cinta_gris as Gris,");
                    sbQuery.Append(" cinta_roja as Roja, cinta_blanca as Blanca, cinta_negra as Negra, cantidadtotal as CantidadTotal,");
                    sbQuery.Append(" cantidadrechazos as CantidadRechazos");
                    //sbQuery.Append(" doctores.doctores_cedula,upper(CONCAT(doctores.doctores_nombre,' ',doctores.doctores_apellido)) as doctor,departamentos.departamento_descripcion");
                    sbQuery.Append(" FROM cosecha");
                    //sbQuery.Append(" INNER JOIN departamentos ON departamentos.departamento_id = cita.referimiento");
                    sbQuery.Append(cWhere);
                }
                else if (rbFechaCampo.Checked)
                {
                    // CREANDO EL QUERY DE CONSULTA
                    string fechadesde = fechaDesde.Value.ToString("yyyy-MM-dd");
                    string fechahasta = fechaHasta.Value.ToString("yyyy-MM-dd");
                    cWhere = cWhere + " AND fechacorte >= " + "'" + fechadesde + "'" + " AND fechacorte <= " + "'" + fechahasta + "'" + "";                    
                    cWhere = cWhere + " AND campo = " + cmbCampo.SelectedValue + "";
                    sbQuery.Clear();
                    sbQuery.Append("SELECT idcosecha as ID, fechacorte as Fecha, semana as Semana, campo as Campo, cinta_verde as Verde,");
                    sbQuery.Append(" cinta_azul as Azul, cinta_amarilla as Amarilla, cinta_marron as Marron, cinta_gris as Gris,");
                    sbQuery.Append(" cinta_roja as Roja, cinta_blanca as Blanca, cinta_negra as Negra, cantidadtotal as CantidadTotal,");
                    sbQuery.Append(" cantidadrechazos as CantidadRechazos");
                    //sbQuery.Append(" doctores.doctores_cedula,upper(CONCAT(doctores.doctores_nombre,' ',doctores.doctores_apellido)) as doctor,departamentos.departamento_descripcion");
                    sbQuery.Append(" FROM cosecha");
                    //sbQuery.Append(" INNER JOIN departamentos ON departamentos.departamento_id = cita.referimiento");
                    sbQuery.Append(cWhere);
                }
                else
                {
                    MessageBox.Show("No se pueden generar reportes sin haber seleccionado un criterio...");                    
                }

                // Paso los valores de sbQuery al CommandText
                myCommand.CommandText = sbQuery.ToString();

                // Creo el objeto Data Adapter y ejecuto el command en el
                myAdapter = new MySqlDataAdapter(myCommand);

                // Creo el objeto Data Table
                DataTable dtCosecha = new DataTable();

                // Lleno el data adapter
                myAdapter.Fill(dtCosecha);

                // Cierro el objeto clsConexion
                myclsConexion.Close();

                // Verifico cantidad de datos encontrados
                int nRegistro = dtCosecha.Rows.Count;
                if (nRegistro == 0)
                {
                    MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema de Gestion Bananera", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //1ero.HACEMOS LA COLECCION DE PARAMETROS
                    //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                    ParameterFields oParametrosCR = new ParameterFields();
                    //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                    ParameterValues oParametrosValuesCR = new ParameterValues();

                    //2do.CREAMOS LOS PARAMETROS
                    ParameterField oUsuario = new ParameterField();
                    //parametervaluetype especifica el TIPO de valor de parametro
                    //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                    oUsuario.ParameterValueType = ParameterValueKind.StringParameter;

                    //3ero.VALORES PARA LOS PARAMETROS
                    //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de 
                    //parametros de valores discretos
                    ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                    oUsuarioDValue.Value = cUsuario;

                    //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                    oUsuario.CurrentValues.Add(oUsuarioDValue);


                    //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION 
                    oParametrosCR.Add(oUsuario);
                    //nombre del parametro en CR (Crystal Reports)
                    oParametrosCR[0].Name = "cUsuario";
                    //nombre del TITULO DEL INFORME
                    cTitulo = "REPORTE ESTADISTICOS DE LAS COSECHAS";

                    //6to Instanciamos nuestro REPORTE
                    //Reportes.ListadoDoctores oListado = new Reportes.ListadoDoctores();
                    REPORTES.rptCosechaCampo orptCosechaCampo = new REPORTES.rptCosechaCampo();
                    //pasamos el nombre del TITULO del Listado
                    //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                    // oListado.SummaryInfo.ReportTitle = cTitulo;
                    orptCosechaCampo.SummaryInfo.ReportTitle = cTitulo;

                    //7mo. instanciamos nuestro el FORMULARIO donde esta nuestro ReportViewer
                    frmPrinter ofrmPrinter = new frmPrinter(dtCosecha, orptCosechaCampo, cTitulo);
                    //ParameterFieldInfo Obtiene o establece la colección de campos de parámetros.                                                            
                    ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                    ofrmPrinter.ShowDialog();
                }


            }
            catch (Exception myEx)
            {
                MessageBox.Show("Error : " +  myEx.Message, "Mostrando Reporte", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                // clsExceptionLog.LogError(myEx, false);
                return;                
            }
        }
        private void Customer_Print_Load(object sender, EventArgs e)
        {
            if (typep)
            {
                ReportDocument cryRpt = new ReportDocument();
                cryRpt.Load(Application.StartupPath + @"\Customer Returned Report.rpt");


                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition  crParameterFieldDefinition;
                ParameterValues           crParameterValues        = new ParameterValues();
                ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();



                crParameterDiscreteValue.Value = Bill_ID;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["@Bill_ID"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = typep;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["@Bill_Type"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = custome_name;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Customer_Name"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Bill_Details;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Bill_Details"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Bill_ID;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["ID"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Bill_Total;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Bill_Total"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Discout;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Discout"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = old;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["old"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                crParameterDiscreteValue.Value = payment;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["payment"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crystalReportViewer1.ReportSource = cryRpt;
                crystalReportViewer1.Refresh();
            }
            else
            {
                string         path      = Application.StartupPath;
                string         directory = Path.GetDirectoryName(path);      //without file name
                string         oneUp     = Path.GetDirectoryName(directory); // Temp folder
                ReportDocument cryRpt    = new ReportDocument();
                cryRpt.Load(Application.StartupPath + @"\Customer Purchasing Rport.rpt");


                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition  crParameterFieldDefinition;
                ParameterValues           crParameterValues        = new ParameterValues();
                ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();



                crParameterDiscreteValue.Value = Bill_ID;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["@Bill_ID"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = typep;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["@Bill_Type"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = custome_name;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Customer_Name"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Bill_Details;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Bill_Details"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Bill_ID;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["ID"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Bill_Total;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Bill_Total"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = Discout;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Discout"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



                crParameterDiscreteValue.Value = old;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["old"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                crParameterDiscreteValue.Value = payment;
                crParameterFieldDefinitions    = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["payment"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);


                crystalReportViewer1.ReportSource = cryRpt;
                crystalReportViewer1.Refresh();
            }
        }
Пример #55
0
		private void SetParameters (ReportDocument Report)
		{
			ParameterFieldDefinition paramField;
			ParameterValues currentValues;
			ParameterDiscreteValue discreteParam;

			paramField = Report.DataDefinition.ParameterFields["CompanyName"];
			discreteParam = new ParameterDiscreteValue();
			discreteParam.Value = CompanyDetails.CompanyName;
			currentValues = new ParameterValues();
			currentValues.Add(discreteParam);
			paramField.ApplyCurrentValues(currentValues);

			paramField = Report.DataDefinition.ParameterFields["PrintedBy"];
			discreteParam = new ParameterDiscreteValue();
			discreteParam.Value = Session["Name"].ToString();
			currentValues = new ParameterValues();
			currentValues.Add(discreteParam);
			paramField.ApplyCurrentValues(currentValues);
		}
Пример #56
0
        private void frmRAbono_Load(object sender, EventArgs e)
        {
            try
            {
                ExcelFormatOptions objExcel    = new ExcelFormatOptions();
                string             bandera     = frmReporteAbono.f1.lblBandera.Text;
                string             fechaInicio = "";
                string             fechaFin    = "";
                DateTime           fecIn;
                if (bandera == "1")
                {
                    fechaInicio = frmReporteAbono.f1.dtpFechaInicio.Value.ToString("yyyy-MM-dd" + " 00:00:00");
                    fechaFin    = frmReporteAbono.f1.dtpFechaFin.Value.ToString("yyyy-MM-dd" + " 23:59:59");
                }
                else
                {
                    fecIn       = Convert.ToDateTime(frmPrincipal.f1.lblFechaApertura.Text);
                    fechaInicio = fecIn.ToString("yyyy-MM-dd HH:mm:ss");

                    fechaFin = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }


                ReportDocument repdoc = new ReportDocument();
                // repdoc.Load(@"C:\Users\vioma\OneDrive\Documentos\Visual Studio 2017\Projects\SISTEMAUCHPA_Barra1\CapaPresentacion\Reportes/RVentasCliente.rpt");
                repdoc.Load(@"D:\Reportes\RAbono.rpt");


                ParameterFieldDefinitions pfds;
                ParameterFieldDefinition  pfd;

                ParameterValues        pvs = new ParameterValues();
                ParameterDiscreteValue pdv = new ParameterDiscreteValue();


                pdv.Value = Convert.ToDateTime(fechaInicio);
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaInicio"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);


                pdv.Value = Convert.ToDateTime(fechaFin);
                pfds      = repdoc.DataDefinition.ParameterFields;
                pfd       = pfds["@fechaFin"];
                pvs.Add(pdv);
                pfd.ApplyCurrentValues(pvs);

                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo  crtableLogoninfo  = new TableLogOnInfo();
                ConnectionInfo  crConnectionInfo  = new ConnectionInfo();
                Tables          CrTables;


                crConnectionInfo.ServerName   = @"EQUIPO\SQLEXPRESS";
                crConnectionInfo.DatabaseName = "SIS_AVICOLA";
                crConnectionInfo.UserID       = "admin";
                crConnectionInfo.Password     = "******";

                /*crConnectionInfo.ServerName = @"EQUIPO\SQLEXPRESS";
                 * crConnectionInfo.DatabaseName = "db_restauranteAlmacen";
                 * crConnectionInfo.UserID = "martin";
                 * crConnectionInfo.Password = "******";*/

                CrTables = repdoc.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }


                cvVentas.ReportSource = repdoc;
                cvVentas.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show("ERROR" + ex);
            }
        }
Пример #57
0
    public static ReportDocument SetReportDoc(params string[] nums)
    {
        ReportDocument doc = new ReportDocument();

        try
        {
            string ReportPath = nums[0].ToString();
            doc.Load(ReportPath);
            for (int i = 3; i < nums.Length; i++)
            {
                string paramValue          = nums[i].ToString();
                ParameterDiscreteValue pdv = new ParameterDiscreteValue();
                pdv.Value = paramValue;
                ParameterValues pv = new ParameterValues();
                pv.Add(pdv);
                doc.DataDefinition.ParameterFields[i - 3].ApplyCurrentValues(pv);
            }
            if (doc.Database.Tables.Count > 0)
            {
                //for (int i = 0; i < doc.Database.Tables.Count; i++)
                //{
                //    doc.Database.Tables[i].ApplyLogOnInfo(LoginInfo());
                //}
                doc.Database.Tables[0].ApplyLogOnInfo(LoginInfo());
            }

            //Sections sections = doc.ReportDefinition.Sections;
            //foreach (Section section in sections)
            //{
            //    ReportObjects reportObjects = section.ReportObjects;
            //    foreach (ReportObject reportObject in reportObjects)
            //    {
            //        if (reportObject.Kind == ReportObjectKind.SubreportObject)
            //        {
            //            SubreportObject subreportObject = (SubreportObject)reportObject;
            //            ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
            //            if (subReportDocument.Database.Tables.Count > 0)
            //            {
            //                for (int i = 0; i < subReportDocument.Database.Tables.Count; i++)
            //                {
            //                    subReportDocument.Database.Tables[i].ApplyLogOnInfo(LoginInfo());
            //                }
            //                //subReportDocument.Database.Tables[0].ApplyLogOnInfo(LoginInfo());
            //            }
            //        }
            //    }
            //}

            if (nums[1].ToString().StartsWith("Y"))
            {
                //打印机名字
                doc.PrintOptions.PrinterName = nums[2].ToString();

                //设置打印边距
                //PageMargins margins;
                //margins = doc.PrintOptions.PageMargins;
                //margins.topMargin = 240; //567
                //margins.leftMargin = 240;
                //margins.rightMargin = 240;
                //margins.bottomMargin = 240;
                //doc.PrintOptions.ApplyPageMargins(margins);

                if (nums[1].ToString() == "Y1")
                {
                    doc.PrintOptions.PaperSize = PaperSize.PaperA4;
                }
                //else
                //{
                //    doc.PrintOptions.PaperOrientation = PaperOrientation.DefaultPaperOrientation;
                //    doc.PrintOptions.PaperSize = PaperSize.DefaultPaperSize;
                //}

                //打印份数,是否逐份打印,打印第一页,最后一页
                doc.PrintToPrinter(1, false, 0, 0);
            }
        }
        catch
        {
        }
        return(doc);
    }
Пример #58
0
 private void Button5_Click(object sender, EventArgs e)
 {
     try
     {
         cryRpt.Load(CHEMINRPT);
         ConnectionInfo connectionInfo  = new ConnectionInfo();
         ConnectionInfo connectionInfo2 = connectionInfo;
         connectionInfo2.ServerName         = "erp_db";
         connectionInfo2.DatabaseName       = "";
         connectionInfo2.UserID             = Globals.BDUSER;
         connectionInfo2.Password           = Globals.BDPW;
         connectionInfo2.IntegratedSecurity = true;
         connectionInfo2 = null;
         TableLogOnInfos tableLogOnInfos = new TableLogOnInfos();
         TableLogOnInfo  tableLogOnInfo  = new TableLogOnInfo();
         Tables          tables          = cryRpt.Database.Tables;
         IEnumerator     enumerator      = default(IEnumerator);
         try
         {
             enumerator = tables.GetEnumerator();
             while (enumerator.MoveNext())
             {
                 Table table = (Table)enumerator.Current;
                 tableLogOnInfo = table.LogOnInfo;
                 tableLogOnInfo.ConnectionInfo = connectionInfo;
                 table.ApplyLogOnInfo(tableLogOnInfo);
             }
         }
         finally
         {
             if (enumerator is IDisposable)
             {
                 (enumerator as IDisposable).Dispose();
             }
         }
         ParameterValues        parameterValues        = new ParameterValues();
         ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
         parameterDiscreteValue.Value = NUMFACT.Text;
         ParameterFieldDefinitions parameterFields          = cryRpt.DataDefinition.ParameterFields;
         ParameterFieldDefinition  parameterFieldDefinition = parameterFields[PARAMFACT];
         parameterValues = parameterFieldDefinition.CurrentValues;
         parameterValues.Clear();
         parameterValues.Add(parameterDiscreteValue);
         parameterFieldDefinition.ApplyCurrentValues(parameterValues);
         CRV.ReportSource = cryRpt;
         CRV.Refresh();
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         Exception ex2 = ex;
         MessageBox.Show(ex2.Message);
         ProjectData.ClearProjectError();
     }
     finally
     {
         if (Globals.conn != null)
         {
             Globals.conn.Close();
         }
     }
     try
     {
         DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();
         PdfRtfWordFormatOptions    formatOptions = new PdfRtfWordFormatOptions();
         NOMFICHJOINT = Nommail + " " + DateTime.Now.ToString("yyyy_MM_dd HH_mm_ss");
         diskFileDestinationOptions.DiskFileName = "C:\\SIGC utility\\Fichier joint\\" + NOMFICHJOINT + ".pdf";
         MyProject.Forms.Mail.chemin.Text        = "C:\\SIGC utility\\Fichier joint\\" + NOMFICHJOINT + ".pdf";
         ExportOptions exportOptions  = cryRpt.ExportOptions;
         ExportOptions exportOptions2 = exportOptions;
         exportOptions2.ExportDestinationType = ExportDestinationType.DiskFile;
         exportOptions2.ExportFormatType      = ExportFormatType.PortableDocFormat;
         exportOptions2.DestinationOptions    = diskFileDestinationOptions;
         exportOptions2.FormatOptions         = formatOptions;
         exportOptions2 = null;
         cryRpt.Export();
         MyProject.Forms.Mail.Show();
         MyProject.Forms.Mail.BringToFront();
         MyProject.Forms.Mail.pathT.Text = "C:\\SIGC utility\\Fichier joint\\" + NOMFICHJOINT + ".pdf";
         MyProject.Forms.Mail.AjoutFJ_Click(RuntimeHelpers.GetObjectValue(sender), e);
     }
     catch (Exception ex3)
     {
         ProjectData.SetProjectError(ex3);
         Exception ex4 = ex3;
         Interaction.MsgBox(ex4.ToString(), MsgBoxStyle.OkOnly, null);
         ProjectData.ClearProjectError();
     }
 }
Пример #59
0
        public void SetParameter(string parameterName, params object[] parameters)
        {
            ParameterValues currentParameterValues = new ParameterValues();

            for (int i = 0; i < parameters.Length; i++)
            {
                ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
                parameterDiscreteValue.Value = parameters[i].ToString();
                currentParameterValues.Add(parameterDiscreteValue);
            }

            ParameterFieldDefinitions parameterFieldDefinitions = _report.DataDefinition.ParameterFields;
            ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[parameterName];
            parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
        }
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            string cTitulo  = "";
            string cUsuario = frmLogin.cUsuarioActual;;

            if (txtCedula.Text == "" || txtID.Text == "")
            {
                MessageBox.Show("El Campo Cedulo o ID no Debe Estar en Blanco, Favor Verificar", "Sistema Medico", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    StringBuilder    sbQuery        = new StringBuilder();
                    MySqlConnection  oMiclsConexion = new MySqlConnection(cclsConexion);
                    MySqlCommand     oComando       = new MySqlCommand();
                    MySqlDataAdapter oAdaptador     = new MySqlDataAdapter();
                    DataTable        dtPaciente     = new DataTable();

                    oMiclsConexion.Open();
                    oComando            = oMiclsConexion.CreateCommand();
                    oComando.Connection = oMiclsConexion;

                    sbQuery.Clear();
                    sbQuery.Append("SELECT paciente.id_paciente,paciente.cedula,paciente.nombre,");
                    sbQuery.Append("paciente.apellido,paciente.edad,paciente.sexo,paciente.dato_nacimiento,");
                    sbQuery.Append("paciente.dato_alimentacion, paciente.dato_condicionespsicologicas, ");
                    sbQuery.Append("paciente.dato_sexualidad, paciente.dato_operaciones, ");
                    sbQuery.Append("paciente.dato_intoleranciamedicinal, paciente.dato_saludpadres, ");
                    sbQuery.Append("paciente.dato_saludhermanos, paciente.dato_saludesposahijos,");
                    sbQuery.Append("paciente.dato_saludfamiliargeneral, paciente.fecharegistro, paciente.fechaupdate,");
                    sbQuery.Append("rangos.rango_descripcion");
                    sbQuery.Append(" from paciente");
                    sbQuery.Append(" inner join rangos on rangos.rango_id = paciente.rango");
                    sbQuery.Append(" where paciente.id_paciente = " + txtID.Text + "");
                    //sbQuery.Append("");
                    //sbQuery.Append("");
                    //sbQuery.Append("");


                    oComando.CommandText = sbQuery.ToString();
                    oAdaptador           = new MySqlDataAdapter(oComando);
                    oAdaptador.Fill(dtPaciente);
                    //oComando.Dispose();
                    //oMiclsConexion.Close();

                    int nRegistros = dtPaciente.Rows.Count;
                    if (nRegistros == 0)
                    {
                        MessageBox.Show("No Hay Datos Para Mostrar, Favor Verificar", "Sistema Medico", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        //1ero.HACEMOS LA COLECCION DE PARAMETROS

                        //los campos de parametros contiene un objeto para cada campo de parametro en el informe
                        ParameterFields oParametrosCR = new ParameterFields();
                        //Proporciona propiedades para la recuperacion y configuracion del tipo de los parametros
                        ParameterValues oParametrosValuesCR = new ParameterValues();

                        //2do.CREAMOS LOS PARAMETROS
                        ParameterField oUsuario = new ParameterField();
                        //parametervaluetype especifica el TIPO de valor de parametro
                        //ParameterValueKind especifica el tipo de valor de parametro en la PARAMETERVALUETYPE de la Clase PARAMETERFIELD
                        oUsuario.ParameterValueType = ParameterValueKind.StringParameter;

                        //3ero.VALORES PARA LOS PARAMETROS
                        //ParameterDiscreteValue proporciona propiedades para la recuperacion y configuracion de
                        //parametros de valores discretos
                        ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                        oUsuarioDValue.Value = cUsuario;

                        //4to. AGREGAMOS LOS VALORES A LOS PARAMETROS
                        oUsuario.CurrentValues.Add(oUsuarioDValue);


                        //5to. AGREGAMOS LOS PARAMETROS A LA COLECCION
                        oParametrosCR.Add(oUsuario);

                        //nombre del parametro en CR (Crystal Reports)
                        oParametrosCR[0].Name = "cUsuario";

                        //nombre del TITULO DEL INFORME
                        cTitulo = "ANTECEDENTES PERSONALES";

                        //6to Instanciamos nuestro REPORTE

                        Reportes.RepAntecedentes oRepAntecedente = new Reportes.RepAntecedentes();
                        //pasamos el nombre del TITULO del Listado
                        //SumaryInfo es un objeto que se utiliza para leer,crear y actualizar las propiedades del reporte
                        oRepAntecedente.SummaryInfo.ReportTitle = cTitulo;

                        frmPrinter oFrmPrinter = new frmPrinter(dtPaciente, oRepAntecedente, cTitulo);
                        oFrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                        oFrmPrinter.ShowDialog();
                    }
                }
                catch (Exception myEx)
                {
                    //MessageBox.Show(myEx.Message);
                    //throw;
                }
            }
        }