コード例 #1
0
        private void CostumerRegisterDataGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                try
                {
                    //currentDate = new DateTime();
                    //string todaysDate = currentDate.Date.ToString();

                    if ((costumerRegisterDataGrid1.SelectedItem as CostumerRegister).FirstName == firstNameTextBox.Text && (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).LastName == lastNameTextBox.Text && (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).TellNo == phoneNumberTextBox1.Text)
                    {
                        AlertOK decision = new AlertOK("You are Attempting to duplicate a record!", "Item already exists!");
                        decision.ShowDialog();
                        //MessageBox.Show("You are Attempting to duplicate and item!", "Item already exists!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                    else
                    {
                        CostumerRegister newMember = new CostumerRegister()
                        {
                            FirstName = firstNameTextBox.Text,
                            LastName  = lastNameTextBox.Text,
                            Gender    = genderComboBox.Text,
                            TellNo    = phoneNumberTextBox1.Text,

                            Occupation           = occupationTextBox1.Text,
                            NxtOfKinName         = nextOfKinName.Text,
                            NxtOfKinNumber       = nextOfKinPhone.Text,
                            NxtOfKinRelationship = nextOfKinRelation.Text,

                            DateRegistered = DateTime.Now.ToString(),
                            Address1       = address1TextBox.Text,
                            Address2       = address2TextBox.Text
                        };

                        test.CostumerRegisters.Add(newMember);
                        test.SaveChanges();
                        costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters.ToList();
                        RegPanel.IsEnabled = false;
                    }
                }
                catch (Exception)
                {
                    //AlertOK alerting = new AlertOK("Something went wrong", ex.Message);
                    //alerting.ShowDialog();
                    //MessageBox.Show(ex.Message);
                    RefreshDataGrid();
                }
            }

            //costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters.ToList();
            //RefreshDataGrid();
        }
コード例 #2
0
 private void RefreshDataGrid()
 {
     try
     {
         costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters.ToList();
     }
     catch (Exception ex)
     {
         AlertOK decision = new AlertOK("Something went wrong!", ex.Message);
         decision.ShowDialog();
         //MessageBox.Show(ex.Message);
     }
 }
コード例 #3
0
        //public string _FirstName { get; set; }

        //8\
        // public BindableCollection DatagridRegister { get; set; }
        private void dataGridBind()
        {
            try
            {
                costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters.ToList();
                dataGrid = costumerRegisterDataGrid1;
                //public var LoadedData = test.CostumerRegisters.ToList();

                // lovar item = test.CostumerRegisters;
                //DatagridRegister = item;
                //DataContext = DatagridRegister;
                //costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters;
            }
            catch (Exception ex)
            {
                AlertOK decision = new AlertOK("Something went wrong!", ex.Message);
                decision.ShowDialog();
                //MessageBox.Show(e.Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// LogIn button click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(UserNameBox.Text))
            {
                errorMsg = new AlertOK("Message", "Please enter your user name!");
                errorMsg.ShowDialog();

                //MessageBox.Show("Please enter your user name!", "Message", MessageBoxButton.OK, MessageBoxImage.Warning);
                UserNameBox.Focus();
                return;
            }
            try
            {
                using (HotelManagementSystemEntities test = new HotelManagementSystemEntities())
                {
                    var query = from o in test.LogIns where o.UserName == UserNameBox.Text && o.PassWord == PassWordBox.Password select o;
                    if (query.SingleOrDefault() != null)
                    {
                        MainWindow MainHome = new MainWindow();

                        this.Close();
                        //Application.Current.Shutdown();

                        MainHome.ShowDialog();
                        // this.LogInPage.Close();
                    }
                    else
                    {
                        errorMsg = new AlertOK("Message", "Your user-name or password is incorrect.");
                        errorMsg.ShowDialog();
                        // MessageBox.Show("Your user-name or password is incorrect.","Message",MessageBoxButton.OK,MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                errorMsg = new AlertOK("Message", ex.Message);
                errorMsg.ShowDialog();
                //MessageBox.Show(ex.Message,"Message",MessageBoxButton.OK,MessageBoxImage.Error);
            }
        }
コード例 #5
0
        public void setInitialValues()
        {
            try
            {
                var copyFirstName  = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).FirstName;
                var copyLastName   = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).LastName;
                var copyGender     = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).Gender;
                var copyTellNo     = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).TellNo;
                var copyOccupation = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).Occupation;
                var copyNOKName    = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).NxtOfKinName;
                var copyNOKNum     = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).NxtOfKinNumber;
                var copyNOKReltn   = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).NxtOfKinRelationship;
                //var copyRegDate = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).DateRegistered;
                var copyAddress1 = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).Address1;
                var copyAddress2 = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).Address2;
                var copyImage    = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).Picture;

                //var item = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).FirstName;
                //_FirstName = item;
                //DataContext = _FirstName;

                firstNameTextBox.Text    = copyFirstName;
                lastNameTextBox.Text     = copyLastName;
                genderComboBox.Text      = copyGender;
                phoneNumberTextBox1.Text = copyTellNo;
                occupationTextBox1.Text  = copyOccupation;
                nextOfKinName.Text       = copyNOKName;
                nextOfKinPhone.Text      = copyNOKNum;
                nextOfKinRelation.Text   = copyNOKReltn;

                //regDate.Text = copyRegDate;
                address1TextBox.Text = copyAddress1;
                address2TextBox.Text = copyAddress2;
            }
            catch (Exception ex)
            {
                AlertOK alerting = new AlertOK("Something went wrong!", ex.Message);
                alerting.ShowDialog();
                //MessageBox.Show(e.Message, "Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #6
0
        //private void NotifyTrasition()
        //{
        //    TrasitioningPupNotifySlide.OnApplyTemplate();
        //    NotifyCard.Margin = new Thickness(0, 0, 150, 0);
        //}

        /// <summary>
        /// Delete Selection on the Data Grid View
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtDelete_Click(object sender, RoutedEventArgs e)
        {
            YesNo getEnquireis = new YesNo("Confirm Action!", "Are you sure that you want to delete this record?");

            getEnquireis.ShowDialog();
            if (getEnquireis.ReturnedDecision())
            {
                try
                {
                    int Id           = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).ClientID;
                    var deleteMember = test.CostumerRegisters.Where(m => m.ClientID == Id).Single();
                    test.CostumerRegisters.Remove(deleteMember);
                    test.SaveChanges();
                    costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters.ToList();
                }
                catch (Exception ex)
                {
                    AlertOK alerting = new AlertOK("Something went wrong!", ex.Message);
                    alerting.ShowDialog();
                    //MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Update Values on the Data Grid View
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //currentDate = new DateTime();
                //string todaysDate = currentDate.ToString();

                var Id = (costumerRegisterDataGrid1.SelectedItem as CostumerRegister).ClientID;
                CostumerRegister updatMember = (from m in test.CostumerRegisters where m.ClientID == Id select m).Single();

                updatMember.FirstName = firstNameTextBox.Text;
                updatMember.LastName  = lastNameTextBox.Text;
                updatMember.Gender    = genderComboBox.Text;
                updatMember.TellNo    = phoneNumberTextBox1.Text;

                updatMember.Occupation           = occupationTextBox1.Text;
                updatMember.NxtOfKinName         = nextOfKinName.Text;
                updatMember.NxtOfKinNumber       = nextOfKinPhone.Text;
                updatMember.NxtOfKinRelationship = nextOfKinRelation.Text;

                //updatMember.DateRegistered = DateTime.Now.ToString();
                updatMember.Address1 = address1TextBox.Text;
                updatMember.Address2 = address2TextBox.Text;

                test.SaveChanges();
                costumerRegisterDataGrid1.ItemsSource = test.CostumerRegisters.ToList();

                //NotifyTrasition();
            }
            catch (Exception ex)
            {
                AlertOK alerting = new AlertOK("Something went wrong check your enteries again", ex.Message);
                alerting.ShowDialog();
                //MessageBox.Show(ex.Message, "Something went wrong! Check your Enteries again", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }