private void Application_Startup(object sender, StartupEventArgs e)
        {
            listOfPersons  = Mystorage.ReadXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml");
            listOfServices = Mystorage.ReadXML <ObservableCollection <Servicesinfo> >("Serviceinfo.xml");
            serviceTypes   = new List <String> {
                "Education", "Furniture", "Electronic_Items", "HouseholdItems", "RentCar", "Renthouse", "Other"
            };

            if (listOfPersons == null)
            {
                listOfPersons = new ObservableCollection <Personinfo_with_service_details>();
            }

            if (listOfServices == null)
            {
                listOfServices = new ObservableCollection <Servicesinfo>();
            }

            if (generalInfo == null)
            {
                generalInfo = new ObservableCollection <DisplayDetails>();
            }

            MainWindow mainWindow = new MainWindow();

            MainWindow.Show();
        }
        private void Btn_Register_Click(object sender, RoutedEventArgs e)
        {
            bool personexist = false;

            if (Txt_Email.Text.Length == 0 && Txt_Password.Text.Length == 0)
            {
                MessageBox.Show("EmailId and Password cannot be empty");
            }
            else
            {
                foreach (var person in App.listOfPersons)
                {
                    if (Txt_Email.Text == person.Email)
                    {
                        MessageBox.Show("Allready registered...");
                        personexist = true;
                        break;
                    }
                }
                if (!personexist)
                {
                    var newPerson = new Personinfo_with_service_details {
                        FirstName = Txt_FrstName.Text, LastName = Txt_LstName.Text, ContactNo = Txt_Contact.Text, Email = Txt_Email.Text, Password = Txt_Password.Text
                    };
                    App.listOfPersons.Add(newPerson);
                    MessageBox.Show("Registered Sucessfull");
                    Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
                }
            }

            this.Close();
        }
        private void Btn_Delete_Servc_Click(object sender, RoutedEventArgs e)
        {
            var deleteService = Lbx_Offered_Services.SelectedItem as Servicesinfo;

            if (Lbx_Offered_Services.SelectedItem == null)
            {
                MessageBox.Show("Please select an item to be deleted...");
                return;
            }

            foreach (var person in App.listOfPersons)
            {
                if (person.Email == App.loginPersonInfo.Email)
                {
                    foreach (var serviceId in person.Offered_services)
                    {
                        if (serviceId == deleteService.ServiceId)
                        {
                            person.Offered_services.Remove(serviceId);
                            Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
                            break;
                        }
                    }
                    break;
                }
            }
            foreach (var deletedItem in App.generalInfo)
            {
                if (deletedItem.ServiceId == deleteService.ServiceId)
                {
                    App.generalInfo.Remove(deletedItem);
                }
            }
            foreach (var item in App.listOfServices)
            {
                if (item.ServiceId == deleteService.ServiceId)
                {
                    App.listOfServices.Remove(item);
                    service.Remove(item);
                    MessageBox.Show("Seletem Item is deleted sucessfully");
                    Mystorage.WriteXML <ObservableCollection <Servicesinfo> >("Serviceinfo.xml", App.listOfServices);
                    break;
                }
            }

            Lbx_Offered_Services.ItemsSource = service;
            Txtb_Offered_Lst.Text            = "You have offered " + Lbx_Offered_Services.Items.Count + " services";

            Lbx_Interested_Ppl.ItemsSource = App.generalInfo;
        }
 private void Btn_Reset_Click(object sender, RoutedEventArgs e)
 {
     foreach (var person in App.listOfPersons)
     {
         if (person.Email == Txt_Email.Text)
         {
             if (Txt_Password.Text == Txt_ConfrmPass.Text)
             {
                 person.Password = Txt_Password.Text;
                 Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
                 MessageBox.Show("Password Reset Successfull");
                 this.Close();
                 break;
             }
         }
         else
         {
             MessageBox.Show("Email Id is not registered");
             break;
         }
     }
 }
        private void Btn_Add_Submit_Click(object sender, RoutedEventArgs e)
        {
            int serviceCount = App.listOfServices.Count;

            if (btnName == "Add")
            {
                var newService = new Servicesinfo
                {
                    ServiceId   = "S" + ++serviceCount,
                    ServiceType = Cbx_Serv_List.SelectedValue.ToString(),
                    Price       = Txt_Price.Text,
                    Description = Txt_Description.Text,
                    Location    = Txt_Location.Text,
                    PostedDate  = Dp_Date.Text,
                    PersonId    = App.loginPersonInfo.Email
                };

                foreach (var person in App.listOfPersons)
                {
                    if (person.Email == App.loginPersonInfo.Email)
                    {
                        person.Offered_services.Add(newService.ServiceId);
                        break;
                    }
                }
                App.listOfServices.Add(newService);
            }
            else
            {
                App.listOfServices.Where(S => S.ServiceId == selelctedService.ServiceId)
                .Select(S => { S.ServiceType = Cbx_Serv_List.SelectedValue.ToString(); S.Price = Txt_Price.Text; S.Location = Txt_Location.Text; S.Description = Txt_Description.Text; return(S); }).ToList();
            }

            Mystorage.WriteXML <ObservableCollection <Servicesinfo> >("Serviceinfo.xml", App.listOfServices);
            Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
            MessageBox.Show("Service Added Successfully....");
            OfferService.UpdateServiceList();
            this.Close();
        }
        private void Btn_Save_Click(object sender, RoutedEventArgs e)
        {
            if (Txt_Email.Text.Length == 0 && Txt_Password.Text.Length == 0)
            {
                MessageBox.Show("EmailId and Password cannot be empty");
            }
            else
            {
                foreach (var person in App.listOfPersons)
                {
                    if (Txt_Email.Text == person.Email)
                    {
                        App.listOfPersons.Where(S => S.Email == App.loginPersonInfo.Email)
                        .Select(S => { S.FirstName = Txt_FrstName.Text; S.LastName = Txt_LstName.Text; S.Password = Txt_Password.Text; S.ContactNo = Txt_Contact.Text; return(S); }).ToList();
                        MessageBox.Show("Updated Sucessfully...");
                        break;
                    }
                }
            }

            EnableDisableCtrls(false);
            Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
        }
        private void Btn_Interested_Click(object sender, RoutedEventArgs e)
        {
            var interestedService = Lbx_Display_List.SelectedItem as Servicesinfo;

            if (App.loginPersonInfo == null)
            {
                MessageBox.Show("Please login to send your interested request");
            }
            else if (Lbx_Display_List.SelectedItem == null)
            {
                MessageBox.Show("Please select an item to send your interested request");
            }
            else
            {
                foreach (var person in App.listOfPersons)
                {
                    if (interestedService.PersonId == App.loginPersonInfo.Email)
                    {
                        MessageBox.Show("Selected service is offered by you...");
                        return;
                    }
                }

                bool existingService = false;

                foreach (var interest in App.listOfPersons)
                {
                    if (interest.Email == App.loginPersonInfo.Email)
                    {
                        foreach (var serviceId in interest.Interested_offers)
                        {
                            if (interestedService.ServiceId == serviceId)
                            {
                                MessageBox.Show("Selected service already in your interested list");
                                existingService = true;
                                return;
                            }
                        }
                        if (!existingService)
                        {
                            interest.Interested_offers.Add(interestedService.ServiceId);
                            MessageBox.Show("Thankyou for your interest in service....");
                        }

                        break;
                    }
                }

                foreach (var service in App.listOfServices)
                {
                    if (service.ServiceId == interestedService.ServiceId)
                    {
                        service.InterestedPersonsEmailId.Add(App.loginPersonInfo.Email);
                        break;
                    }
                }

                Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
                Mystorage.WriteXML <ObservableCollection <Servicesinfo> >("Serviceinfo.xml", App.listOfServices);
            }
        }
示例#8
0
        private void Btn_Delete_Intst_Offer_Click(object sender, RoutedEventArgs e)
        {
            var deleteService = Lbx_Interested_Offers.SelectedItem as DisplayDetails;

            if (Lbx_Interested_Offers.SelectedItem == null)
            {
                MessageBox.Show("Please select an item to delete an interested service");
            }
            else
            {
                if (deleteService == null)
                {
                    return;
                }
                else
                {
                    foreach (var person in App.listOfPersons)
                    {
                        if (person.Email == App.loginPersonInfo.Email)
                        {
                            foreach (var serviceId in person.Interested_offers)
                            {
                                if (serviceId == deleteService.ServiceId)
                                {
                                    person.Interested_offers.Remove(serviceId);
                                    break;
                                }
                            }
                            break;
                        }
                    }

                    foreach (var item in App.listOfServices)
                    {
                        if (item.ServiceId == deleteService.ServiceId)
                        {
                            if (item.InterestedPersonsEmailId.Count != 0)
                            {
                                foreach (var emailId in item.InterestedPersonsEmailId)
                                {
                                    item.InterestedPersonsEmailId.Remove(emailId);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    foreach (var delete in App.generalInfo)
                    {
                        if (delete.ServiceId == deleteService.ServiceId)
                        {
                            App.generalInfo.Remove(delete);
                            break;
                        }
                    }
                }
                Lbx_Interested_Offers.ItemsSource = App.generalInfo;
                Txtb_Interested_Offers.Text       = "You are interested in " + App.generalInfo.Count + " offers";
                Mystorage.WriteXML <ObservableCollection <Servicesinfo> >("Serviceinfo.xml", App.listOfServices);
                Mystorage.WriteXML <ObservableCollection <Personinfo_with_service_details> >("Personinfowithservicedetails.xml", App.listOfPersons);
            }
        }