public IActionResult Create([Bind("CheckDetailsId,QuantitySelected,CheckId,FurnitureId")] CheckDetails checkDetails)
 {
     if (ModelState.IsValid)
     {
         _checkdetailsrepository.Create(checkDetails);
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["CheckId"]     = new SelectList(_furnituresalerepository.GetFurnitureSalesInfo(), "CheckId", "CheckId", checkDetails.CheckId);
     ViewData["FurnitureId"] = new SelectList(_furnitureInStorageRepository.GetFurnitureInStorageInfo(), "FurnitureId", "FurnitureNameWithColor", checkDetails.FurnitureId);
     return(View(checkDetails));
 }
        public void Checking_EmailAdress_ReturnTrue()
        {
            //Arrange
            var checker = new CheckDetails();

            //Act
            var result = checker.CheckEmail("*****@*****.**");

            //Assert
            Assert.IsTrue(result);
        }
        [TestMethod]//what the test going to check? _ who is able to rich it? _ what it returns?
        public void CanInsertWrongValues_CheckOnlyNums_ReturnsFalse()
        {
            //Arrange
            var checker = new CheckDetails();

            // Act
            var result = checker.Check_onlyNums("5555aaa");

            // Assert
            Assert.IsFalse(result);
        }
        public IActionResult Create([Bind("CheckDetailsId,QuantitySelected,FurnitureId")] CheckDetails checkDetails)
        {
            if (ModelState.IsValid)
            {
                if (checkDetails.QuantitySelected > _checkDetailsRepository.CountOfFurniture(checkDetails))
                {
                    this.ModelState["QuantitySelected"].Errors.Clear();
                    this.ModelState["QuantitySelected"].Errors.Add("Кількість вибраного товару не може бути більша, ніж є наявна в магазині! Залишилось одиниць товару :" + _checkDetailsRepository.CountOfFurniture(checkDetails));
                    ViewData["FurnitureId"] = new SelectList(_furnitureRepository.GetFurnitureRelatedToShop(), "FurnitureId", "FurnitureNameWithColor", checkDetails.FurnitureId);
                    return(View(checkDetails));
                }
                _checkDetailsRepository.Create(checkDetails);
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["FurnitureId"] = new SelectList(_furnitureRepository.GetFurnitureRelatedToShop(), "FurnitureId", "FurnitureNameWithColor", checkDetails.FurnitureId);
            return(View(checkDetails));
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            check_funcs.CheckDetails check = new CheckDetails();

            if (check.CheckEmail(txtTo.Text) && (check.CheckEmail(txtCC.Text) || txtCC.Text == ""))
            {
                try
                {
                    this.timer1.Start();
                    login              = new NetworkCredential(txtUser.Text, txtPassword.Text);
                    client             = new SmtpClient(txtSmtp.Text);
                    client.Port        = Convert.ToInt32(txtPort.Text);
                    client.EnableSsl   = chkSSL.Checked;
                    client.Credentials = login;
                    msg = new MailMessage
                    {
                        From = new MailAddress(txtUser.Text + txtSmtp.Text.Replace("smtp.", "@"), "ScheduLuz", Encoding.UTF8)
                    };
                    msg.To.Add(new MailAddress(txtTo.Text));
                    if (!string.IsNullOrEmpty(txtCC.Text))
                    {
                        msg.To.Add(new MailAddress(txtCC.Text));
                    }
                    msg.Subject      = txtSubject.Text;
                    msg.Body         = txtMessage.Text;
                    msg.BodyEncoding = Encoding.UTF8;
                    msg.IsBodyHtml   = true;
                    msg.Priority     = MailPriority.Normal;
                    msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                    client.SendCompleted           += new SendCompletedEventHandler(SendCompletedCallBack);
                    string userstate = "Sending...";
                    client.SendAsync(msg, userstate);
                }
                catch
                {
                    this.timer1.Stop();
                    MessageBox.Show("Error Accured, please check your internet connection");
                }
            }
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string HobiesForReplacing = hobies_txt.Text;

            HobiesForReplacing = HobiesForReplacing.Replace("'", string.Empty);
            string FreeTextForReplacing = freetext_txt.Text;

            FreeTextForReplacing = FreeTextForReplacing.Replace("'", string.Empty);
            string AddressForReplace = address_txt.Text;

            AddressForReplace = AddressForReplace.Replace("'", string.Empty);
            string PhoneForReplace = phone_txt.Text;

            PhoneForReplace = PhoneForReplace.Replace("'", string.Empty);
            string EmailForReplace = Email_1st.Text;

            EmailForReplace = EmailForReplace.Replace("'", string.Empty);
            string PEmailForReplace = PEmail_txt.Text;

            PEmailForReplace = PEmailForReplace.Replace("'", string.Empty);
            string PasswordForReplace = pass_txt.Text;

            PasswordForReplace = PasswordForReplace.Replace("'", string.Empty);
            CheckDetails check = new CheckDetails();

            if (pass_txt.Text == userId)
            {
                MessageBox.Show("Your password is the same as before, please update it.");
            }
            else if (pass_txt.Text == "")
            {
                MessageBox.Show("Please update your password.");
            }
            else if (pass_txt.Text != confirm_pass_txt.Text)
            {
                MessageBox.Show("Passwords do not match.");
            }

            else if (!check.CheckEmail(Email_1st.Text))
            {
                MessageBox.Show("Email is not valid!");
            }
            else if (Email_1st.Text != Email_2nd.Text)
            {
                MessageBox.Show("Emails do not match.");
            }
            else if (phone_txt.Text == "")
            {
                MessageBox.Show("Please update your phone number.");
            }
            else if (!check.Check_onlyNums(phone_txt.Text) || phone_txt.Text.Length != 10)
            {
                MessageBox.Show("Invalid phone number.");
            }
            else if (!check.CheckEmail(PEmail_txt.Text) && log_in_page.permission == "student")
            {
                MessageBox.Show("Parent Email is not valid!");
            }
            else if (PEmail_txt.Text != confirm_PEmail_txt.Text)
            {
                MessageBox.Show("Parent Emails do not match.");
            }
            else if (PEmail_txt.Text == Email_1st.Text)
            {
                MessageBox.Show("Parent Email is the same as yours.");
            }
            else if (yearCB.SelectedIndex == -1 && log_in_page.permission == "student")
            {
                MessageBox.Show("Please fill year.");
            }
            else if (classCB.SelectedIndex == -1 && log_in_page.permission == "student")
            {
                MessageBox.Show("Please fill class.");
            }



            else
            {
                try
                {
                    dataBase      dataBase = new dataBase();
                    SqlConnection conn     = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd1 = new SqlCommand("UPDATE users SET phoneNumber ='" + PhoneForReplace + "' WHERE id ='" + userId + "'", conn);
                    cmd1.ExecuteNonQuery();

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd2 = new SqlCommand("UPDATE users SET Email ='" + EmailForReplace + "' WHERE id ='" + userId + "'", conn);
                    cmd2.ExecuteNonQuery();

                    if (log_in_page.permission == "student")
                    {
                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        SqlCommand cmd3 = new SqlCommand("UPDATE users SET ParentEmail ='" + PEmailForReplace + "' WHERE id ='" + userId + "'", conn);
                        cmd3.ExecuteNonQuery();


                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        SqlCommand cmd4 = new SqlCommand("UPDATE users SET grade ='" + yearCB.Items[yearCB.SelectedIndex].ToString() + "' WHERE id ='" + userId + "'", conn);
                        cmd4.ExecuteNonQuery();

                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        SqlCommand cmd5 = new SqlCommand("UPDATE users SET classNumber ='" + classCB.Items[classCB.SelectedIndex].ToString() + "' WHERE id ='" + userId + "'", conn);
                        cmd5.ExecuteNonQuery();
                    }

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd6 = new SqlCommand("UPDATE users SET address ='" + AddressForReplace + "' WHERE id ='" + userId + "'", conn);
                    cmd6.ExecuteNonQuery();

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd7 = new SqlCommand("UPDATE users SET birthDate ='" + birthdate_pckr.Text + "' WHERE id ='" + userId + "'", conn);
                    cmd7.ExecuteNonQuery();

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd8 = new SqlCommand("UPDATE users SET freeTxt ='" + FreeTextForReplacing + "' WHERE id ='" + userId + "'", conn);
                    cmd8.ExecuteNonQuery();


                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd9 = new SqlCommand("UPDATE users SET hobies ='" + HobiesForReplacing + "' WHERE id ='" + userId + "'", conn);
                    cmd9.ExecuteNonQuery();


                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd10 = new SqlCommand("UPDATE connection_details SET password ='******' WHERE id ='" + userId + "'", conn);
                    cmd10.ExecuteNonQuery();

                    /* adding the image - dont ask*/
                    if (imgLocation != "")
                    {
                        byte[]       images = null;
                        FileStream   stream = new FileStream(imgLocation, FileMode.Open, FileAccess.Read);
                        BinaryReader brs    = new BinaryReader(stream);
                        images = brs.ReadBytes((int)stream.Length);

                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        string sqlQuery = "UPDATE users SET picture =@images WHERE id ='" + userId + "'";
                        cmd = new SqlCommand(sqlQuery, conn);
                        cmd.Parameters.Add(new SqlParameter("@images", images));
                        int N = cmd.ExecuteNonQuery();
                    }

                    MessageBox.Show("Your Details has been updated." + userId);



                    if (per == "manager")
                    {
                        ManagerCalander managerCalander = new ManagerCalander();
                        managerCalander.Show();
                        Visible = false;
                    }
                    else if (per == "teacher")
                    {
                        TeacherCalander teacherCalander = new TeacherCalander();
                        teacherCalander.Show();
                        Visible = false;
                    }

                    else
                    {
                        StudentCalander frmCal = new StudentCalander();
                        frmCal.Show();
                        Visible = false;
                    }
                }
                catch
                {
                    MessageBox.Show("Problem detected. please contact your Scheduluz Guide for more information.");
                }
            }
        }