public tb_Clave_Conting_Info consultar_ult_clave_no_usada(int IdEmpresa, int idAmbiente, ref string mensajeErrorOut)
        {
            try
            {
                tb_Clave_Conting_Info InfoClaveContg = new tb_Clave_Conting_Info();

                decimal IdClaveContige_no_usado = 0;


                using (EntitiesFactElectronica DBFactElec = new EntitiesFactElectronica())
                {
                    var querry = (from claveCont in DBFactElec.tb_Clave_Conting
                                  where claveCont.IdEmpresa == IdEmpresa &&
                                  claveCont.Usado == false &&
                                  claveCont.IdAmbiente == idAmbiente
                                  select claveCont.IdClave).Min();


                    IdClaveContige_no_usado = Convert.ToDecimal(querry.ToString());



                    var querry2 = from clavecon in DBFactElec.tb_Clave_Conting
                                  where clavecon.IdEmpresa == IdEmpresa &&
                                  clavecon.IdClave == IdClaveContige_no_usado &&
                                  clavecon.IdAmbiente == idAmbiente
                                  select clavecon;


                    foreach (var item in querry2)
                    {
                        InfoClaveContg.IdEmpresa         = item.IdEmpresa;
                        InfoClaveContg.IdClave           = item.IdClave;
                        InfoClaveContg.Usado             = item.Usado;
                        InfoClaveContg.Fecha_Trans       = item.Fecha_Trans;
                        InfoClaveContg.ClaveContingencia = item.ClaveContingencia;
                        InfoClaveContg.Fecha_Importacion = item.Fecha_Importacion;
                        InfoClaveContg.Estado            = item.Estado;
                        InfoClaveContg.IdAmbiente        = item.IdAmbiente;
                    }
                }


                Modificar_Clave_Acceso_UsadaDB(InfoClaveContg.IdEmpresa, InfoClaveContg.ClaveContingencia, idAmbiente, true, ref mensajeErrorOut);

                return(InfoClaveContg);
            }
            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(), eTipoError.ERROR, arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensajeErrorOut);
                mensajeErrorOut = ex.InnerException + " " + ex.Message;

                return(new tb_Clave_Conting_Info());
            }
        }
 private void gridViewClaveCont_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     try
     {
         row = (tb_Clave_Conting_Info)gridViewClaveCont.GetFocusedRow();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error " + ex.Message);
     }
 }
        public List <tb_Clave_Conting_Info> Consultar(ref string MensajeErrorOut)
        {
            try
            {
                List <tb_Clave_Conting_Info> lista            = new List <tb_Clave_Conting_Info>();
                EntitiesFactElectronica      OEselecClaveCont = new EntitiesFactElectronica();
                var selectClaveCont = from C in OEselecClaveCont.tb_Clave_Conting
                                      join E in OEselecClaveCont.tb_Empresa on
                                      new { C.IdEmpresa } equals new { E.IdEmpresa }

                select new
                {
                    C.IdEmpresa,
                    C.IdClave,
                    C.Usado,
                    C.IdAmbiente,
                    C.Fecha_Trans,
                    C.Fecha_Importacion,
                    C.ClaveContingencia,
                    C.Estado,
                    E.RazonSocial
                };

                foreach (var item in selectClaveCont)
                {
                    tb_Clave_Conting_Info Cbt = new tb_Clave_Conting_Info();

                    Cbt.IdEmpresa         = item.IdEmpresa;
                    Cbt.IdClave           = item.IdClave;
                    Cbt.IdAmbiente        = item.IdAmbiente;
                    Cbt.Usado             = item.Usado;
                    Cbt.Fecha_Trans       = item.Fecha_Trans;
                    Cbt.Fecha_Importacion = item.Fecha_Importacion;
                    Cbt.ClaveContingencia = item.ClaveContingencia;
                    Cbt.Estado            = item.Estado;
                    Cbt.RazonSocial       = item.RazonSocial;

                    lista.Add(Cbt);
                }
                return(lista);
            }
            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(), eTipoError.ERROR, arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeErrorOut);
                MensajeErrorOut = ex.InnerException + " " + ex.Message;

                return(new List <tb_Clave_Conting_Info>());
            }
        }
Пример #4
0
        public String GeneraClaveAcceso_x_Contingencia(int IdEmpresa, DateTime fechaEmision, String tipoComprobante, String Ambiente, string Emision, ref string mensajeErrorOut)
        {
            try
            {
                InfoClaveCont = Bus_Clave_Con.consultar_ult_clave_no_usada(IdEmpresa, Convert.ToInt32(Ambiente), ref mensajeErrorOut);

                //no tiene clave de contingencia
                if (InfoClaveCont == null || InfoClaveCont.ClaveContingencia == null)
                {
                    mensajeErrorOut = @"no existe claves de contingencia disponibles y no se pudo conectar al webEfirm";
                    #region Log de Errores
                    BusLogError.Log_Error(mensajeErrorOut, eTipoError.ERROR_VALIDACION, this.ToString());
                    #endregion
                    return("");
                }

                String        fecha = fechaEmision.ToString("ddMMyyyy");
                StringBuilder clave = new StringBuilder(fecha); //fecha
                clave.Append(tipoComprobante);                  //tipo cbte tabla 4
                clave.Append(InfoClaveCont.ClaveContingencia);
                clave.Append(Emision);


                return(clave.ToString());
            }
            catch (Exception ex)
            {
                //string mensajeErrorOut = "";
                #region Log de Errores
                mensajeErrorOut = ex.Message.ToString();
                tb_sis_Log_Error_Vzen_Data oData         = 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(), eTipoError.ERROR, this.ToString(), "",
                                                                                          "", "", "", "", DateTime.Now);
                oData.Guardar_Log_Error(Log_Error_sis, ref mensajeErrorOut);
                #endregion

                return("");
            }
        }