private void btnIncident_Click(object sender, RoutedEventArgs e)
        {
            BLClass blcProcessor = new BLClass();

            string driver      = ((Driver)cboDriver.SelectedItem).ToString();
            string truck       = ((Truck)cboTruck.SelectedItem).ToString();
            string location    = txtLocation.Text;
            string description = txtDescription.Text;

            try
            {
                int numberCreated = blcProcessor.ReportIncident(driver, truck, location, description, Convert.ToDateTime(dtIncidentDate.Text));

                if (numberCreated == 1)
                {
                    MessageBox.Show("Incident for:" + truck + " " + driver + "' was successfully added to the database");
                    txtLocation.Clear();
                    txtDescription.Clear();
                }
                else
                {
                    MessageBox.Show("Incident was not sucessfully saved to the database");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        public string Details()
        {
            string password, rePassword, userName;
            int    uniqueNum;

            Console.Write("enter userName");
            userName = Console.ReadLine();
            Console.Write("please enter your uniqueNumber for verification:");
            uniqueNum = Convert.ToInt32(Console.ReadLine());
            Console.Write("please enter your new password:"******"please enter your new Password again:");
            rePassword = Console.ReadLine();
            BLClass obj    = new BLClass();
            bool    result = obj.ForgotPasswordValidation(uniqueNum, userName, password, rePassword);

            if (result)
            {
                return("password has been changed successfully.");
            }
            else
            {
                return("password has not chnaged, try once again.");
            }
        }
Exemplo n.º 3
0
        public void DivideTest4()
        {
            BLClass B  = new BLClass();
            var     ex = Assert.ThrowsException <FormatException>(() => B.Divide("abc", "xyz"));

            Assert.AreEqual("only numbers", ex.Message);
        }
Exemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            BLClass B = new BLClass();

            try
            {
                txtresult.Text = (B.Divide(txtnum.Text, txtdenom.Text)).ToString();
            }
            catch (DivideByZeroException E)
            {
                Response.Write(E.Message);
            }
            catch (FormatException E)
            {
                Response.Write(E.Message);
            }


            //try
            //{
            //    txtresult.Text = (int.Parse(txtnum.Text) / int.Parse(txtdenom.Text)).ToString();
            //}
            //catch(DivideByZeroException e1)
            //{
            //    Response.Write(e1.Message);
            //}
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();
            _bl = new BLClass();

            DataContext = _bl.ViewModel;
        }
        public void validate()
        {
            bool   expected    = true;
            string testemail   = "*****@*****.**";
            bool   actualvalue = BLClass.validateEmail(testemail);

            Assert.AreEqual(expected, actualvalue);
        }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtFirstName.Text != string.Empty && txtLastName.Text != string.Empty && txtEmail.Text != string.Empty &&
                    txtPassword.Password != string.Empty && txtConfirm.Password != string.Empty)
                {
                    if (txtEmail.Text.EndsWith("@btc.com"))
                    {
                        if (txtPassword.Password == txtPassword.Password)
                        {
                            User user = new User();

                            user.Name      = txtFirstName.Text;
                            user.Surname   = txtLastName.Text;
                            user.Role      = cboRole.Text;
                            user.Password  = txtConfirm.Password;
                            user.UserEmail = txtEmail.Text;
                            BLClass blcProcessor = new BLClass();


                            if (blcProcessor.AddNewUser(user) == 1)
                            {
                                MessageBox.Show("User registered successfully.", "User Registered",
                                                MessageBoxButton.OK, MessageBoxImage.Information);
                                new windowRegisterUser().Show();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("User registration failed.", "User Not Registered",
                                                MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please make sure passwords match!", "Passwords mismatch.",
                                            MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("User must register with BTC email address.", "Invalid Email.",
                                        MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Please enter all fields!", "Inomplete Form.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Exemplo n.º 8
0
        public void AgeTest2()
        {
            BLClass b   = new BLClass();
            string  str = "04/11/2005";

            int age      = 0;
            var expected = Assert.ThrowsException <CustomException>(() => b.Age(str));

            Assert.AreEqual("Age should be less than 18 or greater than 60", expected.Message);
        }
Exemplo n.º 9
0
        public void DivideTest3()
        {
            //Arrange - Declare Actuals and Expected
            int     numerator   = 10;
            int     denominator = 0;
            BLClass B           = new BLClass();
            var     expected    = Assert.ThrowsException <DivideByZeroException>(() => B.Divide(numerator.ToString(), denominator.ToString()));

            Assert.AreEqual("Cannot divide by zero", expected.Message);
        }
Exemplo n.º 10
0
    public static void SomeExtensionMethod(this BLClass blclass, string methodname)
    {
        dynamic       users     = blclass.MYBLMethod();
        List <string> usernames = blclass.MYBLSecondMethod();

        foreach (string username in usernames)
        {
            var user = users[username];
            user.GetType().GetMethod(methodname).Invoke(user, null);
        }
    }
Exemplo n.º 11
0
        public void AgeTest1()
        {
            BLClass b   = new BLClass();
            string  str = "04/11/1998";

            int age      = 0;
            int expected = 21;

            age = b.Age(str);
            Assert.AreEqual(expected, age);
        }
        }//end method

        private void btnSumitDriver_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MainWindow.IsTextBoxValid(textFields))
                {
                    if (driver != null)
                    {
                        if (emergencyContact != null)
                        {
                            driver.PayrollFactor = Convert.ToDouble(txtPayrollFactor.Text);
                            license = new License(Convert.ToInt32(cboOldLicenseCode.Text), cboNewLicenseCode.Text,
                                                  Convert.ToDateTime(dpLicenseDOI.SelectedDate), Convert.ToDateTime(dpLicenseDOE.SelectedDate));

                            driver.DriverLicense = license;
                            driver.Availability  = cboAvailability.Text;

                            BLClass blcProcessor = new BLClass();

                            if (blcProcessor.AddNewDriver(driver) == 1)
                            {
                                MessageBox.Show(driver + " saved and submitted successfully", "Driver Saved", MessageBoxButton.OK, MessageBoxImage.Information);
                                new wndwDriverInfo().Show();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show(driver + " successfully saved to database.", "Driver saved", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please save Emergency Contact details before submitting", "Missing details", MessageBoxButton.OK, MessageBoxImage.Warning);
                            tabControl.SelectedIndex = 1;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please save Driver details before submitting", "Missing details", MessageBoxButton.OK, MessageBoxImage.Warning);
                        tabControl.SelectedIndex = 0;
                    }
                }
                else
                {
                    MessageBox.Show("Please fill in fields highlighted in orange", "Some Details Missing", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    tabControl.SelectedIndex = 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 13
0
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            BLClass b = new BLClass();

            try
            {
                txtage.Text = (b.Age(dtdob.Text)).ToString();
            }
            catch (CustomException E)
            {
                Response.Write(E.Message);
            }
        }
Exemplo n.º 14
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                BLClass BL = new BLClass();
                txtAge.Text = (BL.Age(DateTime.Parse(txtDob.Text))).ToString();
            }

            catch (CustomException E)
            {
                Response.Write(E.Message);
            }
            finally
            {
            }
        }
Exemplo n.º 15
0
        public void DivideTest2()
        {
            //Arrange - Declare Actuals and Expected
            int numerator   = 0;
            int denominator = 2;
            int actual      = 0;
            int expected    = 0;

            //Act - call the method and pass the actuals as parameters
            BLClass B = new BLClass();

            actual = B.Divide(numerator.ToString(), denominator.ToString());

            // Assert - check whether Actuals are matching with expected
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 16
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            BLClass blcProcessor = new BLClass();

            try
            {
                int numberDeleted = blcProcessor.DeleteTruck(selectedTruck.LicensePlateNumber);

                if (numberDeleted == 1)
                {
                    MessageBox.Show("Truck: '" + selectedTruck + "' was successfully deleted.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public void SendEmail()
        {
            bool expectedstatus = true;
            //arrange
            string email   = "*****@*****.**";
            string subject = "Customer Portal,Reset Your Password";
            string body    = "<b>Please find the Password Reset Link below. </b><br/>";
            //act
            bool actualstatus = BLClass.SendEmail(email, subject, body);

            //act



            //assert

            Assert.AreEqual(expectedstatus, actualstatus);
        }
Exemplo n.º 18
0
        private void GetAgents()
        {
            try
            {
                BLClass bl = new BLClass();

                _list = bl.GetCloestAgent();

                // used for extracting the data that we need to string format
                // var combined = string.Join(",", list.Select(c => c.Name.ToString() + " " + c.ToLat.ToString() + " " + c.ToLng.ToString()));

                dgvAgents.DataSource = _list;
            }
            catch (Exception ex)
            {
                MessageBox.Show("error: " + ex.ToString());
            }
        }
Exemplo n.º 19
0
        public string Details()
        {
            string userName, password;

            Console.Write("enter userName:"******"enter password");
            password = Console.ReadLine();
            BLClass obj    = new BLClass();
            bool    result = obj.LoginValidation(userName, password);

            if (result)
            {
                return("you have logined successfully");
            }
            else
            {
                return("your username or password is incorrect.please provide valid one.or you are trying to login firsttime please do register.");
            }
        }
Exemplo n.º 20
0
        public string Details()
        {
            string userName, password, firstName, lastName;
            int    uniqueNum;

            Console.Write("enter firstname:");
            firstName = Console.ReadLine();
            Console.Write("enter Lastname:");
            lastName = Console.ReadLine();
            Console.Write("enter uniquenumber for your identity:");
            uniqueNum = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter userName to Register:");
            userName = Console.ReadLine();
            Console.Write("enter password to Register:");
            password = Console.ReadLine();
            BLClass obj    = new BLClass();
            string  result = obj.RegisteringUser(userName, password, firstName, lastName, uniqueNum);

            return(result);
        }
Exemplo n.º 21
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            BLClass BL = new BLClass();

            try
            {
                txtResult.Text = (BL.Divide(txtNumerator.Text, txtDenominator.Text)).ToString();
            }
            catch (DivideByZeroException E)
            {
                Response.Write(E.Message);
            }
            catch (FormatException E)
            {
                Response.Write(E.Message);
            }
            finally
            {
            }
        }
Exemplo n.º 22
0
 private void btnUpdateTruck_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Truck   updateTruck  = GetTruckDetails();
         BLClass blcProcessor = new BLClass();
         if (blcProcessor.UpdateTruck(updateTruck) == 1)
         {
             MessageBox.Show(updateTruck + "successfully added to database.", "New Truck Added", MessageBoxButton.OK, MessageBoxImage.Information);
             new windowTruckInfo().ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Error adding " + updateTruck, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 23
0
        private void button1_Click(object sender, EventArgs e)
        {
            u = UserNameT.Text;
            p = Int32.Parse(PasswordT.Text);
            BLClass bl = new BLClass();
            //bl.uP = Int32.Parse(u);
            bool x = bl.Exist(u, p);

            if (x)
            {
                MessageBox.Show("ברוכים הבאים");
                bl.AddHistory(5, 1234);
                TestF t = new TestF(p);
                t.Show();
            }
            else
            {
                MessageBox.Show("הפרטים שגויים");
            }
            u = null;
            p = 0;
            UserNameT.Text = "";
            PasswordT.Text = "";
        }
 public LoginForm()
 {
     InitializeComponent();
     //object of business layer
     _bl = new BLClass();
 }
Exemplo n.º 25
0
 public MainActivity()
 {
     _bl = new BLClass();
 }