Esempio n. 1
0
        private void Entry_DataChanged(object sender, VisitorUpdateEventArgs e, DataEventType Action)
        {
            ListViewItem lvItem;

            switch (Action)
            {
            case DataEventType.INSERT_EVENT:

                lvItem      = new ListViewItem();
                lvItem.Name = Convert.ToString(e.DBID);
                lvItem.Text = e.VName;
                lvItem.SubItems.Add(e.Company);
                lvItem.SubItems.Add(e.ContactNo);
                //lvItem.SubItems.Add(e.RegNo);

                lvwVisitors.Items.Add(lvItem);
                lvwVisitors.EnsureVisible(lvItem.Index);
                break;

            case DataEventType.UPDATE_EVENT:
                lvItem                  = lvwVisitors.Items[lvwVisitors.SelectedItems[0].Index];
                lvItem.Text             = e.VName;
                lvItem.SubItems[1].Text = e.Company;
                lvItem.SubItems[2].Text = e.ContactNo;
                //lvItem.SubItems[3].Text = e.RegNo;

                lvwVisitors.EnsureVisible(lvwVisitors.SelectedItems[0].Index);
                break;
            }
            /// Below function are called to reload Company and ContactNo List.
            FillCompany();
            FillContactNo();
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool flgApplyEdit;
                flgApplyEdit = VisitorManager.Save(objVisitor, currentUser);
                if (flgApplyEdit)
                {
                    // instance the event args and pass it value
                    VisitorUpdateEventArgs args = new VisitorUpdateEventArgs(objVisitor.DBID, Convert.ToString(objVisitor.RegNo), objVisitor.VName, objVisitor.Company, objVisitor.MobileNo);

                    // raise event wtth  updated
                    if (Entry_DataChanged != null)
                    {
                        if (this.IsNew)
                        {
                            Entry_DataChanged(this, args, DataEventType.INSERT_EVENT);
                        }
                        else
                        {
                            Entry_DataChanged(this, args, DataEventType.UPDATE_EVENT);
                        }
                    }

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Record Not Saved.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }