Ejemplo n.º 1
0
        /*
         * Override the equals method for object comparision
         */
        public override bool Equals(object o)
        {
            if (o == null || o.GetType() != typeof(PreferenceDTO))
            {
                return(false);
            }
            PreferenceDTO ca = (PreferenceDTO)o;

            return(ca.category.Equals(category) && ca.department.Equals(this.department) && ca.stdEmail.Equals(this.stdEmail));
        }
Ejemplo n.º 2
0
        //add objects of PreferenceDTO in arrayliat
        public bool addPreference(PreferenceDTO Obj)
        {
            if (preferenceList.Count == 0)
            {
                preferenceList.Add(Obj);
                return(true);
            }
            else
            {
                // check if object is alredy there don't add in array list
                if (preferenceList.Contains(Obj))
                {
                    return(false);
                }
                else
                {
                    preferenceList.Add(Obj);

                    return(true);
                }
            } // else of main if
        }     // add fun end
Ejemplo n.º 3
0
        private void btnpreference_Click(object sender, EventArgs e)
        {
            PreferenceDTO preference = new PreferenceDTO();

            if (!comboBoxcategory.SelectedItem.Equals("") && !comboBoxdepartment.SelectedItem.Equals(""))
            {
                preference.category   = "" + comboBoxcategory.SelectedItem;
                preference.department = "" + comboBoxdepartment.SelectedItem;
                preference.stdEmail   = strEmail;

                bool matched; // by default its value is false

                /*
                 * check if preference is in list then don't add return bool value
                 */
                matched = PreferenceDepartment.addPreference(preference);

                /*
                 * same preference not be added again and agin
                 */
                if (matched)
                {
                    int keycopy = strEmail.GetHashCode();
                    if (keycopy < 0)
                    {
                        keycopy = keycopy * -1;
                    }
                    // add in grid if message ia true
                    table.Rows.Add(keycopy, preference.category, preference.department);
                    countPreference += 1;
                }
                else
                {
                    MessageBox.Show("Preference is already added");
                }
            }
        }// add preference btn end