예제 #1
0
        protected override void SetUnlinkedGridValues(string grid_name)
        {
            OutputInvoiceInfo item;

            if (grid_name == Facturas_DGW.Name)
            {
                Charge cobro = (Charge)Datos_Cobros.Current;

                foreach (DataGridViewRow row in Facturas_DGW.Rows)
                {
                    if (row.IsNewRow)
                    {
                        return;
                    }

                    item = row.DataBoundItem as OutputInvoiceInfo;
                    if (item == null)
                    {
                        continue;
                    }

                    row.Cells[FacturaSerie.Index].Value      = _series.GetItem(item.OidSerie).Identificador;
                    row.Cells[Asignado.Index].Value          = cobro.CobroFacturas.GetItemByFactura(item.Oid).Cantidad;
                    row.Cells[FechaAsignacion.Index].Value   = cobro.CobroFacturas.GetItemByFactura(item.Oid).FechaAsignacion;
                    row.Cells[Dias.Index].Value              = cobro.Fecha.Subtract(item.Fecha).Days;
                    row.Cells[FacturaAnteriores.Index].Value = item.Cobrado - cobro.CobroFacturas.GetItemByFactura(item.Oid).Cantidad;
                }
            }
        }
예제 #2
0
        public ReportClass GetListReport(OutputInvoiceList list, SerieList series)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            OutputInvoiceListRpt doc = new OutputInvoiceListRpt();

            List <OutputInvoicePrint> pList = new List <OutputInvoicePrint>();

            foreach (OutputInvoiceInfo item in list)
            {
                pList.Add(OutputInvoicePrint.New(item,
                                                 null,
                                                 null,
                                                 series.GetItem(item.OidSerie),
                                                 false));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
예제 #3
0
        public ReportClass GetListReport(BudgetList list, ClienteList clientes, SerieList series)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            BudgetListRpt doc = new BudgetListRpt();

            List <BudgetPrint> pList = new List <BudgetPrint>();

            foreach (BudgetInfo item in list)
            {
                pList.Add(item.GetPrintObject((clientes == null) ? null : clientes.GetItem(item.OidCliente),
                                              series.GetItem(item.OidSerie)));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
        public static void SendMailsFacturasPendientes()
        {
            try
            {
                OutputInvoiceList facturas = OutputInvoiceList.GetNoCobradasList(true);
                ClienteList       clientes = ClienteList.GetList(false);
                SerieList         series   = SerieList.GetList(false);
                CompanyInfo       empresa  = CompanyInfo.Get(AppContext.ActiveSchema.Oid);

                SerieInfo   serie;
                ClienteInfo cliente;

                Registro registro = Registro.New(ETipoRegistro.Email);
                registro.Nombre        = "Envio automático de Facturas";
                registro.Observaciones = "Envio automático de Facturas pendientes de pago";

                foreach (OutputInvoiceInfo item in facturas)
                {
                    if (item.Prevision.AddDays(ModulePrincipal.GetPeriodicidadEnvioFacturasPendientes()) > DateTime.Today)
                    {
                        continue;
                    }

                    cliente = clientes.GetItem(item.OidCliente);
                    if (!cliente.EnviarFacturaPendiente)
                    {
                        continue;
                    }

                    serie = series.GetItem(item.OidSerie);

                    FormatConfFacturaAlbaranReport conf = new FormatConfFacturaAlbaranReport();

                    conf.nota  = (cliente.OidImpuesto == 1) ? Resources.Messages.NOTA_EXENTO_IGIC : string.Empty;
                    conf.nota += Environment.NewLine + (item.Nota ? serie.Cabecera : "");

                    OutputInvoiceReportMng reportMng = new OutputInvoiceReportMng(AppContext.ActiveSchema, string.Empty, string.Empty);
                    ReportClass            report    = reportMng.GetDetailReport(item, serie, cliente, null, conf);

                    if (report != null)
                    {
                        LineaRegistro linea = registro.LineaRegistros.NewItem(registro, cliente);

                        ExportOptions options = new ExportOptions();
                        DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();

                        string fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        fileName += "\\" + item.FileName;

                        diskFileDestinationOptions.DiskFileName = fileName;
                        options.ExportFormatType         = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        options.ExportDestinationType    = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                        options.ExportDestinationOptions = diskFileDestinationOptions;

                        report.Export(options);

                        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

                        mail.To.Add(new MailAddress(cliente.Email, cliente.Nombre));
                        mail.From    = new MailAddress(SettingsMng.Instance.GetSMTPMail(), empresa.Name);
                        mail.Body    = String.Format(Resources.Messages.FACTURA_EMAIL_ATTACHMENT_BODY, empresa.Name);
                        mail.Subject = Resources.Messages.FACTURA_EMAIL_SUBJECT;
                        mail.Attachments.Add(new Attachment(fileName));

                        try
                        {
                            Thread mailThread = new Thread(SendMailDelegate);
                            mailThread.Start(mail);
                            while (mailThread.IsAlive)
                            {
                                ;
                            }

                            linea.Observaciones = linea.Descripcion;
                            linea.Descripcion   = String.Format(Resources.Messages.FACTURA_EMAIL_OK, item.NFactura);
                        }
                        catch (Exception ex)
                        {
                            linea.Observaciones = linea.Descripcion;
                            linea.Descripcion   = String.Format(Resources.Messages.FACTURA_EMAIL_ERROR, item.NFactura);
                            registro.Save();
                            throw new iQException(ex.Message + Environment.NewLine + Environment.NewLine + moleQule.Library.Resources.Errors.SMTP_SETTINGS);
                        }
                        finally
                        {
                            mail.Dispose();
                            try { File.Delete(fileName); }
                            catch (Exception ex) { string a = ex.Message; }
                        }
                    }
                }

                registro.Save();

                ModulePrincipal.SetFechaUltimoEnvioFacturasPendientes(DateTime.Now);
                AppContext.Principal.SaveSettings();
            }
            catch { }
        }