Beispiel #1
0
        private void GuardarAsuntoCuerpoMensaje()
        {
            //this.Validate();
            //this.EmpresasActualBindingSource.EndEdit();
            //this.EmpresasActualTableAdapter.Update(Promowork_dataDataSet.EmpresasActual);

            configuracionUsuario.responderASeleccionado  = idTrabajador;
            configuracionEmpresa.asuntoSinAlbaran        = asuntoSinAlbaranTextEdit.Text;
            configuracionEmpresa.cuerpoMensajeSinAlbaran = cuerpoMensajeSinAlbaranTextEdit.Text;

            repoUsuario.GuardarConfiguracionUsuario(configuracionUsuario);
            repoEmpresa.GuardarConfiguracionEmpresa(configuracionEmpresa);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                configuracionEmpresa.DecimalesPrecioProductosReportes = (int)spDecimales.Value;
                repoEmpresa.GuardarConfiguracionEmpresa(configuracionEmpresa);

                DataTable tmpObras        = new DataTable();
                DataTable tmpTrabajadores = new DataTable();

                for (int i = 0; i < gridView1.Columns.Count; i++)
                {
                    tmpObras.Columns.Add(gridView1.Columns[i].FieldName);
                }

                for (int i = 0; i < gridView2.Columns.Count; i++)
                {
                    tmpTrabajadores.Columns.Add(gridView2.Columns[i].FieldName);
                }


                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    if ((bool)gridView1.GetRowCellValue(i, "Marca") == true)
                    {
                        tmpObras.ImportRow(gridView1.GetDataRow(i));
                    }
                }

                for (int i = 0; i < gridView2.RowCount; i++)
                {
                    if ((bool)gridView2.GetRowCellValue(i, "Marca") == true)
                    {
                        tmpTrabajadores.ImportRow(gridView2.GetDataRow(i));
                    }
                }



                //if (chkResumen.CheckState == CheckState.Checked)
                //{
                RptPendienteFacturarConResumen frm = new RptPendienteFacturarConResumen();
                frm.LoadParametros(dateTimePicker1.Value, dateTimePicker2.Value, tmpObras, tmpTrabajadores, rdgFacturado.SelectedIndex, chkResumen.Checked, chkAgruparDescripcion.Checked, (int)spDecimales.Value);
                frm.MdiParent = this.MdiParent;
                frm.Show();
                //}
                //else
                //{
                //    RptPendienteFacturar frm = new RptPendienteFacturar();
                //    frm.LoadParametros(dateTimePicker1.Value, dateTimePicker2.Value, tmpObras, tmpTrabajadores, rdgFacturado.SelectedIndex);
                //    frm.MdiParent = this.MdiParent;
                //    frm.Show();
                //}


                // resumenObrasTableAdapter.Fill(promowork_dataDataSet.ResumenObras, VariablesGlobales.nIdEmpresaActual, dateTimePicker1.Value, dateTimePicker2.Value, tmpObras, tmpTRabajadores);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Es Obligatorio Seleccionar al menos un Registro en cada panel.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #3
0
        private void btEnviarFactura_Click(object sender, EventArgs e)
        {
            List <string> responderA      = null;
            string        nombreRemitente = "";

            if (cbTrabajadores.ItemIndex != -1)
            {
                var trabajador = (TrabajadorConEmail)cbTrabajadores.GetSelectedDataRow();
                responderA      = trabajador.EmailTrabajador.Split(';').ToList();
                nombreRemitente = trabajador.NombreTrabajador;

                configuracionUsuario.responderASeleccionado = (int)cbTrabajadores.EditValue;
            }
            else
            {
                MessageBox.Show("Debe seleccionar un valor en Remitente", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            List <string> destinatarios = new List <string>();

            foreach (DevExpress.XtraEditors.Controls.CheckedListBoxItem item in cbEmailsCliente.Properties.GetItems())
            {
                if (item.CheckState == CheckState.Checked)
                {
                    destinatarios.Add(item.Value.ToString());
                }
            }

            if (destinatarios.Count == 0)
            {
                MessageBox.Show("Debe seleccionar al menos un Email del cliente, para enviar la Factura", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            configuracionUsuario.gestorSeleccionado = (int)cbGestor.EditValue;

            this.Validate();
            this.empresasBindingSource.EndEdit();
            empresasTableAdapter.Update(Promowork_dataDataSet.Empresas);

            List <string> ccos = null;

            if (cbGestor.ItemIndex != -1)
            {
                var gestorSeleccionado = (GestorConEmail)cbGestor.GetSelectedDataRow();
                if (!string.IsNullOrWhiteSpace(gestorSeleccionado.EmailGestor))
                {
                    ccos = gestorSeleccionado.EmailGestor.Split(';').ToList();
                }
            }

            if (!Directory.Exists("ENVIADOS/FACTURAS"))
            {
                Directory.CreateDirectory("ENVIADOS/FACTURAS");
            }


            string nombreFichero = "ENVIADOS/FACTURAS/" + nombreFactura;
            var    respuesta     = Utilidades.ExportarReporte(reportViewer1, nombreFichero, ".PDF", "PDF");

            if (respuesta == string.Empty)
            {
                //destinatarios = factura["EmailCliente"].ToString().Split(';').ToList();

                ////////////////////////////////
                //destinatarios = new List<string>();
                //destinatarios.Add("*****@*****.**");

                //ccos = new List<string>();
                //ccos.Add("*****@*****.**");
                ////////////////////////////////

                var           asunto       = tbAsuntoMensaje.Text;
                var           cuerpoCorreo = tbCuerpoMensaje.Text.Replace("\n", "<br>");
                List <string> adjuntos     = new List <string>();
                adjuntos.Add(nombreFichero + ".PDF");
                respuesta = Utilidades.EnviaCorreo(VariablesGlobales.nIdEmpresaActual, destinatarios, asunto, adjuntos, cuerpoCorreo, responderA, ccos, nombreRemitente);
                if (respuesta.Trim().ToUpper().Equals("OK"))
                {
                    tbResultado.ForeColor = Color.Green;
                    fechaEnvioFactura     = DateTime.Now;
                    cbFechaEnvio.Text     = fechaEnvioFactura.ToString();

                    repoUsuario.GuardarConfiguracionUsuario(configuracionUsuario);

                    configuracionEmpresa.idEmpresa           = VariablesGlobales.nIdEmpresaActual;
                    configuracionEmpresa.asuntoEnvioFacturas = tbAsuntoMensaje.Text;
                    configuracionEmpresa.CuerpoEnvioFacturas = tbCuerpoMensaje.Text;
                    repoEmpresa.GuardarConfiguracionEmpresa(configuracionEmpresa);
                }
                else
                {
                    tbResultado.ForeColor = Color.Red;
                }
                tbResultado.Text = respuesta;
            }
        }
        private void albaranesCabBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            string msgError = string.Empty;

            if (txtNumeroAlbaran.Text.Trim() == "" && chkSinAlbaran.CheckState != CheckState.Checked)
            {
                msgError = msgError + "Número de Albaran." + Environment.NewLine;
            }
            if (deFechaAlbaran.EditValue == null)
            {
                msgError = msgError + "Fecha de Albaran." + Environment.NewLine;
            }
            if (!cbxProveedores.IsDisplayTextValid)
            {
                msgError = msgError + "Proveedor." + Environment.NewLine;
            }
            if (!cbxObra.IsDisplayTextValid)
            {
                msgError = msgError + "Obra." + Environment.NewLine;
            }

            if (msgError != string.Empty)
            {
                MessageBox.Show("Hay campos obligatorios sin rellenar:" + Environment.NewLine + msgError, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (cbxObra.ItemIndex != -1)
                {
                    if (txtConsecutivo.EditValue == DBNull.Value)
                    {
                        txtConsecutivo.EditValue = (int)this.queriesAlbaranes1.UltimoConsecutivoAlbaran((int)cbxObra.EditValue, (int)cbxProveedores.EditValue) + 1;
                    }
                }
                else
                {
                    txtConsecutivo.EditValue = DBNull.Value;
                }

                this.Validate();
                this.albaranesCabBindingSource.EndEdit();
                this.albaranesCabTableAdapter.Update(datosAlbaranes.AlbaranesCab);

                this.observacionesProveedoresBindingSource.EndEdit();
                this.observacionesProveedoresTableAdapter.Update(datosAlbaranes.ObservacionesProveedores);

                List <string> observaciones = new List <string>();

                foreach (DataGridViewRow row in gvObservacionesAlbaranes.Rows)
                {
                    var obs = row.Cells[0].Value;
                    if (obs != null && !string.IsNullOrWhiteSpace(obs.ToString()))
                    {
                        observaciones.Add(obs.ToString());
                    }
                }

                configuracionEmpresa.ObservacionesAlbaranes = observaciones;
                repoEmpresa.GuardarConfiguracionEmpresa(configuracionEmpresa);
            }

            // this.tableAdapterManager.UpdateAll(this.datosAlbaranes);
        }