Пример #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();
     }
 }
Пример #2
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();
            }
        }
Пример #3
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();
     }
 }
Пример #4
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();
     }
 }
Пример #5
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();
     }
 }
Пример #6
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();
     }
 }
Пример #7
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();
     }
 }
Пример #8
0
        private void ExportToExell_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            saveFileDialog.Title            = "Export To Excell";
            saveFileDialog.FileName         = "";
            saveFileDialog.Filter           = "Excel Files|*.xlsx;*.xls;*.xlsm";
            if (saveFileDialog.ShowDialog() == true)
            {
                Excel.Application xlApp;
                Excel.Workbook    xlWorkBook;
                Excel.Worksheet   xlWorkSheet;
                object            misValue = System.Reflection.Missing.Value;
                xlApp                   = new Excel.Application();
                xlWorkBook              = xlApp.Workbooks.Add(misValue);
                xlWorkSheet             = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                xlWorkSheet.Cells[1, 1] = "Id";
                xlWorkSheet.Cells[1, 2] = "Material Id";
                xlWorkSheet.Cells[1, 3] = "Material Name";
                xlWorkSheet.Cells[1, 4] = "Material Type";
                xlWorkSheet.Cells[1, 5] = "Maintenance Cost";
                xlWorkSheet.Cells[1, 6] = "Maintenance Date";
                for (int i = 0; i <= MaintenanceDataGrid.Items.Count - 1; i++)
                {
                    xlWorkSheet.Cells[i + 2, 1] = ((MaintenanceDBContext)MaintenanceDataGrid.Items[i]).Id;
                    xlWorkSheet.Cells[i + 2, 2] = ((MaintenanceDBContext)MaintenanceDataGrid.Items[i]).MaterialId;
                    xlWorkSheet.Cells[i + 2, 3] = ((MaintenanceDBContext)MaintenanceDataGrid.Items[i]).MaterialName;
                    xlWorkSheet.Cells[i + 2, 4] = ((MaintenanceDBContext)MaintenanceDataGrid.Items[i]).MaterialType;
                    xlWorkSheet.Cells[i + 2, 5] = ((MaintenanceDBContext)MaintenanceDataGrid.Items[i]).MaintenanceCost;
                    xlWorkSheet.Cells[i + 2, 6] = ((MaintenanceDBContext)MaintenanceDataGrid.Items[i]).MaintenanceDate;
                }
                string path = saveFileDialog.FileName;
                xlWorkBook.SaveCopyAs(path);
                xlWorkBook.Saved = true;
                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();
                WindowSuccess success = new WindowSuccess();
                success.SetContent("Exported Successully");
                success.Show();
            }
        }