private void btnReportBBBG_Click(object sender, EventArgs e)
        {
            if (grvDecleration.SelectedRows.Count == 0)
            {
                MessageBox.Show("Bạn cần chọn 1 tờ khai để in biên bản bàn giao.");
                return;
            }
            var declerationId = Convert.ToInt64(grvDecleration.SelectedRows[0].Cells["DeclarationID"].Value);
            // Get Decleration information
            var declarationInfo = DeclarationFactory.GetByID(declerationId);

            ECustoms.HandoverTempImportReExport report = new HandoverTempImportReExport();
            // Cuc hai quan
            ((TextObject)report.Section1.ReportObjects["SuperiorCompany"]).Text = GetUserConfig().ToUpper();
            // Chi cuc hai quan
            ((TextObject)report.Section1.ReportObjects["CompanyName"]).Text = GlobalInfo.CompanyName.ToUpper();

            //((TextObject)report.Section1.ReportObjects["txtHandoverNumber"]).Text = declarationInfo.NumberHandover!=null? declarationInfo.NumberHandover.ToString() : ""; 

            if (declarationInfo.DateHandover != null)
            {
                ((TextObject)report.Section1.ReportObjects["txtDate"]).Text = "Hồi " + declarationInfo.DateHandover.Value.Hour + " giờ " + declarationInfo.DateHandover.Value.Minute + " phút, " + "ngày " + declarationInfo.DateHandover.Value.Day + " tháng " + declarationInfo.DateHandover.Value.Month + " năm " + declarationInfo.DateHandover.Value.Year + ",";
            }

            // Chi cuc hai quan
            ((TextObject)report.Section1.ReportObjects["txtBranchName"]).Text = GlobalInfo.CompanyName.ToUpper();

            ((TextObject)report.Section1.ReportObjects["txtCompany"]).Text = declarationInfo.CompanyName;
            ((TextObject)report.Section1.ReportObjects["txtNumber"]).Text = declarationInfo.Number.ToString();

            StringBuilder buffer = new StringBuilder();
            buffer.Append(" SELECT    * FROM ViewAllDeclarationTNTX ");
            buffer.Append(" WHERE ");
            buffer.Append(" DeclarationID = " + declerationId);

            var connection = new SqlConnection(Common.Decrypt(System.Configuration.ConfigurationSettings.AppSettings["connectionString"], true));

            var adpater = new SqlDataAdapter(buffer.ToString(), connection);
            var dt = new DataTable();
            adpater.Fill(dt);
            report.SetDataSource(dt);
            //preview report
            var reportForm = new FrmCrystalReport(report, _userInfo);
            reportForm.MaximizeBox = true;
            reportForm.Show(this);
        }
        private void btnPrintReport_Click(object sender, EventArgs e)
        {
            ECustoms.HandoverStatisticReport report = new HandoverStatisticReport();
            // Cuc hai quan
            ((TextObject)report.Section1.ReportObjects["SuperiorCompany"]).Text = GetUserConfig().ToUpper();
            // Chi cuc hai quan
            ((TextObject)report.Section1.ReportObjects["CompanyName"]).Text = GlobalInfo.CompanyName.ToUpper();

            //StringBuilder buffer = new StringBuilder();
            //buffer.Append(" SELECT * FROM ViewAllDeclarationTNTX ");
            //buffer.Append(" WHERE DeclarationID != 0 AND DeclarationID != 1 ");


            //var connection = new SqlConnection(Common.Decrypt(System.Configuration.ConfigurationSettings.AppSettings["connectionString"], true));

            //var adpater = new SqlDataAdapter(buffer.ToString(), connection);
            //var dt = new DataTable();
            //adpater.Fill(dt);
            //report.SetDataSource(dt);

            DataSet2 dataSet2 = new DataSet2();
            DataTable table1 = dataSet2.ViewAllDeclarationTNTX;
            foreach (ViewAllDeclaration obj in _listDeclarationinfo)
            {
                table1.Rows.Add(
                    obj.DeclarationID,
                    obj.Number,
                    null,
                    null,
                    null,
                    obj.Unit,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    obj.Type,
                    null,
                    obj.RegisterDate,
                    null,
                    null,
                    null,
                    obj.RegisterPlace,
                    null,
                    obj.NumberHandover,
                    obj.DateHandover,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    obj.Seal,
                    1,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null);
            }

            report.SetDataSource(dataSet2);
            //preview report
            var reportForm = new FrmCrystalReport(report, _userInfo);
            reportForm.MaximizeBox = true;
            reportForm.Show(this);

        }
Пример #3
0
 /// <summary>
 /// Get DataTable to report
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if ((cbReportType.SelectedValue + "").Equals(""))
     {
         MessageBox.Show(this,"Chưa chọn loại báo cáo","Cảnh báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
         return;
     }
     try
     {
         var from = new DateTime(dtpExportFrom.Value.Year, dtpExportFrom.Value.Month, dtpExportFrom.Value.Day, 0, 0, 0);
         var to = new DateTime(dtpExportTo.Value.Year, dtpExportTo.Value.Month, dtpExportTo.Value.Day, 23, 59, 59);
         var reportType = GetReportType(Int32.Parse(cbReportType.SelectedValue + ""));
         var branchId = cbUnit.SelectedValue.ToString();
         var type = cbType.SelectedValue.ToString();
         var report = new FrmCrystalReport(reportType, from, to, _userInfo, branchId, type);
         report.MaximizeBox = true;
         report.Show(this);
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
     }
     
 }
        private void btnReportQC_Click(object sender, EventArgs e)
        {
            // Get Decleration information
            var declarationInfo = DeclarationFactory.GetByID(this._declerationID);

            var report = new HandoverQuaCanh();
            // Cuc hai quan
            ((TextObject)report.Section1.ReportObjects["SuperiorCompany"]).Text = GetUserConfig().ToUpper();
            // Chi cuc hai quan
            ((TextObject)report.Section1.ReportObjects["CompanyName"]).Text = GlobalInfo.CompanyName.ToUpper();

            //((TextObject)report.Section1.ReportObjects["txtHandoverNumber"]).Text = declarationInfo.NumberHandover!=null? declarationInfo.NumberHandover.ToString() : ""; 

            if (declarationInfo.DateHandover != null)
            {
                ((TextObject)report.Section1.ReportObjects["txtDate"]).Text = "Hồi " + declarationInfo.DateHandover.Value.Hour + " giờ " + declarationInfo.DateHandover.Value.Minute + " phút, " + "ngày " + declarationInfo.DateHandover.Value.Day + " tháng " + declarationInfo.DateHandover.Value.Month + " năm " + declarationInfo.DateHandover.Value.Year + ",";
            }

            // Chi cuc hai quan
            ((TextObject)report.Section1.ReportObjects["txtBranchName"]).Text = GlobalInfo.CompanyName.ToUpper();
            ((TextObject)report.Section1.ReportObjects["txtBranchName"]).Text = GlobalInfo.CompanyName.ToUpper();

            ((TextObject)report.Section1.ReportObjects["txtCompany"]).Text = declarationInfo.CompanyName;
            ((TextObject)report.Section1.ReportObjects["txtNumber"]).Text = declarationInfo.Number.ToString();

            StringBuilder buffer = new StringBuilder();
            buffer.Append(" SELECT    * FROM ViewAllDeclarationTNTX ");
            buffer.Append(" WHERE ");
            buffer.Append(" DeclarationID = " + _declerationID);

            var connection = new SqlConnection(Common.Decrypt(System.Configuration.ConfigurationSettings.AppSettings["connectionString"], true));

            var adpater = new SqlDataAdapter(buffer.ToString(), connection);
            var dt = new DataTable();
            adpater.Fill(dt);
            report.SetDataSource(dt);
            //preview report
            var reportForm = new FrmCrystalReport(report, _userInfo);
            reportForm.MaximizeBox = true;
            reportForm.Show(this);
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (cbFeeExport.Checked == false && cbFeeImport.Checked == false)
            {
                MessageBox.Show("Bạn cần chọn loại báo cáo");
                return;
            }
            try
            {

                var dateImportValueFrom = new DateTime(dtpImportFrom.Value.Year, dtpImportFrom.Value.Month, dtpImportFrom.Value.Day, 0, 0, 0);
                var dateImportValueTo = new DateTime(dtpImportTo.Value.Year, dtpImportTo.Value.Month, dtpImportTo.Value.Day, 23, 59, 59);

                var dateExportValueFrom = new DateTime(dtpExportFrom.Value.Year, dtpExportFrom.Value.Month, dtpExportFrom.Value.Day, 0, 0, 0);
                var dateExportValueTo = new DateTime(dtpExportTo.Value.Year, dtpExportTo.Value.Month, dtpExportTo.Value.Day, 23, 59, 59);


                var vehicleFeeReport = new VehicleFeeReport();

                var connection = new SqlConnection(Common.Decrypt(System.Configuration.ConfigurationSettings.AppSettings["connectionString"], true));
                ((TextObject)vehicleFeeReport.Section1.ReportObjects["CompanyName"]).Text = GlobalInfo.CompanyName.ToUpper();

                var createdBy = (TextObject)vehicleFeeReport.Section1.ReportObjects["CreatedBy"];
                createdBy.Text = _userInfo.Name;

                var dateImportFrom = (TextObject)vehicleFeeReport.Section1.ReportObjects["dateImportFrom"];
                dateImportFrom.Text = dtpImportFrom.Value.ToString("dd/MM/yyy");

                var dateImportTo = (TextObject)vehicleFeeReport.Section1.ReportObjects["dateImportTo"];
                dateImportTo.Text = dtpImportTo.Value.ToString("dd/MM/yyy");


                var dateExportFrom = (TextObject)vehicleFeeReport.Section1.ReportObjects["dateExportFrom"];
                dateExportFrom.Text = dtpExportFrom.Value.ToString("dd/MM/yyy");

                var dateExportTo = (TextObject)vehicleFeeReport.Section1.ReportObjects["dateExportTo"];
                dateExportTo.Text = dtpExportTo.Value.ToString("dd/MM/yyy");


                var sql = new StringBuilder();

                if (cbFeeImport.Checked == true && cbFeeExport.Checked == false)
                {
                    dateExportFrom.Text = "";
                    dateExportTo.Text = "";
                    sql.Append("select * from ViewVehicleFee");

                    sql.Append(" where FeeTypeID=2");

                    sql.Append(" AND  FeeDate >= '" + dateImportValueFrom.ToString("yyyy-MM-dd HH:mm"));
                    sql.Append("' AND FeeDate < = '" + dateImportValueTo.ToString("yyyy-MM-dd HH:mm") + "'");
                }


                if (cbFeeImport.Checked == false && cbFeeExport.Checked == true)
                {
                    dateImportFrom.Text = "";
                    dateImportTo.Text = "";
                    sql.Append("select * from ViewVehicleFee");

                    sql.Append(" where FeeTypeID=1");

                    sql.Append(" AND  FeeDate >= '" + dateExportValueFrom.ToString("yyyy-MM-dd HH:mm"));
                    sql.Append("' AND FeeDate < = '" + dateExportValueTo.ToString("yyyy-MM-dd HH:mm") + "'");
                }


                if (cbFeeImport.Checked == true && cbFeeExport.Checked == true)
                {
                    sql.Append("select * from ViewVehicleFee");

                    sql.Append(" where (FeeTypeID=1");

                    sql.Append(" AND  FeeDate >= '" + dateExportValueFrom.ToString("yyyy-MM-dd HH:mm"));
                    sql.Append("' AND FeeDate < = '" + dateExportValueTo.ToString("yyyy-MM-dd HH:mm") + "')");

                    sql.Append(" OR (FeeTypeID=2");

                    sql.Append(" AND  FeeDate >= '" + dateImportValueFrom.ToString("yyyy-MM-dd HH:mm"));
                    sql.Append("' AND FeeDate < = '" + dateImportValueTo.ToString("yyyy-MM-dd HH:mm") + "')");
                }

                var adpater = new SqlDataAdapter(sql.ToString(), connection);
                var dt = new DataTable();
                adpater.Fill(dt);
                vehicleFeeReport.SetDataSource(dt);
                adpater.Dispose();
                FrmCrystalReport frmReport = new FrmCrystalReport(vehicleFeeReport);
                frmReport.MaximizeBox = true;
                frmReport.Show(this); 
            }
            catch (Exception ex)
            {
            }
        }