private void consultarBDporFechayHora(DateTime myDate) { //llamar a algun metodo en la BD. _conexionSQL conectarBD = _conexionSQL.Instance; DataTable resultadoConsulta = new DataTable(); //string fechaSQL = Properties.Settings.Default.FECHA_HORA_APP.Date.ToString("dd-MM-yyyy hh:mm:ss"); resultadoConsulta = conectarBD.ejecutarUnaQuery(@"exec DALE_SA.ActualizarFechaHoraBD '" + myDate.ToString("yyyy/MM/dd hh:mm:ss") + @"'"); System.Console.WriteLine("NUEVA FECHA Y HORA: " + Properties.Settings.Default.FECHA_HORA_APP.ToString("yyyy/MM/dd hh:mm:ss")); if (resultadoConsulta != null) { System.Console.WriteLine("NUEVA FECHA Y HORA: " + resultadoConsulta.Rows[0][0].ToString()); //if (String.Compare(Properties.Settings.Default.FECHA_HORA_APP.ToString(), (DateTime.Parse(resultadoConsulta.Rows[0][0].ToString())).ToString()) == 0) if ((DateTime.Compare(myDate, (DateTime)resultadoConsulta.Rows[0][0])) == 0) { //MessageBox.Show("Se cambio OK la Fecha y Hora en la BD"); } else { MessageBox.Show("Hubo problemas al cambiar la fecha y hora en la BD. Por favor revise la conexion"); } //Usa un dataTable porque esta usando un metodo generico... para este caso es idem que sea void. } else { MessageBox.Show("Hubo problemas al cambiar la fecha y hora en la BD(Al cerrar publicaciones). Por favor revise la conexion"); } }
private void bLogin_Click(object sender, EventArgs e) { // levanto usuario y contraseña string user = null; string password = null; string retorno; user = this.txtUsuario.Text; password = this.txtPassword.Text; if ((String.IsNullOrWhiteSpace(user)) || (String.IsNullOrWhiteSpace(password))) { MessageBox.Show("Por favor complete Usuario y/o contraseña"); return; } password = _SHA256Encrypt.encriptar(this.txtPassword.Text); //Hago una prueba con la palabra hola -> b221d9dbb083a7f33428d7c2a3c3198ae925614d70210e28716ccaa7cd4ddb79 /* System.Console.WriteLine(_SHA256Encrypt.encriptar("dcappa")); * System.Console.WriteLine(_SHA256Encrypt.encriptar("esuchecki")); * System.Console.WriteLine(_SHA256Encrypt.encriptar("lmontavan")); * System.Console.WriteLine(_SHA256Encrypt.encriptar("amarcovecchio")); */ //Se loguea en la BD. _conexionSQL conectarBD = _conexionSQL.Instance; retorno = conectarBD.prueba_login(user, password); //MessageBox.Show(retorno); if (retorno.Equals("-3")) { MessageBox.Show("Problemas con la base de datos"); this.txtPassword.Text = ""; this.txtUsuario.Text = ""; return; } if (retorno.Equals("-2")) { MessageBox.Show("Usuario bloqueado conecte a administracion"); this.txtPassword.Text = ""; this.txtUsuario.Text = ""; return; } if (retorno.Equals("-1")) { MessageBox.Show("Usuario o contraseña invalida"); this.txtPassword.Text = ""; //this.txtUsuario.Text = ""; return; } this.MENU_OPEN(retorno); this.txtIdUsuario.Text = retorno; }
private void btAceptarElegirRol_Click(object sender, EventArgs e) { //MessageBox.Show(this.comboElegirRol.Text); DataTable resultado2 = new DataTable(); _conexionSQL conectarBD = _conexionSQL.Instance; string sql; // comienzo.... sql = @"select t1.nombre as nombre from DALE_SA.rol t1 where t1.nombre = RTRIM(LTRIM('" + this.comboElegirRol.Text + @"'))"; resultado2 = conectarBD.ejecutarUnaQuery(sql); fcAuxiliarLogin(ref resultado2); this.gboxElegirRol.Visible = false; this.gboxElegirRol.Enabled = false; this.gboxHoraFechaSistema.Visible = true; //que se vea la hora this.gboxHoraFechaSistema.Enabled = true; }
private void fcFuncionalidadDelRol(string nombreRol) { DataTable resultado2 = new DataTable(); _conexionSQL conectarBD = _conexionSQL.Instance; string sql; // comienzo.... sql = @" select t3.descripcion as NombreFuncionalidad from DALE_SA.rol t1, DALE_SA.rol_funcionalidad t2, DALE_SA.funcionalidad t3 where t1.nombre = RTRIM(LTRIM('" + nombreRol + @"')) and t1.idrol = t2.idrol and t2.idfuncionalidad = t3.idfuncionalidad "; resultado2 = conectarBD.ejecutarUnaQuery(sql); //habilito o deshabilito los menues segun funcionalidades foreach (DataRow dtRow in resultado2.Rows) { switch (dtRow["NombreFuncionalidad"].ToString()) { case "ABM de ROL": this.AMB_ROL.Visible = true; this.AMB_ROL.Enabled = true; break; case "ABM de USUARIOS": this.AMB_USUARIO.Visible = true; this.AMB_USUARIO.Enabled = true; break; case "ABM de VISIBILIDAD": this.ABM_VIS.Visible = true; this.ABM_VIS.Enabled = true; break; case "ABM de RUBRO": break; case "Facturas por Vendedor": this.cONSULTAFACTURASAVENDEDORToolStripMenuItem.Enabled = true; this.cONSULTAFACTURASAVENDEDORToolStripMenuItem.Visible = true; break; case "Listado Estadistico": this.cONSULTARESTADISTICASToolStripMenuItem.Enabled = true; this.cONSULTARESTADISTICASToolStripMenuItem.Visible = true; break; case "Comprar y Ofertar": this.COMPRA.Enabled = true; this.COMPRA.Visible = true; this.COMPRA_BUSCAR.Enabled = true; this.COMPRA_BUSCAR.Visible = true; break; case "Historial del Cliente y Calificacion": this.miHistorialDeComprasToolStripMenuItem.Visible = true; this.miHistorialDeComprasToolStripMenuItem.Enabled = true; this.calificarToolStripMenuItem.Visible = true; this.calificarToolStripMenuItem.Enabled = true; break; case "Generar Publicacion": this.PUBLICACION.Enabled = true; this.PUBLICACION.Visible = true; this.COMPRA_BUSCAR.Enabled = true; break; } } }
private void MENU_OPEN(string user) { this.AcceptButton = null; this.LOGIN.Visible = false; this.LOGIN.Enabled = false; this.ABM.Visible = true; this.ABM.Enabled = true; this.AMB_ROL.Visible = false; this.AMB_USUARIO.Visible = false; this.AMB_ROL.Enabled = false; this.AMB_USUARIO.Enabled = false; this.ABM_VIS.Enabled = false; this.ABM_VIS.Visible = false; this.cAMBIARMIPWDToolStripMenuItem.Visible = true; this.cAMBIARMIPWDToolStripMenuItem.Enabled = true; this.cONSULTARESTADISTICASToolStripMenuItem.Enabled = false; this.cONSULTARESTADISTICASToolStripMenuItem.Visible = false; this.vERIFICARDUPLICADOSToolStripMenuItem.Enabled = false; this.vERIFICARDUPLICADOSToolStripMenuItem.Visible = false; this.cONSULTAFACTURASAVENDEDORToolStripMenuItem.Enabled = false; this.cONSULTAFACTURASAVENDEDORToolStripMenuItem.Visible = false; _conexionSQL conectarBD = _conexionSQL.Instance; DataTable resultadoConsulta = new DataTable(); Boolean retorno = conectarBD.prueba_data(user, ref resultadoConsulta); //resultadoConsulta.Columns.Remove if (resultadoConsulta.Rows.Count > 1) { //tiene mas de 1 rol! this.comboElegirRol.Items.Clear(); foreach (DataRow dtRow in resultadoConsulta.Rows) { //this.comboElegirRol.Items.Add this.comboElegirRol.Items.Add(dtRow["nombre"].ToString()); //dtRow["nombre"].ToString(); } this.gboxHoraFechaSistema.Visible = false; //que NO se vea la hora this.gboxHoraFechaSistema.Enabled = false; this.gboxElegirRol.Visible = true; this.gboxElegirRol.Enabled = true; } else { this.gboxHoraFechaSistema.Visible = true; //que se vea la hora this.gboxHoraFechaSistema.Enabled = true; fcAuxiliarLogin(ref resultadoConsulta); } this.STATUS_LABEL.Text = @"Bienvenido: " + this.txtUsuario.Text; this.lidusuario.Text = user; DateTime fechaHoraLocal = Properties.Settings.Default.FECHA_HORA_APP; //con esto averigua la fechaHora local del sistema this.dTimePiker_FechaActual.Value = fechaHoraLocal; this.dTimePiker_HoraActual.Value = fechaHoraLocal; this.dTimePiker_HoraNueva.Value = fechaHoraLocal; this.dTimePiker_FechaNueva.Value = fechaHoraLocal; // hago la llamada a la bd con la hora y fecha del sistema.. this.consultarBDporFechayHora(fechaHoraLocal); //agrego unas cosas de la configuracion regional para evitar problemas... }