Ejemplo n.º 1
0
        /// <summary>
        /// We have parsed the 'General' element so now parse the items
        /// within this section noting that we terminate parsing when we reach the end
        /// of the section.
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ReadGeneral(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_GENERAL_AUTHOR:
                    _author = childElement.Text;
                    break;

                case V_GENERAL_TYPE:
                    _reportType = (eReportType)childElement.TextAsInt;
                    break;

                case V_GENERAL_NAME:
                    _name = childElement.Text;
                    break;

                case V_GENERAL_DESCRIPTION:
                    _description = childElement.Text;
                    break;

                case V_GENERAL_VERSION:
                    _currentVersion = childElement.Text;
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private string GenerateBodyText(XmlDocument doc, eReportType reportType, string reportUrl)
        {
            string companyName          = System.Configuration.ConfigurationManager.AppSettings["CompanyName"];
            string addressLine1         = System.Configuration.ConfigurationManager.AppSettings["Address1.Line1"];
            string addressLine2         = System.Configuration.ConfigurationManager.AppSettings["Address1.Line2"];
            string addressLine3         = System.Configuration.ConfigurationManager.AppSettings["Address1.Line3"];
            string companyLogoImageName = System.Configuration.ConfigurationManager.AppSettings["CompanyLogoImageName"];

            XslCompiledTransform transformer = new XslCompiledTransform();

            transformer.Load(HttpContext.Current.Server.MapPath(@"~/xsl/reportType.xsl"));
            XmlUrlResolver resolver  = new XmlUrlResolver();
            XPathNavigator navigator = doc.CreateNavigator();

            XsltArgumentList args = new XsltArgumentList();

            args.AddParam("WebServer", "", Orchestrator.Globals.Configuration.WebServer);
            args.AddParam("ReportType", "", Utilities.UnCamelCase(Enum.GetName(typeof(eReportType), reportType)));
            args.AddParam("ReportUrl", "", reportUrl);
            args.AddParam("CompanyName", "", companyName);
            args.AddParam("AddressLine1", "", addressLine1);
            args.AddParam("AddressLine2", "", addressLine2);
            args.AddParam("AddressLine3", "", addressLine3);
            args.AddParam("CompanyLogoImageName", "", "cid:" + companyLogoImageName);

            StringWriter sw = new StringWriter();

            transformer.Transform(navigator, args, sw);

            string content = sw.GetStringBuilder().ToString();

            return(content);
        }
Ejemplo n.º 3
0
        private void LoadPILReport()
        {
            NameValueCollection reportParams = new NameValueCollection();
            DataSet             dsPIL        = null;

            string OrderIDs        = string.Empty;
            bool   isPalletNetwork = false;

            foreach (GridDataItem item in grdOrders.SelectedItems)
            {
                isPalletNetwork = (bool)item.OwnerTableView.DataKeyValues[item.ItemIndex]["IsPalletNetwork"];
                OrderIDs       += item.OwnerTableView.DataKeyValues[item.ItemIndex]["OrderID"].ToString();
                OrderIDs       += ",";
            }

            Orchestrator.Facade.ICollectDropLoadOrder facLoadOrder = new Orchestrator.Facade.CollectDrop();

            if (OrderIDs.Length > 0)
            {
                #region Pop-up Report

                eReportType reportType = eReportType.PIL;
                dsPIL = facLoadOrder.GetPILData(OrderIDs.ToString());
                DataView dvPIL;

                if (isPalletNetwork)
                {
                    reportType = Orchestrator.Globals.Configuration.PalletNetworkLabelID;

                    //Need to duplicate the rows for the Pallteforce labels
                    dsPIL.Tables[0].Merge(dsPIL.Tables[0].Copy(), true);
                    dvPIL = new DataView(dsPIL.Tables[0], string.Empty, "OrderId, PalletCount", DataViewRowState.CurrentRows);
                }
                else
                {
                    dvPIL = new DataView(dsPIL.Tables[0]);
                }

                //-------------------------------------------------------------------------------------
                //									Load Report Section
                //-------------------------------------------------------------------------------------
                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = reportType;
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = dvPIL;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = String.Empty;
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                // Show the user control
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');</script>");
                #endregion
            }
        }
Ejemplo n.º 4
0
        void btnCreatePIL_Click(object sender, EventArgs e)
        {
            NameValueCollection reportParams = new NameValueCollection();
            DataSet             dsPIL        = null;

            Orchestrator.Facade.ICollectDropLoadOrder facLoadOrder = new Orchestrator.Facade.CollectDrop();

            if (OrderID != -1)
            {
                #region Pop-up Report
                eReportType reportType = eReportType.PIL;
                dsPIL = facLoadOrder.GetPILData(OrderID.ToString());
                DataView dvPIL;

                if ((bool)dsPIL.Tables[0].Rows[0]["IsPalletNetwork"])
                {
                    reportType = Globals.Configuration.PalletNetworkLabelID;

                    //Need to duplicate the rows for the Pallteforce labels
                    dsPIL.Tables[0].Merge(dsPIL.Tables[0].Copy(), true);
                    dvPIL = new DataView(dsPIL.Tables[0], string.Empty, "OrderId, PalletCount", DataViewRowState.CurrentRows);
                }
                else
                {
                    dvPIL = new DataView(dsPIL.Tables[0]);
                }

                //-------------------------------------------------------------------------------------
                //									Load Report Section
                //-------------------------------------------------------------------------------------
                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = reportType;
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = dvPIL;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = String.Empty;
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                //string url = this.Request.Url.AbsoluteUri;
                //if (url.LastIndexOf("&action") > 0)
                //    url = url.Remove(url.LastIndexOf("&action"));

                //Response.Redirect(url + "&action=pil");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');", true);

                #endregion
            }
        }
Ejemplo n.º 5
0
        private ReportBase GetCurrentActiveReport(out eReportType reportType)
        {
            var session = HttpContext.Current.Session;

            ReportBase activeReport = null;
            bool       enforceDataExistence;

            reportType   = (eReportType)session[Orchestrator.Globals.Constants.ReportTypeSessionVariable];
            activeReport = Orchestrator.Reports.Utilities.GetActiveReport(reportType, string.Empty, out enforceDataExistence);

            if (activeReport != null)
            {
                DataView view = null;
                DataSet  ds   = null;

                var dse = session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];

                if (dse is DataView)
                {
                    activeReport.DataSource = dse;
                }
                else
                {
                    ds = (DataSet)session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];
                }

                var sortExpression = (string)session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable];

                if (sortExpression.Length > 0 && dse is DataSet)
                {
                    view      = new DataView(ds.Tables[0]);
                    view.Sort = sortExpression;
                    activeReport.DataSource = view;
                }
                else if (dse is DataSet)
                {
                    activeReport.DataSource = ds;
                }

                activeReport.DataMember = (string)session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable];
                activeReport.Document.Printer.PrinterName = string.Empty;
                activeReport.Document.Printer.PaperKind   = System.Drawing.Printing.PaperKind.A4;
                activeReport.Run(false);
            }

            return(activeReport);
        }
Ejemplo n.º 6
0
        public void btnResend_Click(object sender, EventArgs e)
        {
            int         count         = int.MinValue;
            long        transactionId = long.MinValue;
            string      faxNumber     = string.Empty;
            eReportType reportType    = 0;

            InterFax.InterFax myInterFax;

            count = dgFaxes.SelectedItems.Count;
            if (count != 0)
            {
                // Should only have one select as this is multiple selects on the grid are not allowed.
                foreach (ComponentArt.Web.UI.GridItem item in dgFaxes.SelectedItems)
                {
                    transactionId = Convert.ToInt64(item["TransactionId"]);
                    faxNumber     = item["FaxNumber"].ToString();
                    reportType    = (eReportType)Enum.Parse(typeof(eReportType), item["Description"].ToString());
                }

                myInterFax = new InterFax.InterFax();
                long returnedTransactionId = myInterFax.ReSendFax(Configuration.InterFaxUserName, Configuration.InterFaxPassword, transactionId, faxNumber);

                if (returnedTransactionId > 0)
                {
                    Facade.IAudit facAudit = new Facade.Audit();
                    facAudit.FaxSent(reportType, returnedTransactionId, faxNumber, ((Entities.CustomPrincipal)Page.User).UserName);

                    lblConfirmation.Text = "The fax was resent.";

                    // Cause the data to be updated.
                    BindFaxData();
                }
                else
                {
                    lblConfirmation.Text = "The fax was not resent.";
                    Orchestrator.Logging.ApplicationLog.WriteError("Orchestrator.WebUI.adminstration.audit.sentFaxes.ResendFax", "Fax resend failed: " + returnedTransactionId);
                }

                lblConfirmation.Visible = true;
            }
        }
Ejemplo n.º 7
0
        private int SaveReportPdf(eReportType reportType, byte[] bytes, string userName)
        {
            var uploaderPath = Globals.Configuration.OrchestratorServerUploaderPdfsPath;

            if (string.IsNullOrEmpty(uploaderPath))
            {
                throw new ApplicationException("Cannot email report: the OrchestratorServerUploaderPdfsPath setting has not been configured.");
            }

            if (!Directory.Exists(uploaderPath))
            {
                Directory.CreateDirectory(uploaderPath);
            }

            var sendNowPath = Path.Combine(uploaderPath, "sendnow");

            if (!Directory.Exists(sendNowPath))
            {
                Directory.CreateDirectory(sendNowPath);
            }

            var fileName        = string.Format("EmailedReport_{0}_{1}_{2:yyyyMMddHHmmss}.pdf", Enum.GetName(typeof(eReportType), reportType), userName, DateTime.Now);
            var fileNameAndPath = Globals.Configuration.ScanFormSendNow ? Path.Combine(sendNowPath, fileName) : Path.Combine(uploaderPath, fileName);

            File.WriteAllBytes(fileNameAndPath, bytes);

            var facForm = new Facade.Form();

            var bookingForm = new Entities.Scan
            {
                ScannedDateTime = DateTime.Today,
                FormTypeId      = eFormTypeId.EmailedReport,
                ScannedFormPDF  = fileName,
                IsAppend        = false,
                IsUploaded      = false,
            };

            var scannedFormID = facForm.Create(bookingForm, userName);

            return(scannedFormID);
        }
Ejemplo n.º 8
0
        void btnPIL_Click(object sender, EventArgs e)
        {
            NameValueCollection reportParams = new NameValueCollection();
            DataSet             dsPIL        = null;

            Orchestrator.Facade.ICollectDropLoadOrder facLoadOrder = new Orchestrator.Facade.CollectDrop();

            if (OrderID > 0)
            {
                #region Pop-up Report
                eReportType reportType = eReportType.PIL;
                dsPIL = facLoadOrder.GetPILData(OrderID.ToString());
                DataView dvPIL;

                if ((bool)dsPIL.Tables[0].Rows[0]["IsPalletNetwork"])
                {
                    reportType = Globals.Configuration.PalletNetworkLabelID;;

                    //Need to duplicate the rows for the Pallteforce labels
                    dsPIL.Tables[0].Merge(dsPIL.Tables[0].Copy(), true);
                    dvPIL = new DataView(dsPIL.Tables[0], string.Empty, "OrderId, PalletCount", DataViewRowState.CurrentRows);
                }
                else
                {
                    dvPIL = new DataView(dsPIL.Tables[0]);
                }
                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable] = reportType;

                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = dvPIL;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = String.Empty;
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                // Show the user control
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');</script>");
                #endregion
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Load Report Depending On Invoice Type
        /// </summary>
        private ReportBase LoadReport()
        {
            // Configure the Session variables used to pass data to the report
            NameValueCollection reportParams = new NameValueCollection();

            //-------------------------------------------------------------------------------------
            //						Job/Collect-Drops/References/Demurrages Section
            //-------------------------------------------------------------------------------------
            Facade.IInvoice facInv = new Facade.Invoice();

            DataSet dsInv = null;

            if (m_isUpdate)
            {
                dsInv = facInv.GetJobsForInvoiceId(Convert.ToInt32(lblInvoiceNo.Text));
            }
            else
            {
                dsInv = facInv.GetJobsToInvoice(m_jobIdCSV);
            }

            reportParams.Add("JobIds", m_jobIdCSV);

            reportParams.Add("ExtraIds", m_extraIdCSV);

            //-------------------------------------------------------------------------------------
            //									Param Section
            //-------------------------------------------------------------------------------------
            // Fuel Type & Rate
            eInvoiceDisplayMethod fuelType;
            decimal newRate = 0;

            if (chkIncludeFuelSurcharge.Checked)
            {
                reportParams.Add("Fuel", "Include");

                // Pass The New Rate To Report if so...
                newRate = Convert.ToDecimal(txtFuelSurchargeRate.Text);
                reportParams.Add("FuelRate", newRate.ToString());

                // Pass FuelSurchargeType
                fuelType = (eInvoiceDisplayMethod)Enum.Parse(typeof(eInvoiceDisplayMethod), rdoFuelSurchargeType.SelectedValue);
                reportParams.Add("FuelType", fuelType.ToString());
            }

            // Override
            if (chkOverride.Checked)
            {
                reportParams.Add("Override", "Include");
                reportParams.Add("OverrideVAT", txtOverrideVAT.Text);
                reportParams.Add("OverrideNET", txtOverrideNetAmount.Text);
                reportParams.Add("OverrideGross", txtOverrideGrossAmount.Text);
                reportParams.Add("OverrideReason", txtOverrideReason.Text);
            }

            // PODs
            if (chkIncludePODs.Checked)
            {
                reportParams.Add("PODs", "Include");
            }

            // References
            if (chkIncludeReferences.Checked)
            {
                reportParams.Add("References", "Include");
            }

            // Job
            if (chkJobDetails.Checked)
            {
                reportParams.Add("JobDetails", "Include");

                // Demuragge
                if (chkIncludeDemurrage.Checked)
                {
                    reportParams.Add("Demurrage", "Include");

                    // Demurrage Type
                    try
                    {
                        eInvoiceDisplayMethod demurrageType = (eInvoiceDisplayMethod)Enum.Parse(typeof(eInvoiceDisplayMethod), rdoDemurrageType.SelectedValue);
                        reportParams.Add("DemurrageType", demurrageType.ToString());
                    }
                    catch (Exception) { }
                }
            }

            if (pnlExtras.Visible)
            {
                reportParams.Add("ExtraIds", Convert.ToString(ViewState["ExtraIdCSV"]));
                reportParams.Add("Extras", "Include");
            }

            // Extra details
            if (chkExtraDetails.Visible && chkExtraDetails.Checked)
            {
                reportParams.Add("ExtraDetail", "include");
            }

            // Self Bill Invoice Number
            if ((eInvoiceType)Enum.Parse(typeof(eInvoiceType), lblInvoiceType.Text) == eInvoiceType.SelfBill)
            {
                reportParams.Add("InvoiceType", "SelfBill");
                reportParams.Add("SelfBillInvoiceNumber", txtClientSelfBillInvoiceNumber.Text);
            }
            else
            {
                reportParams.Add("InvoiceType", "Normal");
            }

            // Client Name & Id
            if (m_isUpdate)
            {
                Facade.IInvoice facClient = new Facade.Invoice();

                DataSet ds = facClient.GetClientForInvoiceId(Convert.ToInt32(lblInvoiceNo.Text));

                try
                {
                    reportParams.Add("Client", Convert.ToString(ds.Tables[0].Rows[0]["Client"]));
                    reportParams.Add("ClientId", Convert.ToString(ds.Tables[0].Rows[0]["ClientId"]));

                    m_clientId = int.Parse(ds.Tables[0].Rows[0]["ClientId"].ToString());

                    if (!chkPostToExchequer.Checked)
                    {
                        btnSendToAccounts.Visible = true;
                        pnlInvoiceDeleted.Visible = true;
                    }
                }
                catch
                {
                }
            }
            else
            {
                if (Convert.ToString(Session["ClientName"]) != "")
                {
                    reportParams.Add("Client", Convert.ToString(Session["ClientName"]));
                }

                if (Convert.ToString(Session["ClientId"]) != "")
                {
                    reportParams.Add("ClientId", Convert.ToString(Session["ClientId"]));
                }

                if (m_clientId == 0)
                {
                    m_clientId = int.Parse(Session["ClientId"].ToString());
                }
                else
                {
                    Facade.IOrganisation  facOrg = new Facade.Organisation();
                    Entities.Organisation enOrg  = new Entities.Organisation();
                    enOrg = facOrg.GetForIdentityId(m_clientId);
                    reportParams.Add("Client", enOrg.OrganisationName.ToString());
                    reportParams.Add("ClientId", m_clientId.ToString());
                }
            }

            // Date Range
            if (Convert.ToDateTime(Session["StartDate"]).Date != DateTime.MinValue)
            {
                reportParams.Add("startDate", Convert.ToDateTime(Session["StartDate"]).ToString("dd/MM/yy"));
            }

            if (Convert.ToDateTime(Session["EndDate"]).Date != DateTime.MinValue)
            {
                reportParams.Add("endDate", Convert.ToDateTime(Session["EndDate"]).ToString("dd/MM/yy"));
            }

            // Invoice Id
            if (lblInvoiceNo.Text != "To Be Issued ... (This invoice has not yet been saved, add invoice to allocate Invoice No.)")
            {
                reportParams.Add("invoiceId", lblInvoiceNo.Text);
            }
            else
            {
                reportParams.Add("invoiceId", "0");
            }

            // Posted To Accounts
            if (chkPostToExchequer.Checked)
            {
                reportParams.Add("Accounts", "true");
            }

            int     vatNo   = 0;
            decimal vatRate = 0.00M;

            // VAT Rate
            facInv.GetVatRateForVatType(eVATType.Standard, dteInvoiceDate.SelectedDate.Value, out vatNo, out vatRate);
            reportParams.Add("VATrate", vatRate.ToString());

            // Invoice Date
            reportParams.Add("InvoiceDate", dteInvoiceDate.SelectedDate.Value.ToShortDateString());

            //-------------------------------------------------------------------------------------
            //									Load Report Section
            //-------------------------------------------------------------------------------------
            Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.Invoice;
            Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = dsInv;
            Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = rdoSortType.SelectedItem.Text.Replace(" ", "");
            Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";
            Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;

            Orchestrator.Reports.ReportBase activeReport = null;
            eReportType reportType = 0;

            reportType = (eReportType)Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable];
            try
            {
                activeReport = new Orchestrator.Reports.Invoicing.rptInvoice();
            }
            catch (NullReferenceException e)
            {
                Response.Write(e.Message);
                Response.Flush();
                return(null);
            }

            if (activeReport != null)
            {
                try
                {
                    ApplicationLog.WriteTrace("Getting Data From Session Variable");
                    DataView view = null;
                    DataSet  ds   = (DataSet)Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];

                    string sortExpression = (string)Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable];
                    ApplicationLog.WriteTrace("sortExpression ::" + sortExpression);
                    try
                    {
                        if (sortExpression.Length > 0)
                        {
                            view      = new DataView(ds.Tables[0]);
                            view.Sort = sortExpression;
                            activeReport.DataSource = view;
                        }
                        else
                        {
                            activeReport.DataSource = ds;
                        }

                        activeReport.DataMember = (string)Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable];
                    }
                    catch (Exception eX)
                    {
                        this.Trace.Write("Err1:" + eX.Message);
                        ApplicationLog.WriteTrace("GetReport :: Err1:" + eX.Message);
                    }
                    activeReport.Document.Printer.PrinterName = string.Empty;
                    activeReport.Document.Printer.PaperKind   = System.Drawing.Printing.PaperKind.A4;
                    //activeReport.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
                    //activeReport.PrintWidth = activeReport.PageSettings.PaperWidth - (activeReport.PageSettings.Margins.Right + activeReport.PageSettings.Margins.Left);
                    activeReport.Run(false);
                }
                catch (Exception e)
                {
                    Response.Write(e.Message);
                    Response.Flush();
                    return(null);
                }
            }

            Session[Orchestrator.Globals.Constants.ReportSessionVariable] = activeReport;

            return(activeReport);
        }
Ejemplo n.º 10
0
        private void btnGetReport_Click(object sender, EventArgs e)
        {
            if (!base.ProcessValidationFormControls())
            {
                return;
            }

            int?DepartmentID = ucEmployeeFilter1.DepartmentID;

            if (DepartmentID == -1)
            {
                DepartmentID = null;
            }

            int?DesignationID = ucEmployeeFilter1.DesignationID;

            if (DesignationID == -1)
            {
                DesignationID = null;
            }

            int?LocationID = ucEmployeeFilter1.LocationID;

            if (LocationID == -1)
            {
                LocationID = null;
            }

            int?EmployementTypeID = ucEmployeeFilter1.EmploymentType - 1;

            if (EmployementTypeID == -1)
            {
                EmployementTypeID = null;
            }

            var ds = (new DAL.Payroll.EmployeeAttendanceDAL()).GetEmployeeAttendanceData(ucEmployeeFilter1.DateFrom, ucEmployeeFilter1.DateTo,
                                                                                         DepartmentID, DesignationID, LocationID, EmployementTypeID);


            eReportType ReportType = (eReportType)cmbType.SelectedIndex;

            switch (ReportType)
            {
            case eReportType.LateComing:
                ds = ds.Where(r => r.LateIn).ToList();
                break;

            case eReportType.EarlyGoing:
                ds = ds.Where(r => r.EarlyGoing).ToList();
                break;

            case eReportType.MissedPunch:
                ds = ds.Where(r => r.MissedPunch).ToList();
                break;
            }

            var filteredEmployees = (from r in ds
                                     group r by r.EmployeeID into gr
                                     select gr.Key);

            DataTable dt = new DataTable("dsReport" + DateTime.Now.Ticks.ToString());

            dt.Columns.Add("EmployeeNoPrefix", typeof(string));
            dt.Columns.Add("EmployeeNo", typeof(int));
            dt.Columns.Add("EmployeeName", typeof(string));
            //dt.Columns.Add("DepartmentName", typeof(string));
            //dt.Columns.Add("DesignationName", typeof(string));
            //dt.Columns.Add("LocationName", typeof(string));
            //dt.Columns.Add("EmployementType", typeof(string));

            for (DateTime r = ucEmployeeFilter1.DateFrom; r <= ucEmployeeFilter1.DateTo; r = r.AddDays(1))
            {
                string dtname = r.ToString("ddMMyyyy");

                dt.Columns.Add("ShiftName" + dtname, typeof(string));

                if (ReportType != eReportType.EarlyGoing)
                {
                    dt.Columns.Add("DTIN" + dtname, typeof(TimeSpan));
                }

                if (ReportType != eReportType.LateComing)
                {
                    dt.Columns.Add("DTOUT" + dtname, typeof(TimeSpan));
                }
            }

            foreach (var emp in filteredEmployees)
            {
                var Employee = dsEmployeeLookup.Find(r => r.EmployeeID == emp);
                if (Employee == null || Employee.EmployeeID == -1)
                {
                    continue;
                }
                DataRow dr = dt.Rows.Add();
                //dr["EmployeeID"] = emp;
                dr["EmployeeName"]     = Employee.EmployeeName;
                dr["EmployeeNoPrefix"] = Employee.EmployeeNoPrefix;
                dr["EmployeeNo"]       = Employee.EmployeeNo;
                //dr["DepartmentName"] = Employee.Department;
                //dr["DesignationName"] = Employee.Designation;
                //dr["LocationName"] = Employee.Location;
                //dr["EmployementType"] = Employee.EmployementType;


                for (DateTime date = ucEmployeeFilter1.DateFrom; date <= ucEmployeeFilter1.DateTo; date = date.AddDays(1))
                {
                    var attendances = ds.Where(r => r.EmployeeID == emp && r.Day == date);
                    foreach (var attendance in attendances)
                    {
                        if (attendance != null)
                        {
                            dr["ShiftName" + date.ToString("ddMMyyyy")] = attendance.EmployeeShiftName;

                            if (attendance.InTime != null && ReportType != eReportType.EarlyGoing)
                            {
                                dr["DTIN" + date.ToString("ddMMyyyy")] = attendance.InTime;
                            }
                            if (attendance.OutTime != null && ReportType != eReportType.LateComing)
                            {
                                dr["DTOUT" + date.ToString("ddMMyyyy")] = attendance.OutTime;
                            }
                        }
                    }
                }
            }
            dt.DefaultView.Sort = "EmployeeNo";

            ClearGrid();
            gridControlData.DataSource = dt;//.DefaultView.ToTable();

            txtNofRecords.EditValue = dt.Rows.Count;

            GridBand EmployeeBand = new DevExpress.XtraGrid.Views.BandedGrid.GridBand()
            {
                Name     = "EmployeeBand",
                Caption  = "Employee",
                MinWidth = 100,
            };

            EmployeeBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridViewData.Bands.Add(EmployeeBand);

            BandedGridColumn myGridColumn = null;

            myGridColumn          = gridViewData.Columns["EmployeeNoPrefix"];
            myGridColumn.Caption  = "Prefix";
            myGridColumn.MinWidth = 70;
            myGridColumn.MaxWidth = 100;
            //myGridColumn.SortIndex = 0;
            myGridColumn.OwnerBand = EmployeeBand;
            myGridColumn.Width     = 100;
            myGridColumn.Visible   = false;

            myGridColumn          = gridViewData.Columns["EmployeeNo"];
            myGridColumn.Caption  = "No.";
            myGridColumn.MinWidth = 70;
            myGridColumn.MaxWidth = 100;
            //myGridColumn.SortIndex = 0;
            myGridColumn.OwnerBand = EmployeeBand;
            myGridColumn.Width     = 100;
            myGridColumn.Visible   = true;

            myGridColumn          = gridViewData.Columns["EmployeeName"];
            myGridColumn.Caption  = "Name";
            myGridColumn.MinWidth = 200;
            //myGridColumn.MaxWidth = 500;
            myGridColumn.OwnerBand = EmployeeBand;
            myGridColumn.Visible   = true;
            myGridColumn.Width     = 1000;
            //myGridColumn = gridViewData.Columns["DepartmentName"];
            //myGridColumn.Caption = "Department";
            //myGridColumn.MinWidth = 100;
            //myGridColumn.MaxWidth = 300;
            //myGridColumn.OwnerBand = EmployeeBand;
            //myGridColumn.Visible = false;

            //myGridColumn = gridViewData.Columns["DesignationName"];
            //myGridColumn.Caption = "Designation";
            //myGridColumn.MinWidth = 100;
            //myGridColumn.MaxWidth = 300;
            //myGridColumn.OwnerBand = EmployeeBand;
            //myGridColumn.Visible = false;

            //myGridColumn = gridViewData.Columns["LocationName"];
            //myGridColumn.Caption = "Location";
            //myGridColumn.MinWidth = 100;
            //myGridColumn.MaxWidth = 300;
            //myGridColumn.OwnerBand = EmployeeBand;
            //myGridColumn.Visible = false;

            //myGridColumn = gridViewData.Columns["EmployementType"];
            //myGridColumn.Caption = "Employement Type";
            //myGridColumn.MinWidth = 70;
            //myGridColumn.MaxWidth = 200;
            //myGridColumn.OwnerBand = EmployeeBand;
            //myGridColumn.Visible = false;

            int ColumnIndex = 0;

            for (DateTime r = ucEmployeeFilter1.DateFrom; r <= ucEmployeeFilter1.DateTo; r = r.AddDays(1))
            {
                string dtname = r.ToString("ddMMyyyy");
                //--
                GridBand DateBand = new GridBand()
                {
                    Name    = "DateBand" + dtname,
                    Caption = r.ToString("dd-MM-yyyy"),
                };
                DateBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridViewData.Bands.Add(DateBand);
                //--
                BandedGridColumn column = null;

                Color AlternateBackColor = Color.WhiteSmoke;

                column           = gridViewData.Columns["ShiftName" + dtname];
                column.Caption   = "Shift";
                column.MinWidth  = 75;
                column.MaxWidth  = 300;
                column.OwnerBand = DateBand;
                column.Width     = 100;
                column.Visible   = ShowShift;
                if ((ColumnIndex % 2 == 0))
                {
                    column.AppearanceCell.BackColor = AlternateBackColor;
                }

                if (ReportType != eReportType.EarlyGoing)
                {
                    column         = gridViewData.Columns["DTIN" + dtname];
                    column.Caption = "In";
                    column.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.DateTime;
                    column.DisplayFormat.FormatString = "hh\\:mm";
                    column.MinWidth = 55;
                    column.MaxWidth = 100;
                    column.AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Center;
                    column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    column.OwnerBand = DateBand;
                    column.Width     = 100;
                    column.Visible   = true;
                    if ((ColumnIndex % 2 == 0))
                    {
                        column.AppearanceCell.BackColor = AlternateBackColor;
                    }
                }

                if (ReportType != eReportType.LateComing)
                {
                    column         = gridViewData.Columns["DTOUT" + dtname];
                    column.Caption = "Out";
                    column.DisplayFormat.FormatType                = DevExpress.Utils.FormatType.DateTime;
                    column.DisplayFormat.FormatString              = "hh\\:mm";
                    column.AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Center;
                    column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    column.OwnerBand = DateBand;
                    column.MinWidth  = 55;
                    column.MaxWidth  = 100;
                    column.Width     = 100;
                    column.Visible   = true;
                    if ((ColumnIndex % 2 == 0))
                    {
                        column.AppearanceCell.BackColor = AlternateBackColor;
                    }
                }

                if (ReportType == eReportType.LateComing || ReportType == eReportType.EarlyGoing)
                {
                    DateBand.Width = 100;
                }
                else
                {
                    DateBand.Width = 200;
                }
                ColumnIndex++;
            }
            //--
            gridControlData.RefreshDataSource();
            gridViewData.BestFitColumns();
        }
Ejemplo n.º 11
0
        private ReportBase GetReport(HttpSessionState session, TraceContext trace, string reportParametersSessionKey, out bool noData)
        {
            ReportBase activeReport = null;

            noData = false;

            eReportType reportType             = 0;
            bool        enforceDataExistence   = false;
            bool        useReportParametersKey = !string.IsNullOrWhiteSpace(reportParametersSessionKey);
            Hashtable   htReportInformation    = null;

            try
            {
                if (useReportParametersKey)
                {
                    htReportInformation = (Hashtable)session[reportParametersSessionKey];
                    reportType          = (eReportType)htReportInformation[Orchestrator.Globals.Constants.ReportTypeSessionVariable];
                }
                else
                {
                    reportType = (eReportType)session[Orchestrator.Globals.Constants.ReportTypeSessionVariable];
                }

                activeReport = Orchestrator.Reports.Utilities.GetActiveReport(reportType, reportParametersSessionKey, out enforceDataExistence);
            }
            catch (Exception ex)
            {
                Utilities.LastError = ex;
                return(null);
            }

            if (activeReport != null)
            {
                try
                {
                    ApplicationLog.WriteTrace("Getting Data From Session Variable");
                    DataView view           = null;
                    var      sortExpression = string.Empty;
                    object   ds             = null;

                    if (useReportParametersKey)
                    {
                        if (htReportInformation[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] is DataSet)
                        {
                            ds = (DataSet)htReportInformation[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];
                        }
                        else
                        {
                            ds = htReportInformation[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];
                        }

                        sortExpression = (string)htReportInformation[Orchestrator.Globals.Constants.ReportDataSessionSortVariable];
                    }
                    else
                    {
                        if (session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] is DataSet)
                        {
                            ds = (DataSet)session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];
                        }
                        else
                        {
                            ds = session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];
                        }

                        sortExpression = (string)session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable];
                    }

                    ApplicationLog.WriteTrace("sortExpression ::" + sortExpression);

                    try
                    {
                        if (sortExpression.Length > 0)
                        {
                            if (ds is DataSet)
                            {
                                view = new DataView(((DataSet)ds).Tables[0]);
                            }

                            view.Sort = sortExpression;
                            activeReport.DataSource = view;
                        }
                        else
                        {
                            activeReport.DataSource = ds;
                        }

                        if (enforceDataExistence && ds != null && ds is DataSet && ((DataSet)ds).Tables.Count > 0 && ((DataSet)ds).Tables[0].Rows.Count == 0)
                        {
                            noData = true;
                            return(null);
                        }

                        if (useReportParametersKey)
                        {
                            activeReport.DataMember = (string)htReportInformation[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable];
                        }
                        else
                        {
                            activeReport.DataMember = (string)session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable];
                        }
                    }
                    catch (Exception eX)
                    {
                        Utilities.LastError = eX;
                        trace.Write("Err1:" + eX.Message);
                        ApplicationLog.WriteTrace("GetReport :: Err1:" + eX.Message);
                    }

                    activeReport.SetReportCulture();
                    activeReport.Run(false);
                }
                catch (Exception e)
                {
                    Utilities.LastError = e;
                    return(null);
                }
            }

            trace.Write("Returning Report");
            ApplicationLog.WriteTrace("GetReport :: Returning Report");
            return(activeReport);
        }