コード例 #1
0
        private string Recipt()
        {
            decimal total   = 0;
            string  message = $"==========================\n" +
                              $"Order for:\n" +
                              $"{_orderFor}\n" +
                              $"==========================\n" +
                              $"Items:\n";

            foreach (var od in _basket)
            {
                message += $"{od.Quantity}x [{od.ProductId}] {CRUDManager.GetProduct(od.ProductId).ProductName} @£{od.UnitPrice}\n";
                total   += od.Quantity * od.UnitPrice * (decimal)(1 - od.Discount);
            }
            message += $"==========================\n" +
                       $"Discounts:\n";
            foreach (var od in _basket)
            {
                if (od.Discount != 0)
                {
                    message += $"[{od.ProductId}] {CRUDManager.GetProduct(od.ProductId).ProductName}: £{-1 * od.UnitPrice * od.Quantity * (decimal)od.Discount}\n";
                }
            }
            message += $"==========================\n" +
                       $"Total:\n" +
                       $"£{Math.Round(total,2)}\n" +
                       $"==========================\n";
            return(message);
        }
コード例 #2
0
        private void LikePost_Clicked(object sender, RoutedEventArgs e)
        {
            CRUDManager cm = new CRUDManager();

            cm.likePost(post.PostId);
            postsLikes.Text = (post.Likes + 1).ToString();
        }
コード例 #3
0
 public void BeAbleToBeConstructed()
 {
     //Arrange and Act
     _sut = new CRUDManager(null);
     //Assert
     Assert.That(_sut, Is.InstanceOf <CRUDManager>());
 }
コード例 #4
0
 public REFSuggestion(DataContext dataContext)
 {
     _dataContext       = dataContext;
     _models            = dataContext.Suggestion;
     _voteModels        = dataContext.Votes;
     _CRUDManagerTenant = new CRUDManager <Tenants, int>(dataContext, dataContext.Tenant);
 }
コード例 #5
0
 public GPPatientView(CRUDManager cRUDManager)
 {
     InitializeComponent();
     _crudManager = cRUDManager;
     PopulateListBox();
     TextDOB.SelectedDate = null;
 }
コード例 #6
0
        private void ListBoxOrders_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var listbox = (ListBox)sender;
            var order   = (Order)listbox.SelectedItem;

            if (order == null)
            {
                return;
            }

            _selectedOrder = order;
            var orderDetails        = CRUDManager.RetrieveOrderDetailsList(order.OrderId);
            var scrollViewerContent = "";

            orderDetails.ForEach(x => scrollViewerContent += $"{x.Quantity}x [{x.ProductId}] {CRUDManager.GetProduct(x.ProductId).ProductName} @£{Math.Round(x.UnitPrice * (decimal)(1 - x.Discount),2)}\n");

            TextBoxOrderId.Text = order.OrderId.ToString();
            DatePickerOrderDate.SelectedDate = order.OrderDate;
            TextBoxTotalCost.Text            = Math.Round(CRUDManager.RetrieveOrderTotalCost(order.OrderId), 2).ToString();
            ScrollViewerItemList.Content     = scrollViewerContent;

            if (order.ShippedDate == null || order.ShippedDate > DateTime.Now)
            {
                LabelShippedIndicator.Background = Brushes.Red;
            }
            else
            {
                LabelShippedIndicator.Background = Brushes.Green;
            }
        }
コード例 #7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CRUDManager cm = new CRUDManager();
            //Register function
            string username = TextRegisterUsername.Text;
            string email    = TextRegisterEmail.Text;
            string password = TextRegisterPassword.Text;

            if (username == "")
            {
                TextRegisterUsername.Text = "Please enter a username";
                return;
            }
            if (email == "")
            {
                TextRegisterEmail.Text = "Please enter a email";
                return;
            }
            if (password == "")
            {
                TextRegisterPassword.Text = "Please enter a password";
                return;
            }

            Tuple <string, bool> response = cm.createUser(username, email, password, password);

            if (response.Item2 == false)
            {
                TextRegisterUsername.Text = response.Item1;
            }
            if (response.Item2 == true)
            {
                _mainFrame.Navigate(new LoginPage());
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: Sundy25/MySQLManager
        static void Main(string[] args)
        {
            ConnectionCredentials credentials = new ConnectionCredentials
            {
                Server   = "www.muhandjumah.com",
                Database = "muhand5_ls_static",
                Username = "******",
                Password = "******"
            };

            CRUDManager manager = new CRUDManager(credentials);

            manager.ConnectionOpenedSuccessfully += Manager_ConnectionOpenedSuccessfully;;
            manager.ConnectionFailedToOpen       += Manager_ConnectionFailedToOpen;;
            manager.ConnectionClosedSuccessfully += Manager_ConnectionClosedSuccessfully;
            manager.ConnectionFailedToClose      += Manager_ConnectionFailedToClose;
            manager.CreatedSuccessfully          += Manager_CreatedSuccessfully;
            manager.FailedToCreate += Manager_FailedToCreate;

            Console.WriteLine("Name: ");
            string name = Console.ReadLine();

            Console.WriteLine("Age: ");
            int age = Convert.ToInt32(Console.ReadLine());

            Columns columns = new Columns("name", "age");
            Values  values  = new Values(name, age.ToString());

            manager.Create("info", columns, values);


            Console.WriteLine("Pres any key to continue...");
            Console.ReadKey();
        }
コード例 #9
0
        public void LoadProducts()
        {
            var productsList = CRUDManager.RetrieveAllProducts();

            ListBoxProducts.ItemsSource = productsList;
            ComboBoxProduct.ItemsSource = productsList;
        }
コード例 #10
0
        private void PostComment_Clicked(object sender, RoutedEventArgs e)
        {
            CRUDManager cm = new CRUDManager();

            cm.createComment(post.PostId, PostComment.Text);
            ListComments.ItemsSource = cm.getPostComments(post.PostId);
        }
コード例 #11
0
        static void Main(string[] args)
        {
            ConnectionCredentials credentials = new ConnectionCredentials
            {
                Server   = "127.0.0.1",
                Database = "mysqlmanager",
                Username = "******",
                Password = ""
            };

            CRUDManager manager = new CRUDManager(credentials);

            manager.ConnectionOpenedSuccessfully += Manager_ConnectionOpenedSuccessfully;
            manager.ConnectionFailedToOpen       += Manager_ConnectionFailedToOpen;
            manager.ConnectionClosedSuccessfully += Manager_ConnectionClosedSuccessfully;
            manager.ConnectionFailedToClose      += Manager_ConnectionFailedToClose;
            manager.DeletedSuccessfully          += Manager_DeletedSuccessfully;
            manager.FailedToDelete += Manager_FailedToDelete;

            Console.WriteLine("Condition Field: ");
            string condName = Console.ReadLine();

            Console.WriteLine("Condition Value: ");
            string condVal = Console.ReadLine();

            Field[] condition =
            {
                new Field(condName, condVal)
            };

            manager.Delete("info", condition);

            Console.WriteLine("Pres any key to continue...");
            Console.ReadKey();
        }
コード例 #12
0
        public AllPostsPage()
        {
            InitializeComponent();
            CRUDManager cm = new CRUDManager();

            ListAllPosts.ItemsSource = cm.getAllPosts();
        }
コード例 #13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CRUDManager cm       = new CRUDManager();
            string      username = TextLoginUsername.Text;
            string      password = TextLoginPassword.Text;

            if (username == "")
            {
                TextLoginUsername.Text = "Please enter a username";
                return;
            }
            if (password == "")
            {
                TextLoginPassword.Text = "Please enter a password";
                return;
            }

            Tuple <string, bool> response = cm.loginUser(username, password);

            if (response.Item2 == false)
            {
                TextLoginUsername.Text = response.Item1;
            }

            if (response.Item2 == true)
            {
                _mainFrame.Navigate(new Homepage());
            }
        }
コード例 #14
0
 public MakeOrder(Customer customer)
 {
     InitializeComponent();
     _orderFor                   = customer;
     _basket                     = new List <OrderDetail>();
     LabelOrderFor.Content       = $"Order For: [{customer.CustomerId}] {customer.ContactName}";
     ListBoxProducts.ItemsSource = CRUDManager.RetrieveAllProducts();
 }
コード例 #15
0
        private void UpdateGrid()
        {
            CRUDManager crudManager = new CRUDManager();

            Products = crudManager.LoadRecords <Product>(DatabaseStrings.ProductTable);
            DatagridView.DataSource = null;
            DatagridView.DataSource = Products;
        }
コード例 #16
0
        public void LoadCustomers()
        {
            var customerList = CRUDManager.RetrieveAllCustomers();

            ListBoxCustomers.ItemsSource          = customerList;
            ComboBoxCustomers.ItemsSource         = customerList;
            ComboBoxMakeOrderCustomer.ItemsSource = customerList;
        }
コード例 #17
0
        public void BeAbleToBeConstructeUsingMoq()
        {
            //Construct a mock instance of Type IRiderAccountService
            var mockRiderAccountService = new Mock <IRiderAccountService>();

            _sut = new CRUDManager(mockRiderAccountService.Object);

            Assert.That(_sut, Is.InstanceOf <CRUDManager>());
        }
        private void UpdateBlog_Clicked(object sender, RoutedEventArgs e)
        {
            string blogname = TextBlogName.Text;
            string blogdesc = TextBlogDescription.Text;

            CRUDManager cm = new CRUDManager();

            cm.updateBlog(blog.BlogId, blogname, blogdesc);
        }
コード例 #19
0
        public void RiderDeleteMethod_IsNotCalled_WhenInvokingCRUDManagerCreateMethod()
        {
            var mockRiderAccountService = new Mock <IRiderAccountService>();

            _sut = new CRUDManager(mockRiderAccountService.Object);
            //Act (invoke mock)
            _sut.CreateRiderAccount("*****@*****.**", "password", "Nishant", "Mandal", Convert.ToDateTime("12/01/1989"), "English", "None");
            mockRiderAccountService.Verify(x => x.DeleteRiderAccount(It.IsAny <int>()), Times.Never);
        }
コード例 #20
0
ファイル: Moq.cs プロジェクト: Breesha/Eng71
        public void CustomerDeleteMethod_IsNotCalled_WhenInvokingCRUDManagerCreateMethod()
        {
            var mockCustomerService = new Mock <ICustomerService>();

            _sut = new CRUDManager(mockCustomerService.Object);
            //Act (invoke mock)
            _sut.CreateCustomer("MANDA", "Nish Mandal", "Spart Global");
            mockCustomerService.Verify(x => x.DeleteCustomer(It.IsAny <string>()), Times.Never);
        }
コード例 #21
0
ファイル: Moq.cs プロジェクト: Breesha/Eng71
        public void GetCustomerInCRUDManager_CallsTheCorrectMethodWithCorrectParameters_OfICustomerServiceLOOSE()
        {
            //Construct a mock instance of Type ICutomerService
            var mockCustomerService = new Mock <ICustomerService>(MockBehavior.Loose);

            mockCustomerService.Setup(c => c.GetCustomerById("MANDA")).Returns(It.IsAny <Customers>);
            _sut = new CRUDManager(mockCustomerService.Object);
            _sut.RetrieveSelectedCustomer("FRENC");
        }
コード例 #22
0
        public Homepage()
        {
            InitializeComponent();
            CRUDManager cm = new CRUDManager();

            ListMyBlogs.ItemsSource = cm.getUserBlog(CurrentUser.Id);
            ListMyPosts.ItemsSource = cm.getUserPosts(CurrentUser.Id);
            LabelUsername.Content   = CurrentUser.Username.ToUpper();
        }
コード例 #23
0
 public PatientRecordView(CRUDManager cRUDManager)
 {
     _crudManager = cRUDManager;
     InitializeComponent();
     PopulateAllergyListBox();
     PopulateVaccineListBox();
     PopulateMedicineListBox();
     PopulateConcernListBox();
 }
コード例 #24
0
 public void insertAnything()
 {
     CRUDManager cm     = new CRUDManager();
     int         result = cm.InsertOrUpdate <CommonCodeDetail>(new CommonCodeDetail
     {
         ID   = null,
         Name = "test",
     });
 }
        public BlogPostViewer(Blog blog)
        {
            InitializeComponent();
            CRUDManager cm = new CRUDManager();

            ListBlogPosts.ItemsSource = cm.getBlogPosts(blog.BlogId);
            this.blog                = blog;
            TextBlogName.Text        = blog.Title;
            TextBlogDescription.Text = blog.Description;
        }
        private void CreatePost_Clicked(object sender, RoutedEventArgs e)
        {
            string postname    = TextPostName.Text;
            string postcontent = TextPostContent.Text;

            CRUDManager cm = new CRUDManager();

            cm.createPost(blog.BlogId, postname, postcontent);
            ListBlogPosts.ItemsSource = cm.getBlogPosts(blog.BlogId);
        }
コード例 #27
0
ファイル: Moq.cs プロジェクト: Breesha/Eng71
        public void DeleteCustomerMethod_IsCalled_WithCorrectParameters()
        {
            var mockCustomerService = new Mock <ICustomerService>();

            _sut = new CRUDManager(mockCustomerService.Object);
            //Act (invoke mock)
            _sut.DeleteCustomer("MANDA");
            mockCustomerService.Verify(x => x.DeleteCustomer("MANDA"));
            mockCustomerService.Verify(x => x.DeleteCustomer("MANDA"), Times.Exactly(1));
        }
コード例 #28
0
        public void DeleteRiderMethod_IsCalled_WithCorrectParameters()
        {
            var mockRiderAccountService = new Mock <IRiderAccountService>();

            _sut = new CRUDManager(mockRiderAccountService.Object);
            //Act (invoke mock)
            _sut.DeleteRider(10);
            mockRiderAccountService.Verify(x => x.DeleteRiderAccount(10));
            mockRiderAccountService.Verify(x => x.DeleteRiderAccount(10), Times.Exactly(1));
        }
コード例 #29
0
        public void GetRiderAccountInCRUDManager_CallsTheCorrectMethodWithCorrectParameters_OfIRiderAccountServiceLOOSE()
        {
            //Construct a mock instance of Type IRiderAccountService
            var mockRiderAccountService = new Mock <IRiderAccountService>(MockBehavior.Loose);

            mockRiderAccountService.Setup(c => c.GetRiderAccountByID(10)).Returns(It.IsAny <RiderAccount>);

            _sut = new CRUDManager(mockRiderAccountService.Object);
            _sut.RetrieveSelectedRiderAccount(11);
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: Sundy25/MySQLManager
        static void Main(string[] args)
        {
            ConnectionCredentials credentials = new ConnectionCredentials
            {
                Server   = "127.0.0.1",
                Database = "mysqlmanager",
                Username = "******",
                Password = ""
            };

            CRUDManager manager = new CRUDManager(credentials);

            manager.ConnectionOpenedSuccessfully    += Manager_ConnectionOpenedSuccessfully;;
            manager.ConnectionFailedToOpen          += Manager_ConnectionFailedToOpen;;
            manager.ConnectionClosedSuccessfully    += Manager_ConnectionClosedSuccessfully;
            manager.ConnectionFailedToClose         += Manager_ConnectionFailedToClose;
            manager.CustomQueryExecutedSuccessfully += Manager_CustomQueryExecutedSuccessfully;
            manager.FailedToExecuteCustomQuery      += Manager_FailedToExecuteCustomQuery;


            Console.WriteLine();
            Console.WriteLine("ExecutionOptions.ExecuteReader");
            Console.WriteLine("--------------------------------");
            Console.WriteLine();

            string query = "SELECT * FROM info WHERE name='Muhand Jumah 3' AND age = '22'";
            List <List <string> > res = new List <List <string> >();

            manager.ExecuteCustomQuery(query, ExecutionOptions.ExecuteReader, out res);

            Console.WriteLine();

            foreach (var row in res)
            {
                foreach (var col in row)
                {
                    Console.Write(col + ", ");
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine("ExecutionOptions.ExecuteNonQuery");
            Console.WriteLine("--------------------------------");
            Console.WriteLine();

            string query2 = "INSERT INTO info (name,age) VALUES ('Muhand Jumah 3','22')";

            manager.ExecuteCustomQuery(query2, ExecutionOptions.ExecuteNonQuery);


            Console.WriteLine("Pres any key to continue...");
            Console.ReadKey();
        }
コード例 #31
0
        private void SaveAnswerBtnClicked(object sender, RoutedEventArgs e)
        {
            AdminWindowVM aw = (AdminWindowVM)this.DataContext;

            if(CurrentQuestion.Equals(Guid.Empty)) return;
            QuestionContentRTB.SelectAll();

            #region Validate Fields

            if (QuestionContentRTB.Selection.Text == "")
            {
                MessageBox.Show("Question is not defined");
                return;
            }
            if(AnswersDictionary.Count ==0)
            {
                MessageBox.Show("No answers added");
                return;
            }
            if (AnswersDictionary.Count != 0)
            {
                bool IsanswrsEmpty = true;
                for (int i = 0; i < AnswersCount; i++)
                {
                    if (AnswersDictionary.ContainsKey(i))
                    {
                        try
                        {
                            RichTextBox tb = (RichTextBox)AnswersStackPannel.FindName("AnswerRTB" + i.ToString());
                            tb.SelectAll();
                            if (tb.Selection.Text.Trim() != "")
                            {
                                IsanswrsEmpty = false;
                            }
                        }
                        catch { }
                    }
                }
                if (IsanswrsEmpty)
                {
                    MessageBox.Show("No answers added");
                    return;
                }
            }
            if (AnswersDictionary.Count != 0)
            {
                bool IsAChecked = false;
                for (int i = 0; i < AnswersCount; i++)
                {
                    if (AnswersDictionary.ContainsKey(i))
                    {
                        try
                        {
                            RadioButton rb = (RadioButton)AnswersStackPannel.FindName("AnswerRadioButton" + i.ToString());
                            if ((bool)rb.IsChecked)
                            {
                                IsAChecked = true;
                            }
                        }
                        catch { }
                    }
                }
                if (!IsAChecked)
                {
                    MessageBox.Show("Select Correct Answer");
                    return;
                }
            }
            #endregion

            QuestionModel Question = new QuestionModel();
            Question.Answers = new List<AnswersModel>();
            Question.Images = new List<ImageModel>();
            Question.QID = CurrentQuestion;
            Question.QBody = QuestionContentRTB.Selection.Text.Trim();
            Question.HasMultipleAnswers = false;

            if (ImageDictionary.Count != 0) Question.HasImages = true;

            for (int i = 0; i < AnswersCount; i++)
            {
                if (AnswersDictionary.ContainsKey(i))
                {
                    RichTextBox tb = (RichTextBox)AnswersStackPannel.FindName("AnswerRTB" + i.ToString());
                    tb.SelectAll();
                    if (tb.Selection.Text.Trim() != "")
                    {
                        AnswersModel answer = new AnswersModel();
                        answer.QID = Question.QID;
                        answer.AID = Guid.NewGuid();
                        answer.AnswerBody = tb.Selection.Text.Trim();
                        RadioButton rb = (RadioButton)AnswersStackPannel.FindName("AnswerRadioButton" + i.ToString());
                        answer.IsCorrectAnswer = (bool)rb.IsChecked;
                        Question.Answers.Add(answer);
                    }
                }
            }
            for (int i = 0; i < ImagesCount; i++)
            {
                if (ImageDictionary.ContainsKey(i))
                {
                    try
                    {
                        byte[] picbyte = null;
                        Image img = (Image)ImagesStackPanel.FindName("QImage" + i.ToString());
                        BitmapImage bimg = (BitmapImage)img.Source;
                        if (bimg.UriSource == null)
                        {
                            picbyte = ((MemoryStream)bimg.StreamSource).ToArray();
                        }
                        else
                        {
                            FileStream fs = new FileStream(bimg.UriSource.LocalPath.ToString(), FileMode.Open, FileAccess.Read);
                            picbyte = new byte[fs.Length];
                            fs.Read(picbyte, 0, System.Convert.ToInt32(fs.Length));
                            fs.Close();
                        }
                        ImageModel imodel = new ImageModel();
                        imodel.QID = Question.QID;
                        imodel.ImageID = Guid.NewGuid();
                        imodel.Image = picbyte;

                        Question.Images.Add(imodel);
                    }
                    catch { }
                }
            }

            CRUDManager dm = new CRUDManager();
            if (dm.UpdateQuestion(Question))
            {
                aw.QList[ComboboxIndex] = ConvertModelToVM(Question);
                QuestionEditSelectCombobox.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("Question Save Failed");
                return;
            }
        }
コード例 #32
0
 private void ClearAnswerBtnClicked(object sender, RoutedEventArgs e)
 {
     CRUDManager cm = new CRUDManager();
     if (CurrentQuestion != Guid.Empty)
     {
         if (cm.DeleteGivenQuestion(CurrentQuestion))
         {
             AdminWindowVM aw = (AdminWindowVM)this.DataContext;
             aw.QList.RemoveAt(ComboboxIndex);
             QuestionEditSelectCombobox.SelectedIndex = 0;
         }
     }
 }