private void Entry_DataChanged(object sender, VisitorGPUpdateEventArgs e, DataEventType Action) { ListViewItem lvItem; switch (Action) { case DataEventType.INSERT_EVENT: lvItem = new ListViewItem(); lvItem.Name = Convert.ToString(e.DBID); lvItem.Text = Convert.ToString(e.GPNo); lvItem.SubItems.Add(e.VisitorName); lvItem.SubItems.Add(e.GPDate.ToShortDateString()); lvItem.SubItems.Add(e.TimeIn.ToShortTimeString()); lvItem.SubItems.Add(e.ToMeet); lvItem.SubItems.Add(e.Purpose); if (e.TimeOut != DateTime.MinValue) { lvItem.SubItems.Add(e.TimeOut.ToShortTimeString()); } else { lvItem.SubItems.Add(""); } lvwGPs.Items.Add(lvItem); lvwGPs.EnsureVisible(lvItem.Index); lvItem.ForeColor = Color.Blue; lblTotal.Text = Convert.ToString(Convert.ToInt16(lblTotal.Text) + 1); lblTotalIn.Text = Convert.ToString(Convert.ToInt16(lblTotalIn.Text) + 1); break; case DataEventType.UPDATE_EVENT: lvItem = lvwGPs.Items[lvwGPs.SelectedItems[0].Index]; lvItem.Text = Convert.ToString(e.GPNo); lvItem.SubItems[1].Text = e.VisitorName; lvItem.SubItems[2].Text = e.GPDate.ToShortDateString(); lvItem.SubItems[3].Text = e.TimeIn.ToShortTimeString(); lvItem.SubItems[4].Text = e.ToMeet; lvItem.SubItems[5].Text = e.Purpose; if (e.TimeOut != DateTime.MinValue) { lvItem.SubItems[6].Text = e.TimeOut.ToShortTimeString(); } else { lvItem.SubItems[6].Text = ""; } lvwGPs.EnsureVisible(lvwGPs.SelectedItems[0].Index); break; } }
private void btnSave_Click(object sender, EventArgs e) { try { bool flgApplyEdit; flgApplyEdit = VisitorGatePassManager.Save(objVisitorGP, objUser); if (flgApplyEdit) { if (objVisitorGP.IsNew) { if (objVisitorGP.AppointmentNo != "") { GetSMSRespons(); } } // instance the event args and pass it value VisitorGPUpdateEventArgs args = new VisitorGPUpdateEventArgs(objVisitorGP.DBID, objVisitorGP.GatePassNo, objVisitorGP.GateDate, objVisitorGP.VisitorName, objVisitorGP.ToMeet, objVisitorGP.Purpose, objVisitorGP.TimeIn, objVisitorGP.TimeOut); // 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); this.Close(); } }
private void checkOutVisitorToolStripMenuItem_Click(object sender, EventArgs e) { try { if (objUIRights.AddRight) { VisitorGatePass objVisitorGP; objVisitorGP = VisitorGatePassManager.GetItem(Convert.ToInt32(lvwGPs.SelectedItems[0].Name)); objVisitorGP.TimeOut = DateTime.Now; bool flgApplyEdit; flgApplyEdit = VisitorGatePassManager.Save(objVisitorGP, currentUser); if (flgApplyEdit) { // instance the event args and pass it value VisitorGPUpdateEventArgs args = new VisitorGPUpdateEventArgs(objVisitorGP.DBID, objVisitorGP.GatePassNo, objVisitorGP.GateDate, objVisitorGP.VisitorName, objVisitorGP.ToMeet, objVisitorGP.Purpose, objVisitorGP.TimeIn, objVisitorGP.TimeOut); // raise event wtth updated Entry_DataChanged(this, args, DataEventType.UPDATE_EVENT); } else { MessageBox.Show("Record Not Saved."); } FillList(); } else { throw new Exception("Not Authorised."); } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }