private void Form1_Load(object sender, EventArgs e) { if(AdministradorXML.Login.sourceGlobal.Equals("ERROR")) { System.Windows.Forms.MessageBox.Show("Sunplusito® se abre desde el formulario de Sunplus. No se detecto el operador.", "Sunplusito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (System.Windows.Forms.Application.MessageLoop) { System.Windows.Forms.Application.Exit(); } else { System.Environment.Exit(1); } } logueadoComoToolStripMenuItem.Text = "Logueado como: " + AdministradorXML.Login.sourceGlobal+" en "+Login.unidadDeNegocioGlobal; siguiente = true; String connString2 = "Database=" + Properties.Settings.Default.sunDatabase + ";Data Source=" + Properties.Settings.Default.datasource + ";Integrated Security=False;User ID='" + Properties.Settings.Default.user + "';Password='******';connect timeout = 10"; String queryCheck = "USE [" + Properties.Settings.Default.sunDatabase + "] SELECT name FROM sys.tables"; try { using (SqlConnection connection = new SqlConnection(connString2)) { connection.Open(); SqlCommand cmdCheck = new SqlCommand(queryCheck, connection); SqlDataReader reader = cmdCheck.ExecuteReader(); if (reader.HasRows) { // System.Windows.Forms.MessageBox.Show("Conexión Establecida satisfactoriamente", "Sunplusito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { config form = new config(); form.ShowDialog(); // System.Windows.Forms.MessageBox.Show("Sin conexión", "Sunplusito", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception) { config form = new config(); form.ShowDialog(); //System.Windows.Forms.MessageBox.Show("Sin conexión", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }/* try { // Open the text file using a stream reader. using (StreamReader sr = new StreamReader("settings.txt")) { String line = sr.ReadToEnd(); Properties.Settings.Default.datasource = line; Properties.Settings.Default.Save(); } } catch (Exception ex) { ex.ToString(); }*/ arreglaAlgunosProblemillas(); arreglarErrorCanceladosSinRazon(); int height = Screen.PrimaryScreen.Bounds.Height; int width = Screen.PrimaryScreen.Bounds.Width; int posX = 50; int posY = 50; int dif = 20; totalIngresoSATLabel.Location = new Point(posX, posY + (height / 2) - (posY * 2) + 5); totalEgresosSATLabel.Location = new Point(posX, posY + (height / 2) - (posY * 2) + posY + (height / 2) - (posY * 2)+5); listaFinal = new List<Dictionary<string, object>>(); listaFinalEgresosSAT = new List<Dictionary<string, object>>(); listaFinalIngresosSunplus = new List<Dictionary<string, object>>(); listaFinalEgresosSunPlus = new List<Dictionary<string, object>>(); totalIngresosSunplusLabel.Location = new Point((width / 2) + (posX / 2), posY + (height / 2) - (posY * 2) + 5); totalEgresosSunplusLabel.Location = new Point((width / 2) + (posX / 2), posY + (height / 2) - (posY * 2) + posY + (height / 2) - (posY * 2) + 5); periodoLabel.Location = new Point(posX, posY-dif); periodosCombo.Location = new Point(periodosCombo.Location.X, posY - dif-7); ingresosSATList.Location = new Point(posX, posY); ingresosSATList.Size = new Size((width / 2) - (posX * 2), (height / 2) - (posY * 2)); ingresosSunPlusList.Location = new Point((width / 2) + (posX / 2), posY); ingresosSunPlusList.Size = new Size((width / 2) - (posX * 2), (height / 2) - (posY * 2)); gastosSATList.Location = new Point(posX, posY + (height / 2) - (posY * 2)+posY); gastosSATList.Size = new Size((width / 2) - (posX * 2), (height / 2) - (posY * 2)); gastosSunplusList.Location = new Point((width / 2) + (posX / 2), posY + (height / 2) - (posY * 2) + posY); gastosSunplusList.Size = new Size((width / 2) - (posX * 2), (height / 2) - (posY * 2)); //String queryPeriodos = "SELECT DISTINCT SUBSTRING( CAST(fechaExpedicion AS NVARCHAR(11)),1,7) as periodos FROM [" + Properties.Settings.Default.databaseFiscal + "].[dbo].[facturacion_XML] WHERE CAST(fechaExpedicion AS NVARCHAR(11)) != 'NULL'"; String connString = "Database=" + Properties.Settings.Default.databaseFiscal + ";Data Source=" + Properties.Settings.Default.datasource + ";Integrated Security=False;MultipleActiveResultSets=true;User ID='" + Properties.Settings.Default.user + "';Password='******';connect timeout = 60"; String queryPeriodos = "SELECT DISTINCT SUBSTRING( CAST(fechaExpedicion AS NVARCHAR(11)),1,7) as periodos FROM [" + Properties.Settings.Default.databaseFiscal + "].[dbo].[facturacion_XML] WHERE CAST(fechaExpedicion AS NVARCHAR(11)) != 'NULL' AND rfcRaiz = '"+Login.rfcGlobal+"' order by SUBSTRING( CAST(fechaExpedicion AS NVARCHAR(11)),1,7) asc"; try { using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); SqlCommand cmdCheck = new SqlCommand(queryPeriodos, connection); SqlDataReader reader = cmdCheck.ExecuteReader(); int empiezo = 1; if (reader.HasRows) { while (reader.Read()) { String periodo = reader.GetString(0); periodosCombo.Items.Add(new Item(periodo, empiezo)); empiezo++; } } else { System.Windows.Forms.MessageBox.Show("No existen Periodos, primero descarga xml del buzon tributario.", "Sunplusito", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString(), "Sunplusito", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // periodosCombo.SelectedIndex = periodosCombo.Items.Count - 1; }
private void variablesToolStripMenuItem_Click(object sender, EventArgs e) { config form = new config(); form.Show(); }