private void UltraGrid_DocAnu_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     try
     {
         Info = (tb_sis_Documento_Tipo_x_Empresa_Anulados_Info)UltraGrid_DocAnu.GetFocusedRow();
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
 public Boolean GuardarDB(tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Info, ref string msj)
 {
     try
     {
         //if(Info.Documento == Info.DocumentoFin)
         //{
         if (!data.ValidaSiEstaAnulado(Info.IdEmpresa, Info.codDocumentoTipo, Info.Serie1, Info.Serie2, Info.Documento))
         {
             return(data.GuardarDB(Info));
         }
         else
         {
             msj = "El documento: " + Info.Serie1 + "-" + Info.Serie2 + "-" + Info.Documento + "ya fue Anulado";
             return(false);
         }
         //}
         //else
         //{
         //    string doc = "";
         //    string d = "";
         //    decimal ini=Convert.ToDecimal(Info.Documento);
         //    decimal fin = Convert.ToDecimal(Info.DocumentoFin);
         //    for(decimal i=ini  ; i <= fin; i++)
         //    {
         //        if (!data.ValidaSiEstaAnulado(Info.IdEmpresa, Info.codDocumentoTipo, Info.Serie1, Info.Serie2, Info.Documento))
         //        {
         //            Info.Documento = i.ToString(); Info.DocumentoFin = i.ToString();
         //            data.GuardarDB(Info);
         //        }
         //        else
         //        {
         //            doc = doc + d + i;
         //            d = " - ";
         //        }
         //    }
         //    if(doc.Length > 0)
         //    {
         //        msj = "Estos documentos (" + doc + ") ya fueron anulados con anterioridad ";
         //        return false;
         //    }
         //    else
         //        return true;
         //}
     }
     catch (Exception ex)
     {
         Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
         throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "validarEstadoDocumento", ex.Message), ex)
               {
                   EntityType = typeof(tb_sis_Documento_Tipo_x_Empresa_Anulados_Bus)
               };
     }
 }
        public Boolean GuardarDB(tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Info)
        {
            try
            {
                List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> Lst = new List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info>();
                using (EntitiesGeneral Context = new EntitiesGeneral())
                {
                    var Address = new tb_sis_Documento_Tipo_x_Empresa_Anulados();

                    Address.IdEmpresa        = Info.IdEmpresa;
                    Address.codDocumentoTipo = Info.codDocumentoTipo;
                    Address.IdTipoDocAnu     = get_ID(Info.IdEmpresa);
                    Address.Fecha            = Info.Fecha;
                    Address.Serie1           = Info.Serie1;
                    Address.Serie2           = Info.Serie2;
                    Address.Documento        = Info.Documento;
                    //Address.DocumentoFin = Info.DocumentoFin;
                    Address.Autorizacion = Info.Autorizacion;
                    Address.IdMotivoAnu  = Info.IdMotivoAnu;
                    Address.MotivoAnu    = Info.MotivoAnu;


                    Address.nom_pc = Info.nom_pc;
                    Address.ip     = Info.ip;

                    Address.IdUsuarioUltAnu = Info.IdUsuarioUltAnu;
                    Address.Fecha_UltAnu    = Info.Fecha_UltAnu;

                    Context.tb_sis_Documento_Tipo_x_Empresa_Anulados.Add(Address);
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
        public List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> ConsultaGeneral(int IdEmpresa)
        {
            try
            {
                List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> Lst = new List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info>();
                EntitiesGeneral oEnti = new EntitiesGeneral();
                var             Query = from q in oEnti.vwtb_sis_Documento_Tipo_x_Empresa_Anulados
                                        where q.IdEmpresa == IdEmpresa
                                        select q;
                foreach (var item in Query)
                {
                    tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Obj = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                    Obj.IdEmpresa        = item.IdEmpresa;
                    Obj.codDocumentoTipo = item.CodDocumentoTipo;
                    //Obj.IdTipoDocAnu = item.IdTipoDocAnu;
                    Obj.Fecha     = item.fecha;
                    Obj.Serie1    = item.serie1;
                    Obj.Serie2    = item.serie2;
                    Obj.Documento = item.NumRetencion;
                    //Obj.Autorizacion = item.Autorizacion;
                    //Obj.IdMotivoAnu = item.IdMotivoAnu;
                    //Obj.MotivoAnu = item.MotivoAnu;

                    Obj.Serie       = item.serie1 + "-" + item.serie2;
                    Obj.Docu_IniFin = item.NumRetencion;
                    //Obj.nom_DocuTipo = item.Descripcion;
                    //Obj.nom_MotivoAnu = item.ca_descripcion;
                    Lst.Add(Obj);
                }
                return(Lst);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
        private void LlamaFRM(Cl_Enumeradores.eTipo_action Accion, tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Info)
        {
            try
            {
                frm = new FrmGe_DocuAnulados();
                frm.event_FrmGe_DocuAnulados_FormClosing += frm_event_FrmGe_DocuAnulados_FormClosing;
                frm.MdiParent = this.MdiParent;
                frm.set_accion(Accion);

                if (!(Accion == Cl_Enumeradores.eTipo_action.grabar))
                {
                    // frm.set_Info(Info);

                    frm.set = Info;
                }

                frm.Show();
            }
            catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString());
                                   MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Esempio n. 6
0
        public void set_Info()
        {
            try
            {
                cmbTipoDocu.EditValue    = set.codDocumentoTipo;
                cmbMotivoAnula.EditValue = set.IdMotivoAnu;

                dtp_fecha.Value  = set.Fecha;
                txt_AutSRI.Text  = set.Autorizacion;
                txt_serie1.Text  = set.Serie1;
                txt_docIni.Text  = set.Documento;
                txt_serie2.Text  = set.Serie2;
                txt_docFin.Text  = set.Documento;
                txt_detalle.Text = set.MotivoAnu;

                Doc_I = set;
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> ConsultaPorMesAnio(int IdEmpresa, int anio, int mes)
        {
            try
            {
                #region Antiguo

                /*
                 * List<tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> Lst = new List<tb_sis_Documento_Tipo_x_Empresa_Anulados_Info>();
                 * EntitiesGeneral oEnti = new EntitiesGeneral();
                 * var Query = from q in oEnti.tb_sis_Documento_Tipo_x_Empresa_Anulados
                 *          where q.IdEmpresa == IdEmpresa && q.Fecha.Year == anio && q.Fecha.Month == mes
                 *          select q;
                 * foreach (var item in Query)
                 * {
                 *  tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Obj = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                 *  Obj.IdEmpresa = item.IdEmpresa;
                 *  Obj.codDocumentoTipo = item.codDocumentoTipo;
                 *  Obj.IdTipoDocAnu = item.IdTipoDocAnu;
                 *  Obj.Fecha = item.Fecha;
                 *  Obj.Serie1 = item.Serie1;
                 *  Obj.Serie2 = item.Serie2;
                 *  //Obj.DocumentoIni = item.DocumentoInicio;
                 *  //Obj.DocumentoFin = item.DocumentoFin;
                 *  Obj.Autorizacion = item.Autorizacion;
                 *  Obj.IdMotivoAnu = item.IdMotivoAnu;
                 *  Obj.MotivoAnu = item.MotivoAnu;
                 *  Obj.nom_pc = item.nom_pc;
                 *  Obj.ip = item.ip;
                 *  Obj.IdUsuarioUltAnu = item.IdUsuarioUltAnu;
                 *  Obj.Fecha_UltAnu = item.Fecha_UltAnu;
                 *  Lst.Add(Obj);
                 * }
                 *
                 * EntitiesCuentasxPagar oEnti_cxp = new EntitiesCuentasxPagar();
                 *
                 *
                 * //Retenciones
                 * var Query_ret = from q in oEnti_cxp.cp_retencion
                 *           where q.IdEmpresa == IdEmpresa
                 *           && q.fecha.Year == anio
                 *           && q.fecha.Month == mes
                 *           && q.Estado == "I"
                 *           select q;
                 *
                 * foreach (var item in Query_ret)
                 * {
                 *  tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Obj = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                 *  Obj.IdEmpresa = item.IdEmpresa;
                 *  Obj.codDocumentoTipo = "07";
                 *  Obj.IdTipoDocAnu = 0;
                 *  Obj.Fecha = item.fecha;
                 *  Obj.Serie1 = item.serie1;
                 *  Obj.Serie2 = item.serie2;
                 *  Obj.Documento = item.NumRetencion;
                 *  Obj.Docu_IniFin = item.NumRetencion;
                 *  Obj.DocumentoFin = item.NumRetencion;
                 *  Obj.Autorizacion = item.NAutorizacion;
                 *  Obj.IdMotivoAnu = 0;
                 *  Obj.MotivoAnu = item.MotivoAnulacion;
                 *  Obj.nom_pc = item.nom_pc;
                 *  Obj.ip = item.ip;
                 *  Obj.IdUsuarioUltAnu = item.IdUsuarioUltAnu;
                 *  Obj.Fecha_UltAnu = item.Fecha_UltAnu;
                 *
                 *  Lst.Add(Obj);
                 * }
                 *
                 *
                 *
                 *
                 * EntitiesFacturacion oEnti_fact = new EntitiesFacturacion();
                 *
                 * //ventas de cliente
                 *
                 * var Query_vta = from q in oEnti_fact.fa_factura
                 *           where q.IdEmpresa == IdEmpresa
                 *           && q.vt_fecha.Year == anio
                 *           && q.vt_fecha.Month == mes
                 *           && q.Estado=="I"
                 *           select q;
                 *
                 * foreach (var item in Query_vta)
                 * {
                 *  tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Obj = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                 *  Obj.IdEmpresa = item.IdEmpresa;
                 *  Obj.codDocumentoTipo = "18";
                 *  Obj.IdTipoDocAnu = 0;
                 *  Obj.Fecha = item.vt_fecha;
                 *  Obj.Serie1 = item.vt_serie1;
                 *  Obj.Serie2 = item.vt_serie2;
                 *  Obj.Documento = item.vt_NumFactura;
                 *  Obj.Docu_IniFin = item.vt_NumFactura;
                 *  Obj.DocumentoFin = item.vt_NumFactura;
                 *  Obj.Autorizacion = item.vt_autorizacion;
                 *  Obj.IdMotivoAnu = 0;
                 *  Obj.MotivoAnu = item.MotivoAnulacion;
                 *  Obj.nom_pc = item.nom_pc;
                 *  Obj.ip = item.ip;
                 *  Obj.IdUsuarioUltAnu = item.IdUsuarioUltAnu;
                 *  Obj.Fecha_UltAnu = item.Fecha_UltAnu;
                 *
                 *  Lst.Add(Obj);
                 * }
                 *
                 * //notas debito y credito faturacion
                 *
                 * var Query_Nota_deb_cred = from q in oEnti_fact.fa_notaCreDeb
                 *              where q.IdEmpresa == IdEmpresa
                 *              && q.no_fecha.Year == anio
                 *              && q.no_fecha.Month == mes
                 *              && q.Estado == "I"
                 *              && q.NaturalezaNota == "SRI"
                 *              select q;
                 *
                 * foreach (var item in Query_Nota_deb_cred)
                 * {
                 *  tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Obj = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                 *  Obj.IdEmpresa = item.IdEmpresa;
                 *  Obj.codDocumentoTipo = (item.CreDeb == "C") ? "04" : "05";
                 *  Obj.IdTipoDocAnu = 0;
                 *  Obj.Fecha = item.no_fecha;
                 *  Obj.Serie1 = item.Serie1;
                 *  Obj.Serie2 = item.Serie2;
                 *  Obj.Documento = item.NumNota_Impresa;
                 *  Obj.Docu_IniFin = item.NumNota_Impresa;
                 *  Obj.DocumentoFin = item.NumNota_Impresa;
                 *  Obj.Autorizacion = item.NumAutorizacion;
                 *  Obj.IdMotivoAnu = 0;
                 *  Obj.MotivoAnu = item.MotiAnula;
                 *  Obj.nom_pc = item.nom_pc;
                 *  Obj.ip = item.ip;
                 *  Obj.IdUsuarioUltAnu = item.IdUsuarioUltAnu;
                 *  Obj.Fecha_UltAnu = item.Fecha_UltAnu;
                 *
                 *  Lst.Add(Obj);
                 * }
                 * */
                #endregion

                List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> Lst = new List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info>();
                EntitiesGeneral oEnti = new EntitiesGeneral();
                var             Query = from q in oEnti.vwtb_sis_Documento_Tipo_x_Empresa_Anulados
                                        where q.IdEmpresa == IdEmpresa && q.anio == anio && q.mes == mes
                                        select q;
                foreach (var item in Query)
                {
                    tb_sis_Documento_Tipo_x_Empresa_Anulados_Info Obj = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                    Obj.IdEmpresa        = item.IdEmpresa;
                    Obj.codDocumentoTipo = item.CodDocumentoTipo;
                    //Obj.IdTipoDocAnu = item.IdTipoDocAnu;
                    Obj.Fecha        = item.fecha;
                    Obj.Serie1       = item.serie1;
                    Obj.Serie2       = item.serie2;
                    Obj.Docu_IniFin  = item.Documento_ini;
                    Obj.DocumentoFin = item.Documento_fin;
                    Obj.Documento    = item.NumRetencion;
                    Obj.Autorizacion = item.NumAutorizacion;
                    //Obj.IdMotivoAnu = item.IdMotivoAnu;
                    //Obj.MotivoAnu = item.MotivoAnu;
                    //Obj.nom_pc = item.nom_pc;
                    //Obj.ip = item.ip;
                    //Obj.IdUsuarioUltAnu = item.IdUsuarioUltAnu;
                    //Obj.Fecha_UltAnu = item.Fecha_UltAnu;
                    Lst.Add(Obj);
                }



                return(Lst);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Esempio n. 8
0
        private void Grabar()
        {
            try
            {
                if (validaColumna())
                {
                    get_Info();

                    if (_Accion == Cl_Enumeradores.eTipo_action.grabar)
                    {
                        if (rb_Documento.Checked == true)
                        {
                            string msj = "";
                            if (Doc_B.GuardarDB(Doc_I, ref msj))
                            {
                                MessageBox.Show("Documento Anulado correctamente", "SISTEMAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                ucGe_Menu.Visible_bntAnular = false;
                                this.Close();
                            }
                            else
                            {
                                if (msj.Length > 0)
                                {
                                    MessageBox.Show(msj, "SISTEMAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    ucGe_Menu.Visible_bntAnular = false;
                                }
                                else
                                {
                                    MessageBox.Show("No se pudo Anular.. Comuníquese con Sistemas", "SISTEMAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                        else
                        {
                            if (rb_Lote.Checked == true)
                            {
                                string msg   = "";
                                string msg2  = "";
                                int    conta = Convert.ToInt32(txt_docFin.Text) - Convert.ToInt32(txt_docIni.Text);
                                int    r     = 0;
                                string micadena;
                                int    d = Convert.ToInt32(txt_docIni.MaxLength);
                                //Boolean allOk = true;
                                for (int i = 0; i <= conta; i++)
                                {
                                    Info = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Info();
                                    cp_TipoDocumento_Info obj  = (cp_TipoDocumento_Info)cmbTipoDocu.Properties.View.GetFocusedRow();
                                    tb_Catalogo_Info      obj2 = (tb_Catalogo_Info)cmbMotivoAnula.Properties.View.GetFocusedRow();
                                    //asigno la empresa
                                    Info.IdEmpresa        = param.IdEmpresa;
                                    Info.codDocumentoTipo = obj.CodTipoDocumento;
                                    Info.Fecha            = dtp_fecha.Value;
                                    //asigno valor a mi numero inicial serie1 y serie2
                                    Info.Serie1          = txt_serie1.Text.PadLeft(3, '0');
                                    Info.Serie2          = txt_serie2.Text.PadLeft(3, '0');
                                    r                    = i + Convert.ToInt32(txt_docIni.Text);
                                    micadena             = r.ToString();
                                    Info.Documento       = micadena.PadLeft(d, '0');
                                    Info.DocumentoFin    = txt_docFin.Text;
                                    Info.Autorizacion    = txt_AutSRI.Text;
                                    Info.IdMotivoAnu     = obj2.IdCatalogo;
                                    Info.MotivoAnu       = txt_detalle.Text;
                                    Info.Fecha_Transac   = param.Fecha_Transac;
                                    Info.IdUsuario       = param.IdUsuario;
                                    Info.IdEmpresa       = param.IdEmpresa;
                                    Info.ip              = param.ip;
                                    Info.nom_pc          = param.nom_pc;
                                    Info.IdUsuarioUltAnu = param.IdUsuario;
                                    Info.Fecha_UltAnu    = param.Fecha_Transac;
                                    if (!Doc_B.GuardarDB(Info, ref msg))
                                    {
                                        msg2 = msg;
                                        //allOk = false;
                                    }
                                }
                                MessageBox.Show("Los documementos han sido anulados correctamente", "SISTEMAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                ucGe_Menu.Visible_bntAnular = false;
                                this.Close();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }