private void LoadData()
        {
            try
            {
                StartDate = new DateTime(((DateTime)dtpStartDate.SelectedDate).Year,
                                         ((DateTime)dtpStartDate.SelectedDate).Month,
                                         ((DateTime)dtpStartDate.SelectedDate).Day,
                                         tmpStartTime.SelectedHour, tmpStartTime.SelectedMinute,
                                         tmpStartTime.SelectedSecond);

                EndDate = new DateTime(((DateTime)dtpEndDate.SelectedDate).Year,
                                       ((DateTime)dtpEndDate.SelectedDate).Month,
                                       ((DateTime)dtpEndDate.SelectedDate).Day,
                                       tmpEndTime.SelectedHour, tmpEndTime.SelectedMinute,
                                       tmpEndTime.SelectedSecond);

                oAudit_History = new BMC.CashDeskOperator.BusinessObjects.Audit();

                var listAudit_History = oAudit_History.GetModulesList();
                if (listAudit_History == null)
                {
                    return;
                }
                cmbModules.ItemsSource       = listAudit_History;
                cmbModules.DisplayMemberPath = "Audit_Module_Name";
                cmbModules.SelectedValuePath = "Audit_Module_ID";
                cmbModules.SelectedIndex     = 0;

                // For resizing columns automatically.
                //GridView gv = lvAuditView.View as GridView;
                //if (gv != null)
                //{
                //    foreach (GridViewColumn gvc in gv.Columns)
                //    {
                //        gvc.Width = gvc.ActualWidth;
                //        if (gvc.Width == 0.0 || gvc.Width == 0)
                //            gvc.Width = 0;
                //        else
                //            gvc.Width = Double.NaN;
                //    }
                //}
                //GridView gvAFT = lvAFTView.View as GridView;
                //if (gvAFT != null)
                //{
                //    foreach (GridViewColumn gvc in gvAFT.Columns)
                //    {
                //        gvc.Width = gvc.ActualWidth;
                //        if (gvc.Width == 0.0 || gvc.Width == 0)
                //            gvc.Width = 0;
                //        else
                //            gvc.Width = Double.NaN;
                //    }
                //}
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        private void btnViewAudit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnViewAudit.IsEnabled = false;

                #region CR_#93510 (A.Vinod Kumar - 12/11/2011)

                /* <CR_#93510>
                 * 1. Exact records between from and to date
                 */
                // since we don't have the milliseconds in the UI, remove it from the date
                StartDate = StartDate.AddMilliseconds(-1 * StartDate.Millisecond);
                EndDate   = EndDate.AddMilliseconds(-1 * EndDate.Millisecond);
                /* </CR_#93510> */
                #endregion

                if (EndDate > DateTime.Now)
                {
                    MessageBox.ShowBox("MessageID288", BMC_Icon.Information);
                    lvAuditView.ItemsSource = null;
                    return;
                }
                if (StartDate > EndDate)
                {
                    MessageBox.ShowBox("MessageID99", BMC_Icon.Information);
                    lvAuditView.ItemsSource = null;
                    return;
                }
                oAudit_History = new BMC.CashDeskOperator.BusinessObjects.Audit();

                #region CR_#93510 (A.Vinod Kumar - 12/11/2011)

                /* <CR_#93510>
                 * 1. Exact records between from and to date
                 */
                // after date comparision add 999 milliseconds to todate,
                // otherwise will not get the records between milliseconds
                EndDate = EndDate.AddMilliseconds(999);
                /* </CR_#93510> */
                #endregion

                if (grdAudit.IsVisible)
                {
                    if (cmbModules.SelectedValue != null)
                    {
                        var orsp_GetAuditDetailsResult = oAudit_History.GetAuditDetails((DateTime)StartDate, (DateTime)EndDate,
                                                                                        (int.Parse(cmbModules.SelectedValue.ToString()) != 0) ? cmbModules.SelectedValue.ToString() : string.Empty, (cmbRows.SelectedItem == null || cmbRows.SelectedItem.ToString() == "ALL") ? 0 : int.Parse(cmbRows.SelectedItem.ToString()));
                        if (orsp_GetAuditDetailsResult == null)
                        {
                            lvAuditView.ItemsSource = null;
                            return;
                        }
                        if (orsp_GetAuditDetailsResult.Count > 0)
                        {
                            lvAuditView.ItemsSource = orsp_GetAuditDetailsResult;
                            //foreach (GridViewColumn gvCol in gvAudit.Columns)
                            //    ResizeGridViewColumn(gvCol);
                        }
                        else
                        {
                            MessageBox.ShowBox("MessageID100", BMC_Icon.Information);
                            lvAuditView.ItemsSource = null;
                        }
                    }
                    else
                    {
                        var orsp_GetAuditDetailsResult = oAudit_History.GetAuditDetails((DateTime)StartDate, (DateTime)EndDate,
                                                                                        string.Empty, (cmbRows.SelectedItem == null || cmbRows.SelectedItem.ToString() == "ALL") ? 0 : int.Parse(cmbRows.SelectedItem.ToString()));
                        if (orsp_GetAuditDetailsResult == null)
                        {
                            lvAuditView.ItemsSource = null;
                            return;
                        }
                        if (orsp_GetAuditDetailsResult.Count > 0)
                        {
                            lvAuditView.ItemsSource = orsp_GetAuditDetailsResult;
                            //foreach (GridViewColumn gvCol in gvAudit.Columns)
                            //    ResizeGridViewColumn(gvCol);
                        }
                        else
                        {
                            MessageBox.ShowBox("MessageID100", BMC_Icon.Information);
                            lvAuditView.ItemsSource = null;
                        }
                    }
                }
                else
                {
                    var orsp_GetAFTAuditDetailsResult = oAudit_History.GetAFTAuditData((DateTime)StartDate, (DateTime)EndDate,
                                                                                       (cmbRows.SelectedItem == null || cmbRows.SelectedItem.ToString() == "ALL") ? 0 : int.Parse(cmbRows.SelectedItem.ToString()));

                    if (orsp_GetAFTAuditDetailsResult == null)
                    {
                        lvAFTView.ItemsSource = null;
                        return;
                    }
                    if (orsp_GetAFTAuditDetailsResult.Count > 0)
                    {
                        lvAFTView.ItemsSource = orsp_GetAFTAuditDetailsResult;
                    }
                    else
                    {
                        MessageBox.ShowBox("MessageID100", BMC_Icon.Information);
                        lvAFTView.ItemsSource = null;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            finally
            {
                btnViewAudit.IsEnabled = true;
            }
        }