Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     MySqlDataAccess dAccess = new MySqlDataAccess();
     var date1 = date_from.Value.ToString("d/M/yyyy");
     var date2 = date_to.Value.ToString("d/M/yyyy");
     var type = reportType_cmb.SelectedIndex;
     var timestamp = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString();
     if(type > -1)
     {
         switch(type)
         {
             //case 0:
             //    dAccess.GetRecords("Count_Hours_2", @"\ReporteTotales" + Global.appUser + "-" + timestamp + ".xlsx", date1, date2, Global.appUserId);
             //    break;
             //case 1:
             //    dAccess.GetRecords("Raw_Report_2", @"\ReporteDetallado" + Global.appUser + "-" + timestamp + ".xlsx", date1, date2, Global.appUserId);
             //    break;
             case 0:
                 dAccess.GetRecords("Count_Hours_2", @"\ReporteTotales-" + timestamp + ".xlsx", date1, date2);
                 break;
             case 1:
                 dAccess.GetRecords("Raw_Report_2", @"\ReporteDetallado-" + timestamp + ".xlsx", date1, date2);
                 break;
         }           
     MessageBox.Show("El reporte ha sido generado exitosamente");
     
     }
     else
         MessageBox.Show("Seleccione un tipo de reporte");
     
 }
Example #2
0
        private void ok_Button_Click(object sender, EventArgs e)
        {
            MySqlDataAccess dAccess = new MySqlDataAccess();
            //var hashedString = Convert.ToBase64String(hashedBytes);

            byte[] passwordBytes = Encoding.Unicode.GetBytes(pass_txtBox.Text);
            //
            // This is where you'd normally append or prepend the salt bytes
            //
            var hasher = System.Security.Cryptography.SHA256.Create();
            byte[] hashedBytes = hasher.ComputeHash(passwordBytes);

            try
            {
                var result = dAccess.GetUser("select * from Users where UserName = @userName and Password = @password", user_txtBox.Text, hashedBytes);
                if (!result)
                {
                    ClearTextBoxes();
                    MessageBox.Show("Usuario o contraseƱa incorrectos... vuelva a intentar");
                }
                else
                {
                    Log.Info("Usuario " + user_txtBox.Text + " logueado correctamente");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error " + ex.Message);
            }                
        }
Example #3
0
        private void ok_Button_Click(object sender, EventArgs e)
        {
            string user = user_txtBox.Text;
            MySqlDataAccess dAccess = new MySqlDataAccess();

            byte[] passwordBytes = Encoding.Unicode.GetBytes(pass_txtBox.Text);
            //
            // This is where you'd normally append or prepend the salt bytes
            //
            var hasher = System.Security.Cryptography.SHA256.Create();
            byte[] hashedBytes = hasher.ComputeHash(passwordBytes);

            //string command = "Update Users set password = HASHBYTES('sha2_256', @password)";
            string command = "Update Users set password = @password";
            command += " where userName = @userName";

            dAccess.RegisterUser(command, user, hashedBytes);

            this.Close();            
        }
Example #4
0
        private int GetLastActivity()
        {
            MySqlDataAccess dAccess = new MySqlDataAccess();
            var result = dAccess.ReadLastActivity("select actionId from Activity where userId = " + Global.appUserId + " order by id desc Limit 1");

            return result;
        }
Example #5
0
        private void RegisterEvent(Enums.Actions action, string observaciones, string station)
        {
            MySqlDataAccess mySqlDAccess = new MySqlDataAccess();
            string mySqlcommand = "INSERT INTO Activity (userId, fecha, hora, actionId, estacion, observaciones)";
            mySqlcommand += " VALUES (@userId, @fecha, @hora, @actionId, @station, @observaciones)";
            try
            {
                mySqlDAccess.SaveAction(mySqlcommand, Global.appUserId, action, currentTime.Text, observaciones, station);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
Example #6
0
        public bool UpdateDBase(string path)
        {
            bool status = false;
            
            if (File.Exists(path))
            {                
                try
                {
                    MySqlDataAccess da = new MySqlDataAccess();
                    System.IO.StreamReader file = new System.IO.StreamReader(path);                    

                    //while ((line = file.ReadLine()) != null)
                    //{
                    //    Log.Info("entered while");
                    //    da.SaveOfflineAction(line);
                    //    Log.Info("Offline action saved");
                    //}
                    //Log.Info("Offline activity saved");

                    da.SaveOfflineAction(file);

                    status = true;
                    file.Close(); 
                    file.Dispose();                                        
                    File.Delete(path);                    
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);                    
                }                
            }

            return status;
        }