Exemple #1
0
        /// <summary>
        /// To the liquid.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public object ToLiquid()
        {
            var dictionary = new Dictionary <string, object>();

            dictionary.Add("PrinterDeviceId", PrinterDeviceId);
            dictionary.Add("PrinterAddress", PrinterAddress);
            dictionary.Add("PrintFrom", PrintFrom.ConvertToString());
            dictionary.Add("PrintTo", PrintTo.ConvertToString());
            dictionary.Add("LabelFile", LabelFile);
            dictionary.Add("LabelKey", LabelKey);
            dictionary.Add("MergeFields", MergeFields);
            return(dictionary);
        }
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var deviceService = new DeviceService(new RockContext());
            var sortProperty  = gDevice.SortProperty;

            gDevice.EntityTypeId = EntityTypeCache.Get <Device>().Id;

            var queryable = deviceService.Queryable();

            string name = fDevice.GetUserPreference("Name");

            if (!string.IsNullOrWhiteSpace(name))
            {
                queryable = queryable.Where(d => d.Name.Contains(name));
            }

            int?deviceTypeId = fDevice.GetUserPreference("Device Type").AsIntegerOrNull();

            if (deviceTypeId.HasValue)
            {
                queryable = queryable.Where(d => d.DeviceTypeValueId == deviceTypeId.Value);
            }

            string ipAddress = fDevice.GetUserPreference("IP Address");

            if (!string.IsNullOrWhiteSpace(ipAddress))
            {
                queryable = queryable.Where(d => d.IPAddress.Contains(ipAddress));
            }

            if (!string.IsNullOrWhiteSpace(fDevice.GetUserPreference("Print To")))
            {
                PrintTo printTo = (PrintTo)System.Enum.Parse(typeof(PrintTo), fDevice.GetUserPreference("Print To"));;
                queryable = queryable.Where(d => d.PrintToOverride == printTo);
            }

            int?printerId = fDevice.GetUserPreference("Printer").AsIntegerOrNull();

            if (printerId.HasValue)
            {
                queryable = queryable.Where(d => d.PrinterDeviceId == printerId);
            }

            if (!string.IsNullOrWhiteSpace(fDevice.GetUserPreference("Print From")))
            {
                PrintFrom printFrom = (PrintFrom)System.Enum.Parse(typeof(PrintFrom), fDevice.GetUserPreference("Print From"));;
                queryable = queryable.Where(d => d.PrintFrom == printFrom);
            }

            string activeFilterValue = fDevice.GetUserPreference("Active Status");

            if (!string.IsNullOrWhiteSpace(activeFilterValue))
            {
                if (activeFilterValue != "all")
                {
                    var activeFilter = activeFilterValue.AsBoolean();
                    queryable = queryable.Where(b => b.IsActive == activeFilter);
                }
            }
            else
            {
                queryable = queryable.Where(b => b.IsActive);
            }

            gDevice.ObjectList = new Dictionary <string, object>();
            queryable.ToList().ForEach(d => gDevice.ObjectList.Add(d.Id.ToString(), d));

            var gridList = queryable.Select(a =>
                                            new
            {
                a.Id,
                a.Name,
                DeviceTypeName = a.DeviceType.Value,
                a.IPAddress,
                a.PrintToOverride,
                a.PrintFrom,
                PrinterDeviceName = a.PrinterDevice.Name,
                a.PrinterDeviceId,
                a.DeviceTypeValueId,
                a.IsActive
            });

            if (sortProperty != null)
            {
                gDevice.DataSource = gridList.Sort(sortProperty).ToList();
            }
            else
            {
                gDevice.DataSource = gridList.OrderBy(d => d.Name).ToList();
            }

            gDevice.EntityTypeId = EntityTypeCache.Get <Rock.Model.Device>().Id;
            gDevice.DataBind();
        }
Exemple #3
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var deviceService = new DeviceService();
            var sortProperty  = gDevice.SortProperty;

            var queryable = deviceService.Queryable().Select(a =>
                                                             new
            {
                a.Id,
                a.Name,
                DeviceTypeName = a.DeviceType.Name,
                a.IPAddress,
                a.PrintToOverride,
                a.PrintFrom,
                PrinterDeviceName = a.PrinterDevice.Name,
                a.PrinterDeviceId,
                a.DeviceTypeValueId
            });

            string name = fDevice.GetUserPreference("Name");

            if (!string.IsNullOrWhiteSpace(name))
            {
                queryable = queryable.Where(d => d.Name.Contains(name));
            }

            int?deviceTypeId = fDevice.GetUserPreference("Device Type").AsInteger();

            if (deviceTypeId.HasValue)
            {
                queryable = queryable.Where(d => d.DeviceTypeValueId == deviceTypeId.Value);
            }

            string ipAddress = fDevice.GetUserPreference("IP Address");

            if (!string.IsNullOrWhiteSpace(ipAddress))
            {
                queryable = queryable.Where(d => d.IPAddress.Contains(ipAddress));
            }

            if (!string.IsNullOrWhiteSpace(fDevice.GetUserPreference("Print To")))
            {
                PrintTo printTo = (PrintTo)System.Enum.Parse(typeof(PrintTo), fDevice.GetUserPreference("Print To"));;
                queryable = queryable.Where(d => d.PrintToOverride == printTo);
            }

            int?printerId = fDevice.GetUserPreference("Printer").AsInteger();

            if (printerId.HasValue)
            {
                queryable = queryable.Where(d => d.PrinterDeviceId == printerId);
            }

            if (!string.IsNullOrWhiteSpace(fDevice.GetUserPreference("Print From")))
            {
                PrintFrom printFrom = (PrintFrom)System.Enum.Parse(typeof(PrintFrom), fDevice.GetUserPreference("Print From"));;
                queryable = queryable.Where(d => d.PrintFrom == printFrom);
            }

            if (sortProperty != null)
            {
                gDevice.DataSource = queryable.Sort(sortProperty).ToList();
            }
            else
            {
                gDevice.DataSource = queryable.OrderBy(d => d.Name).ToList();
            }

            gDevice.DataBind();
        }
        public void PrintGPI(PrintTo ToPrint, String PrinterName, String InvoiceNote, Boolean IsPreInvoice)
        {
            Double AllPositive            = this.GetPositiveAmount();
            Double AllNegative            = this.GetNegativeAmount();
            Double DropPercentageCustomer = 0.00;
            Double DropPercentageItem     = 0.00;

            if (Retail < 2500 && !this.IsGiftAvenue && !this.IsGPI)
            {
                DataTable dtInv = GetCurrentTotalsByBrochure();
                if (dtInv != null)
                {
                    if (LastInvoicedAmount == 0 && Retail < 2500 && Retail > 0)
                    {
                        if (!IsPreInvoice)
                        {
                            SubtractBrochureProfitPercent(InvoicedAmount, dtInv);
                        }
                        else
                        {
                            DropPercentageCustomer = -5.00;
                        }
                    }
                    DropPercentageItem = -5.00;
                }
                else
                {
                    return;
                }
            }

            this.Note  = InvoiceNote;
            this.Note += "\n" + GetStringOverageInvoice();

            DataSet ds = new DataSet();

            ds.Tables.Add(oMySql.GetDataTable(String.Format("Select * From Customer Where CompanyID='{0}' And CustomerID='{1}'", CompanyID, ID), "Customer"));

            DataTable dvInv = new DataTable();

            dvInv = GetTotalDataTableGPI("ProductID", DropPercentageCustomer, DropPercentageItem);
            ds.Tables.Add(CreateDetailTable(dvInv)); //Detail


            DataTable dtTotals = GetCurrentTotalsGPI(DropPercentageCustomer, DropPercentageItem); //GetTotalDataTable("CustomerID");

            //GetCurrentTotalsByBrochure();
            if (dtTotals != null)
            {
                ds.Tables.Add(dtTotals); //Detail



                frmViewReport oViewReport = new frmViewReport();
                //ds.WriteXml("Invoice.xml", XmlWriteMode.WriteSchema);
                InvoiceHeaderDetailGPI oRpt = new InvoiceHeaderDetailGPI();
                oRpt.SetDataSource(ds);
                oRpt.SetParameterValue("PrevInvoice", AllPositive);                            //LastInvoicedAmount);
                oRpt.SetParameterValue("Payments", AllNegative);                               //PaymentsAmount+Charges);
                oRpt.SetParameterValue("AddedAmount", AddedAmount);
                oRpt.SetParameterValue("BalanceDue", AllPositive + AllNegative + AddedAmount); //AmountDue);
                oRpt.SetParameterValue("InvoiceNote", this.Note);

                Company oCompany = new Company(this.CompanyID);
                oRpt.SetParameterValue("CompanyName", oCompany.Name);

                if (this.BrochureID == "C" || this.BrochureID_2 == "C" || this.BrochureID_3 == "C")
                {
                    oRpt.SetParameterValue("txtFee", "E Card Ship Fee".ToUpper());
                }
                else
                {
                    oRpt.SetParameterValue("txtFee", "IMPRINT FEE");
                }

                if (this.IsPostPay)
                {
                    oRpt.SetParameterValue("Terms", "");
                }
                else
                {
                    oRpt.SetParameterValue("Terms", "TERMS: NET DUE UPON DELIVERY");
                }

                if (ToPrint == PrintTo.File)
                {
                    PDF oPDF = new PDF();
                    oPDF.FileName = Application.StartupPath + "\\" + this.Name + ".pdf";
                    oPDF.ExportReport(oRpt, "pdf", Application.StartupPath + "\\", this.Name);

                    Smtp oSmtp = new Smtp();
                    oSmtp.Subject = "Invoice for " + this.Name + "   " + DateTime.Now.ToShortDateString() + "   " + DateTime.Now.ToShortTimeString();
                    oSmtp.To      = "<" + "*****@*****.**" + ">"; //this.eMail + ">";
                    oSmtp.From    = "\"Signature Fundraising Customer Service\" <*****@*****.**>";

                    String strTitle = "Invoice\n\r";

                    oSmtp.Body       = strTitle;
                    oSmtp.Attachment = oPDF.FileName;
                    if (!oSmtp.Send())
                    {
                        return;
                    }
                }
                else if (ToPrint == PrintTo.Printer)
                {
                    oRpt.PrintOptions.PrinterName = PrinterName;
                    oRpt.PrintToPrinter(1, true, 1, 100);
                }
                else if (ToPrint == PrintTo.Viewer)
                {
                    oViewReport.cReport.ReportSource = oRpt;
                    oViewReport.ShowDialog();
                    //oViewReport.cReport.PrintReport();
                }


                if (!IsPreInvoice)
                {
                    UpdateInventory();

                    //Update Statement
                    if (LastInvoicedAmount != InvoicedAmount)
                    {
                        UpdateInvoicedAmount(InvoicedAmount - LastInvoicedAmount); //Adding Line ,,,,
                        AddedAmount = 0.00;
                    }
                }


                this.UpdateCurrentTotals();
                ds.Dispose();
                oRpt.Dispose();
            }
            return;
        }