Ejemplo n.º 1
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.º 2
0
        private void InitializeFacility()
        {
            RequestDBContext.IntitalizeDB();
            List <RequestDBContext> requests = RequestDBContext.GetRequests();

            foreach (RequestDBContext request in requests)
            {
                MemberDBContext.IntitalizeDB();
                MemberDBContext member   = MemberDBContext.GetMember(request.MemberId);
                string          fullName = string.Format($"{member.FirstName} {member.MiddleName}");
                FacilityPannel.Children.Add(new UserControlSingleFacility(fullName, request.PhoneNumber, request.Date, request.Subject, request.Body));
            }
        }