Esempio n. 1
0
        public void DeleteContactControl(ContactControl control, int recordId)
        {
            if (MessageBox.Show("Are you sure you want to delete this Contact?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                string error = string.Empty;

                try
                {
                    DataBaseHelper.Delete <ContactDO>(Program.ConnectionString, ContactDO.TableName, recordId, ref error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while trying to delete a record: " + ex.Message);
                    return;
                }

                if (!string.IsNullOrWhiteSpace(error))
                {
                    MessageBox.Show(error);
                    return;
                }

                control.Visible = false;
                this.flowLayoutPanel1.Controls.Remove(control);
            }
        }
Esempio n. 2
0
        private void ExportClick(object sender, EventArgs e)
        {
            try
            {
                if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    List <ContactDO> records = new List <ContactDO>();

                    string fileName = this.saveFileDialog1.FileName;

                    foreach (object control in flowLayoutPanel1.Controls)
                    {
                        if (control is ContactControl)
                        {
                            ContactControl contactControl = control as ContactControl;

                            if (contactControl.Visible)
                            {
                                records.Add(contactControl.GetContactCopy());
                            }
                        }
                    }

                    string error = string.Empty;
                    ExcelHelper.Export(records, fileName, ref error);
                    this.ShowErrorIfNotEmpty(error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while trying to export data: " + ex.Message);
            }
        }
Esempio n. 3
0
 public void FormMouseEnter(object sender, EventArgs e)
 {
     foreach (object control in flowLayoutPanel1.Controls)
     {
         if (control is ContactControl)
         {
             ContactControl contactControl = control as ContactControl;
             contactControl.ContolMouseLeave();
         }
     }
 }
Esempio n. 4
0
        private void SearchClick(object sender, EventArgs e)
        {
            string searchString = this.txtSearch.Text;

            foreach (object control in flowLayoutPanel1.Controls)
            {
                if (control is ContactControl)
                {
                    ContactControl contactControl = control as ContactControl;
                    contactControl.Visible = contactControl.Contains(searchString);
                }
            }
        }