Example #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            ScanPerson   scnPerson = (ScanPerson)Session["session"];
            LoggIn       lg        = new LoggIn();
            ChartDetails chrd      = new ChartDetails();
            Dictionary <TimeSpan, double> DictionaryPromilesAndHours = new Dictionary <TimeSpan, double>();

            DictionaryPromilesAndHours = scnPerson.alcoReducingInTime(scnPerson.DrinkStartVal, scnPerson.DrinkTimeValue, scnPerson.MaxAlcoCOncentrationVal);
            foreach (KeyValuePair <TimeSpan, double> item in DictionaryPromilesAndHours)
            {
                PromilesInBloodCrt.Series[0].Points.AddXY(item.Key.ToString(), Math.Round(item.Value, 2));
            }
            string nicki = (string)Session["Nick"];

            if (Session["correctLogin"] != null)
            {
                lg.RightUser = (bool)Session["correctLogin"];
            }
            if (lg.RightUser == true)
            {
                toSql(scnPerson, chrd, DictionaryPromilesAndHours);
                toRaport(scnPerson, chrd, DictionaryPromilesAndHours, nicki);
                Session["session"]      = scnPerson;
                Session["correctLogin"] = null;
                _imie.ToString();
            }
            if (lg.RightUser == false)
            {
                toRaport(scnPerson, chrd, DictionaryPromilesAndHours, nicki);
            }
            if (uzytkownikLbl.Text != null)
            {
                uzytkownikLbl.Text = _imie.ToString();
            }
        }
Example #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            ScanPerson scnPerson = new ScanPerson();
            LoggIn     logg      = new LoggIn();

            try
            {
                namePerson  = nameTxb.Text;
                emailPerson = emailTxb.Text;
                passPerson  = passTxb.Text;
                confirmPass = confirmPassTxb.Text;
                string wrongInfo = wrongInfoEmailLbl.Text;
                correctEmail = isValidEmail(emailPerson);
                if (!correctEmail)
                {
                    wrongInfoEmailLbl.Text = "Podaj poprawny mail";
                }
                else
                {
                    PersonDataRegistration prsnDataReg = new PersonDataRegistration(namePerson, emailPerson, passPerson, confirmPass);
                    prsnDataReg.SetUnicqlyValue(namePerson, emailPerson, passPerson, confirmPass);
                    logg.logUser(namePerson, emailPerson, passPerson);
                    prsnDataReg.lookAtName(CheckIsNickIn);
                }
            }
            catch (Exception exception)
            {
                wrongInfoLbl.Text = "Wystąpił nieoczekiwany błąd" + exception;
                // wysylaj maila
            }
            EmailOnDatabase(emailPerson);
        }
Example #3
0
        public void SetUnicqlyValue(string namePerson, string emailPerson, string passPerson,
                                    string confirmPass)
        {
            string     updateData = "Insert Into AlcPrsnTable" + " (namePerson,emailPerson,passPerson,confirmPass) Values(@namePerson,@emailPerson,@passPerson,@confirmPass)";
            SqlCommand cmd        = new SqlCommand();

            using (var con = new SqlConnection())
            {
                try
                {
                    con.ConnectionString = "Data Source=JAC-KOMPUTER\\SQLEXPRESS;Initial Catalog=AlcoPersonalDataSql;Integrated Security=True";
                    cmd.CommandText      = updateData;
                    con.Open();
                    ScanPerson scnPrs = new ScanPerson();
                    cmd.CommandText = "SELECT * FROM [AlcPrsnTable]";
                    cmd.Connection  = con;
                }
                catch (SqlException se)
                {
                    wrongInfoLbl.Text = "Błąd dostępu do Bazy Danych" + se.StackTrace;
                }
                SqlDataReader rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    if (rd[1].ToString() == NamePerson)
                    {
                        nameIsOnStorge = true;
                        con.Close();
                        break;
                    }
                    //   powtarzajacy sie kod
                    i = rd.GetInt32(0);
                    Session["imieUsera"] = i + 1;
                }
                rd.Close();
                if (nameIsOnStorge == true)
                {
                    con.Close();
                }
                if (nameIsOnStorge == false)
                {
                    cmd.CommandText = updateData;
                    Session["Nick"] = namePerson;
                    cmd.Parameters.AddWithValue("@namePerson", namePerson);
                    cmd.Parameters.AddWithValue("@emailPerson", emailPerson);
                    cmd.Parameters.AddWithValue("@passPerson", passPerson);
                    cmd.Parameters.AddWithValue("@confirmPass", confirmPass);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Example #4
0
        public void toSql(ScanPerson scPerson, ChartDetails chrd, Dictionary <TimeSpan, double> oo)
        {
            _imie = (int)Session["imieUsera"];
            string hours, maxProm;

            hours   = Convert.ToString(chrd.ten(oo) / 2 - 2);
            maxProm = Convert.ToString(chrd.tamten(oo));
            string weight     = Convert.ToString(scPerson.WeightValue);
            string minilitres = Convert.ToString(scPerson.MinilitresOfDrinkedAlcValue);
            string testDate   = dataTodayLbl.Text = DateTime.Now.ToString();

            WhichGender(scPerson);
            UpdateAlcoDataBase(weight, hours, minilitres, maxProm, testDate, _imie);
        }
        protected void countPromiles_Click(object sender, EventArgs e)
        {
            try
            {
                if (
                    !double.TryParse(genderRBtn.Text, out genderValueToReducaAlcoholPerHour) ||
                    !double.TryParse(weightPersonTbx.Text, out weightValue) || weightValue <= 0 || // && weightPersonTbx.MaxLength.Equals(1) ||
                    !double.TryParse(alcoholAmountsTbx.Text, out amountsOfDrinkedAlcValue) || amountsOfDrinkedAlcValue <= 0 ||
                    !int.TryParse(drinkStartDdl.Text, out drinkStartVal) || drinkStartVal <= 0 ||
                    !int.TryParse(drinkTimeTxb.Text, out drinkTimeValue) || drinkTimeValue <= 0 ||
                    !double.TryParse(alcoholAmountsTbx.Text, out amountsOfDrinkedAlcValue) || amountsOfDrinkedAlcValue <= 0 ||
                    !double.TryParse(alcoholVoltageTxb.Text, out alcoVoltageValToReducaAlcoholPerHour) || alcoVoltageValToReducaAlcoholPerHour <= 0 || alcoVoltageValToReducaAlcoholPerHour > 96)
                {
                    if (alcoVoltageValToReducaAlcoholPerHour > 96)
                    {
                        invalidDataLbl.Text           = "W naszej bazie nie istnieje alkohol trunek mocniejszy niż 96% alk. Wpisz innną wartość.";
                        alcoholVoltageTxb.BorderColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        invalidDataLbl.Text = "błąd podaj opdowiednia wartosc";
                    }
                }
                else
                {
                    if (genderValueToReducaAlcoholPerHour == 0)
                    {
                        genderValueToReducaAlcoholPerHour = 0.6;
                    }
                    else
                    {
                        genderValueToReducaAlcoholPerHour = 0.7;
                    }

                    alcoVoltageValToReducaAlcoholPerHour = alcoVoltageValToReducaAlcoholPerHour * 0.01;
                    double maxAlcoCOncentrationVal;
                    maxAlcoCOncentrationVal = CalculateAlcoVoltage(genderValueToReducaAlcoholPerHour, weightValue  //@
                                                                   , amountsOfDrinkedAlcValue, alcoVoltageValToReducaAlcoholPerHour);
                    ScanPerson scnPerson = new ScanPerson(genderValueToReducaAlcoholPerHour, weightValue
                                                          , amountsOfDrinkedAlcValue, alcoVoltageValToReducaAlcoholPerHour, drinkStartVal, drinkTimeValue, maxAlcoCOncentrationVal);
                    Dictionary <TimeSpan, double> DictionaryAlkInTime = new Dictionary <TimeSpan, double>();
                    Session["session"] = scnPerson;
                    Response.Redirect("AlcoRaportChart.aspx");
                }
            }
            catch (Exception ex)
            {
                invalidDataLbl.Text = ex.StackTrace;
            }
        }
Example #6
0
        public void toRaport(ScanPerson scPerson, ChartDetails chrd, Dictionary <TimeSpan,
                                                                                 double> oo, string nick)
        {
            rprtWeightLbl.Text  = Convert.ToString(scPerson.WeightValue);
            rprtAmountLbl.Text  = Convert.ToString(scPerson.MinilitresOfDrinkedAlcValue);
            rprtVoltageLbl.Text = Convert.ToString(scPerson.AlcoVoltageVal * 100);
            WhichGender(scPerson);
            rprtDrunkTimeLbl.Text = Convert.ToString(chrd.ten(oo) / 2 - 2);
            rprtDataLbl.Text      = dataTodayLbl.Text = DateTime.Now.ToString();

            if (Session["Nick"] != null)
            {
                rprtNameLbl.Text = nick;
            }
            Session["Nick"] = null;
        }
        public void userAccepted(bool userOk)
        {
            ScanPerson scPerson = new ScanPerson();

            if (userOk == false)
            {
                wrongNameEmailLogLbl.Text = "Niepoprawny login lub haslo";
            }
            else
            {
                AlcoRaportChart alcrptCha = new AlcoRaportChart();
                _rightUser = true;
                Session["correctLogin"] = _rightUser;
                Response.Redirect("USerPanelForm.aspx");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string     nicki     = (string)Session["Nick"];
         ScanPerson scnPerson = (ScanPerson)Session["session"];
         if (Session["correctLogin"] != null)
         {
             logInInfoLbl.Text = "WITAJ " + nicki + " !!!";
         }
         else
         if (Session["correctLogin"] != null)
         {
             logInInfoLbl.Text = "Zaloguj się";
         }
     }
     catch (Exception exception)
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('Wystąpił błąd podczas ładowania strony');", true);
     }
 }
        protected void enterUserBtn_Click(object sender, EventArgs e)
        {
            ScanPerson scnPerson = new ScanPerson();

            try
            {
                string nameUser  = nameUserTxb.Text;
                string passUser  = passUserTxb.Text;
                string emailUser = emailUserTxb.Text;
                Session["imie"] = nameUser;
                logUser(nameUser, emailUser, passUser);
                UserOnStaff(userAccepted);
                nameUserTxb.MaxLength.Equals(10);
                passUserTxb.MaxLength.Equals(10);
                emailUserTxb.MaxLength.Equals(10);
                Session["session"] = scnPerson;
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "error", "alert('Wystąpił błąd podczas ładowania strony');", true);
            }
        }
Example #10
0
 private string WhichGender(ScanPerson scnPrsn)
 {
     return(scnPrsn.GenderValue > 0.6 ?  rprtGenderLbl.Text = "mężczyzna"
        : rprtGenderLbl.Text = "kobieta");
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     ScanPerson scnPerson = (ScanPerson)Session["session"];
 }