public SearchStudentModal(int coordinatorId, string typeOfSearch)
        {
            searches search = (searches)System.Enum.Parse(typeof(searches), typeOfSearch);

            InitializeComponent();
            this.TopLevel   = false;
            this.AutoScroll = true;
            this.Hide();

            checkBox1.Checked = false;

            if ((int)search == 1)
            {
                this.label1.Text = "Find Student To Update";
                _isUpdateStudent = true;
            }
            else if ((int)search == 2)
            {
                this.label1.Text             = "Find Student To Update Consultation";
                _isUpdateStudentConsultation = true;
            }

            _coordinatorId = coordinatorId;
            _group         = groupTableAdapter1.GetData();
            _groupId       = PopulateGroupComboBox();
        }
Ejemplo n.º 2
0
        public static bool addSearch(searches s)
        {
            using (DAL.Charity_DBEntities db = new DAL.Charity_DBEntities())
            {
                db.Searches.Add(Converters.SearchesConverter.convertToDal(s));
                try
                {
                    db.SaveChanges();
                    int count = 0;
                    foreach (var s1 in db.Searches)
                    {
                        if (s.Category == s1.Category && BL.GoogleMaps.GetDistance(s.Adress, s1.Adress) < 50 && s.fingerPrint != s1.fingerPrint)
                        {
                            count++;
                        }
                    }

                    {
                        if (count >= 5)
                        {
                            NeedsGmhim ng = new NeedsGmhim
                            {
                                Adress   = s.Adress,
                                category = s.Category
                            };
                            System.Diagnostics.Debug.WriteLine(s.Adress);
                            db.NeedsGmhim.Add(BL.Converters.GMHConverter.convertToDal(ng));
                            try
                            {
                                db.SaveChanges();
                                return(true);
                            }
                            catch { return(false); }
                        }
                    }
                    return(false);
                }
                catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            System.Diagnostics.Debug.WriteLine(
                                "Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                        }
                    }
                    System.Diagnostics.Debug.WriteLine("no");
                    return(false);
                }
            }
        }