Ejemplo n.º 1
0
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     if ((imageName != "" || imgByteArrDB != null) && IsValidEmail(EmailAddress.Text.ToString()))
     {
         foreach (UserDBContext user in users)
         {
             if (user.Email.Equals(EmailAddress.Text.ToString()))
             {
                 UserDBContext.IntitalizeDB();
                 UserDBContext.Delete(EmailAddress.Text.ToString());
                 InitializeDataGrid();
                 ClearAll();
                 WindowSuccess success = new WindowSuccess();
                 success.SetContent("Account Deleted Succefully");
                 success.Show();
             }
         }
     }
     else
     {
         WindowError error = new WindowError();
         error.SetContent("Account Is Not Selected");
         error.Show();
     }
 }
Ejemplo n.º 2
0
        public bool ValidateAll()
        {
            if (EAErr.IsVisible || PErr.IsVisible || MIErr.IsVisible || PPErr.IsVisible)
            {
                return(false);
            }
            else if (string.IsNullOrEmpty(EmailAddress.Text.ToString().Trim()) || string.IsNullOrEmpty(Password.Password.ToString().Trim()) || string.IsNullOrEmpty(MemberId.Text.ToString().Trim()) || string.IsNullOrEmpty(imgByteArrDB.ToString()))
            {
                return(false);
            }
            List <MemberDBContext> members = MemberDBContext.GetMembers();
            bool isTrue = true;

            foreach (MemberDBContext member in members)
            {
                if (member.Id == int.Parse(MemberId.Text.ToString()))
                {
                    isTrue = false;
                }
            }
            if (isTrue)
            {
                WindowError error = new WindowError();
                error.SetContent("Member Id Doesn't Exist");
                error.Show();
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            if ((imageName != "" && ValidateAll()) || (imgByteArrDB != null && ValidateAll()))
            {
                foreach (UserDBContext user in users)
                {
                    if (user.Email.Equals(EmailAddress.Text.ToString()))
                    {
                        MemberDBContext.IntitalizeDB();
                        List <MemberDBContext> members = MemberDBContext.GetMembers();
                        var member = members
                                     .SingleOrDefault(m => m.Id == int.Parse(MemberId.Text.ToString()));
                        if (member == null)
                        {
                            WindowError error = new WindowError();
                            error.SetContent("Unknown Member Id");
                            error.Show();
                            return;
                        }
                        try {
                            FileStream fs         = new FileStream(imageName, FileMode.Open, FileAccess.Read);
                            byte[]     imgByteArr = new byte[fs.Length];

                            fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
                            fs.Close();
                            UserDBContext.IntitalizeDB();
                            UserDBContext.Update(EmailAddress.Text.ToString(), Password.Password.ToString(), UserRole.Text.ToString(), imgByteArr, int.Parse(MemberId.Text.ToString()));
                            InitializeDataGrid();
                            ClearAll();
                            WindowSuccess success = new WindowSuccess();
                            success.SetContent("Account Updated Succefully");
                            success.Show();
                        }
                        catch (Exception) {
                            UserDBContext.IntitalizeDB();
                            UserDBContext.Update(EmailAddress.Text.ToString(), Password.Password.ToString(), UserRole.Text.ToString(), imgByteArrDB, int.Parse(MemberId.Text.ToString()));
                            InitializeDataGrid();
                            ClearAll();
                            WindowSuccess success = new WindowSuccess();
                            success.SetContent("Account Updated Succefully");
                            success.Show();
                        }
                    }
                }
            }
            else
            {
                WindowError error = new WindowError();
                error.SetContent("Empty Filed Or Invalid Input");
                error.Show();
            }
        }
Ejemplo n.º 4
0
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateAll())
     {
         EventDBContext.IntitalizeDB();
         EventDBContext.Inserst(EventDate.Text.ToString(), EventAdress.Text.ToString(), EventDetail.Text.ToString().Trim());
         InitializeDataGrid();
         ClearAll();
         WindowSuccess success = new WindowSuccess();
         success.SetContent("Event Saved Succefully");
         success.Show();
     }
     else
     {
         WindowError error = new WindowError();
         error.SetContent("Empty Filed Or Invalid Input");
         error.Show();
     }
 }
Ejemplo n.º 5
0
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     if (eventId != 0)
     {
         EventDBContext.IntitalizeDB();
         EventDBContext.Delete(eventId);
         InitializeDataGrid();
         ClearAll();
         WindowSuccess success = new WindowSuccess();
         success.SetContent("Event Deleted Succefully");
         success.Show();
     }
     else
     {
         WindowError error = new WindowError();
         error.SetContent("Event Is Not Selected");
         error.Show();
     }
 }
Ejemplo n.º 6
0
 private void UpdateButton_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateAll() && eventId != 0)
     {
         EventDBContext.IntitalizeDB();
         EventDBContext.Update(eventId, EventDate.Text.ToString(), EventAdress.Text.ToString(), EventDetail.Text.ToString().Trim());
         InitializeDataGrid();
         ClearAll();
         WindowSuccess success = new WindowSuccess();
         success.SetContent("Event Updated Succefully");
         success.Show();
     }
     else
     {
         WindowError error = new WindowError();
         error.SetContent("Event Is Not Selected");
         error.Show();
     }
 }
Ejemplo n.º 7
0
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateAll())
     {
         MaintenanceDBContext.IntitalizeDB();
         MaintenanceDBContext.Inserst(int.Parse(MaterialId.Text.ToString()), MaterialName.Text.ToString(), MaterialType.Text.ToString(), int.Parse(MaintenanceCost.Text), MaintenanceDate.Text.ToString());
         InitializeDataGrid();
         ClearAll();
         WindowSuccess success = new WindowSuccess();
         success.SetContent("Maintenance Saved Succefully");
         success.Show();
     }
     else
     {
         WindowError error = new WindowError();
         error.SetContent("Empty Filed Or Invalid Input");
         error.Show();
     }
 }
Ejemplo n.º 8
0
 private void UpdateButton_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateAll() && maintenenceId != 0)
     {
         MaintenanceDBContext.IntitalizeDB();
         MaintenanceDBContext.Update(maintenenceId, int.Parse(MaterialId.Text.ToString()), MaterialName.Text.ToString(), MaterialType.Text.ToString(), int.Parse(MaintenanceCost.Text.ToString()), MaintenanceDate.Text.ToString());
         InitializeDataGrid();
         ClearAll();
         WindowSuccess success = new WindowSuccess();
         success.SetContent("Maintenance Updated Succefully");
         success.Show();
     }
     else
     {
         WindowError error = new WindowError();
         error.SetContent("Maintenance Is Not Selected");
         error.Show();
     }
 }