private void ChangeProfileStatus_Click(object sender, RoutedEventArgs e) { if (AccountListLocal.SelectedItem != null) { ProfileRF profileRF = AccountListLocal.SelectedItem as ProfileRF; if (profileRF.STATUS == "Active") { //Suspend profile //There is 2 choices: imediately or set exprire date SuspendOptionForm frm = new SuspendOptionForm(this, profileRF); frm.ShowDialog(); return; } else { //Active profile profileRF.STATUS = "Active"; //Release lock date and expire date profileRF.LOCK_DATE = DateTime.MinValue; profileRF.CHECK_DATE_TO_LOCK = false; profileRF.DATE_TO_LOCK = DateTime.MinValue; } SqliteDataAccess.UpdateProfileRF(profileRF, profileRF.STATUS); mainModel.ReloadListProfileRFDGV(); } }
public void ReloadListTimeCheckDGV() { try { timeCheckRFList.Clear(); if (mainW.AccountListData.SelectedItem != null && mainW.dp_search.SelectedDate != null) { ProfileRF profileRF = mainW.AccountListData.SelectedItem as ProfileRF; DateTime date = (DateTime)mainW.dp_search.SelectedDate; List <DateTime> timeList = SqliteDataAccess.LoadTimeCheckRF(profileRF.SERIAL_ID, date); foreach (DateTime item in timeList) { timeCheckRFList.Add(item); } } if (groupedTimeCheck.IsEditingItem) { groupedTimeCheck.CommitEdit(); } if (groupedTimeCheck.IsAddingNew) { groupedTimeCheck.CommitNew(); } groupedTimeCheck.Refresh(); } catch (Exception ex) { logFile.Error(ex.Message); } }
private void AccountListData_SelectedCellsChanged(object sender, System.Windows.Controls.SelectedCellsChangedEventArgs e) { try { if (AccountListData.SelectedItem != null) { ProfileRF temp = AccountListData.SelectedItem as ProfileRF; tb_serialID.Text = temp.SERIAL_ID; tb_name.Text = temp.NAME; dp_dateofbirth.Text = temp.BIRTHDAY.ToLongDateString(); tb_student.Text = temp.STUDENT; cbb_class.Text = temp.CLASS; tb_email.Text = temp.EMAIL; tb_address.Text = temp.ADDRESS; tb_phone.Text = temp.PHONE; if (temp.GENDER == Constant.Gender.Male) { rb_male.IsChecked = true; } else { rb_female.IsChecked = true; } } } catch (Exception ex) { logFile.Error(ex.Message); } }
private void Btn_delete_Click(object sender, RoutedEventArgs e) { try { if (AccountListLocal.SelectedItem == null) { return; } if (System.Windows.Forms.MessageBox.Show ( String.Format(Constant.messageDeleteConfirm, "Profile"), Constant.messageTitileWarning, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes ) { ProfileRF profileRF = AccountListLocal.SelectedItem as ProfileRF; if (profileRF != null) { SqliteDataAccess.RemoveProfileRF(profileRF); mainModel.ReloadListProfileRFDGV(); } } } catch (Exception ex) { logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); } }
private void CreateNewPerson() { ProfileRF person = new ProfileRF(); person.SERIAL_ID = tb_serialId.Text; person.NAME = tb_name.Text; person.GENDER = ((bool)rb_male.IsChecked) ? Constant.Gender.Male : Constant.Gender.Female; person.CLASS = cbb_class.Text; person.BIRTHDAY = (DateTime)dp_dateofbirth.SelectedDate; if (person.CLASS == "Student") { person.STUDENT = tb_studentName.Text; } else { person.STUDENT = ""; } person.EMAIL = tb_email.Text; person.ADDRESS = tb_address.Text; person.PHONE = tb_phone.Text; try { SqliteDataAccess.SaveProfileRF(person); lb_status.Content = "New Profile Added"; ClearForm(); mainWindow.mainModel.ReloadListProfileRFDGV(); } catch (Exception ex) { lb_status.Content = "Error add new person"; logFile.Error(ex.Message); } }
private void AccountListData_SelectedCellsChanged(object sender, System.Windows.Controls.SelectedCellsChangedEventArgs e) { try { if (AccountListLocal.SelectedItem != null) { ProfileRF temp = AccountListLocal.SelectedItem as ProfileRF; if (temp.STATUS == "Active") { btn_changestatuslb.Content = "Suspend Profile"; img_profileStatus.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"pack://*****:*****@"pack://siteoforigin:,,,/Resources/resultset_next.png")); } tb_serialID.Text = temp.PIN_NO; tb_adno.Text = temp.ADNO; tb_name.Text = temp.NAME; dp_dateofbirth.Text = temp.DOB.ToLongDateString(); dp_disu.Text = temp.DISU.ToLongDateString(); cbb_class.Text = temp.CLASS; //cbb_status.Text = temp.STATUS; tb_email.Text = temp.EMAIL; tb_image.Text = temp.IMAGE; tb_address.Text = temp.ADDRESS; tb_phone.Text = temp.PHONE; cb_automanicsuspension.IsChecked = temp.CHECK_DATE_TO_LOCK; dp_datetolock.Text = temp.DATE_TO_LOCK.ToLongDateString(); if (temp.GENDER == Constant.Gender.Male) { rb_male.IsChecked = true; } else { rb_female.IsChecked = true; } try { img_profile.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\ATEK\Image\" + temp.IMAGE)); } catch { img_profile.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"pack://siteoforigin:,,,/Resources/" + "images.png")); } } } catch (Exception ex) { logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); } }
private void Btn_fakeTimeCheck_Click(object sender, RoutedEventArgs e) { try { ProfileRF profileRF = AccountListData.SelectedItem as ProfileRF; SqliteDataAccess.SaveTimeCheckRF(profileRF.SERIAL_ID, DateTime.Now); } catch (Exception ex) { logFile.Error(ex.Message); } }
private void CreateNewPerson() { try { ProfileRF person = new ProfileRF(); person.PIN_NO = tb_serialId.Text; person.NAME = tb_name.Text; person.CLASS = cbb_class.Text; person.GENDER = ((bool)rb_male.IsChecked) ? Constant.Gender.Male : Constant.Gender.Female; person.DOB = (DateTime)dp_dateofbirth.SelectedDate; //if (person.CLASS == "Student") //{ // person.STUDENT = tb_studentName.Text; //} //else //{ // person.STUDENT = ""; //} person.EMAIL = tb_email.Text; person.ADDRESS = tb_address.Text; person.PHONE = tb_phone.Text; person.ADNO = tb_adno.Text; person.DISU = (DateTime)dp_disu.SelectedDate; person.CHECK_DATE_TO_LOCK = (bool)cb_automanicsuspension.IsChecked; if (cb_automanicsuspension.IsChecked == true) { person.DATE_TO_LOCK = (DateTime)dp_datetolock.SelectedDate; } else { person.DATE_TO_LOCK = DateTime.MinValue; } person.IMAGE = tb_image.Text; person.STATUS = "Active"; SqliteDataAccess.SaveProfileRF(person); lb_status.Content = "New Profile Added"; ClearForm(); mainWindow.mainModel.ReloadListProfileRFDGV(); } catch (Exception ex) { lb_status.Content = "Error add new person"; logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); } }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(importFilePath); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; try { Constant.CreateFolderToSaveData(); this.Dispatcher.Invoke(() => { processStatusText.Content = "Loading"; btn_stop.IsEnabled = true; }); int rowCount = xlRange.Rows.Count; int colCount = xlRange.Columns.Count; string serialId = ""; for (int i = 2; i <= rowCount; i++) { if (xlRange.Cells[i, 2] != null && xlRange.Cells[i, 2].Value2 != null) { ProfileRF profile = new ProfileRF(); DateTime ngayThang = DateTime.MinValue; double dateD; if (xlRange.Cells[i, 8] != null && xlRange.Cells[i, 8].Value2 != null) { serialId = xlRange.Cells[i, 8].Value2.ToString(); profile.PIN_NO = serialId; } profile.NAME = xlRange.Cells[i, 2].Value2.ToString().ToUpper(); profile.ADNO = xlRange.Cells[i, 3].Value2.ToString().ToUpper(); profile.GENDER = (xlRange.Cells[i, 4].Value2.ToString() == "Male" ? Constant.Gender.Male : Constant.Gender.Female); string sDate = xlRange.Cells[i, 5].Value2.ToString(); try { ngayThang = DateTime.MinValue; ngayThang = DateTime.ParseExact(sDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { dateD = double.Parse(sDate); var dateTime = DateTime.FromOADate(dateD).ToString("MMMM dd, yyyy"); ngayThang = DateTime.Parse(dateTime); } profile.DOB = ngayThang; sDate = xlRange.Cells[i, 6].Value2.ToString(); try { ngayThang = DateTime.MinValue; ngayThang = DateTime.ParseExact(sDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { dateD = double.Parse(sDate); var dateTime = DateTime.FromOADate(dateD).ToString("MMMM dd, yyyy"); ngayThang = DateTime.Parse(dateTime); } profile.DISU = ngayThang; profile.IMAGE = xlRange.Cells[i, 7].Value2.ToString(); ImportProfileImage(importFileFolder, profile.IMAGE); profile.CLASS = xlRange.Cells[i, 9].Value2.ToString(); profile.EMAIL = (xlRange.Cells[i, 10].Value2 == null) ? "" : xlRange.Cells[i, 10].Value2.ToString(); profile.ADDRESS = (xlRange.Cells[i, 11].Value2 == null) ? "" : xlRange.Cells[i, 11].Value2.ToString(); profile.PHONE = (xlRange.Cells[i, 12].Value2 == null) ? "" : xlRange.Cells[i, 12].Value2.ToString(); profile.STATUS = xlRange.Cells[i, 13].Value2.ToString(); if (profile.STATUS == "Suspended") { sDate = xlRange.Cells[i, 14].Value2.ToString(); try { ngayThang = DateTime.MinValue; ngayThang = DateTime.ParseExact(sDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { dateD = double.Parse(sDate); var dateTime = DateTime.FromOADate(dateD).ToString("MMMM dd, yyyy"); ngayThang = DateTime.Parse(dateTime); } profile.LOCK_DATE = ngayThang; } else { profile.LOCK_DATE = DateTime.MinValue; } if (xlRange.Cells[i, 16].Value2 != null) { profile.CHECK_DATE_TO_LOCK = Boolean.Parse(xlRange.Cells[i, 16].Value2.ToString()); } else { profile.CHECK_DATE_TO_LOCK = false; } if (profile.CHECK_DATE_TO_LOCK == true) { if (xlRange.Cells[i, 15].Value2 != null) { sDate = xlRange.Cells[i, 15].Value2.ToString(); try { ngayThang = DateTime.MinValue; ngayThang = DateTime.ParseExact(sDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { dateD = double.Parse(sDate); var dateTime = DateTime.FromOADate(dateD).ToString("MMMM dd, yyyy"); ngayThang = DateTime.Parse(dateTime); } profile.DATE_TO_LOCK = ngayThang; } else { profile.DATE_TO_LOCK = DateTime.MinValue; } } else { profile.DATE_TO_LOCK = DateTime.MinValue; } try { if (addorupdate) { SqliteDataAccess.SaveProfileRF(profile); } else { SqliteDataAccess.UpdateProfileRF(profile, profile.STATUS); } } catch (Exception ex) { logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); } } if (worker.CancellationPending) { this.Dispatcher.Invoke(() => { processStatusText.Content = "Stopped"; btn_stop.IsEnabled = false; }); break; } (sender as BackgroundWorker).ReportProgress((i * 100) / rowCount); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Import error, please check again!", Constant.messageTitileError, MessageBoxButtons.OK, MessageBoxIcon.Error); logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); } finally { //Constant.mainWindowPointer.WriteLog("Dong xlWorkbook.Close();"); xlWorkbook.Close(); xlApp.Quit(); this.Dispatcher.Invoke(() => { processStatusText.Content = "Finished"; btn_import.IsEnabled = true; btn_stop.IsEnabled = false; }); } }
public SuspendOptionForm(MainWindow mainW, ProfileRF profileRF) { this.mainW = mainW; this.profileRF = profileRF; InitializeComponent(); }
private void Btn_save_Click(object sender, RoutedEventArgs e) { try { if (String.IsNullOrEmpty(tb_serialID.Text.ToString()) || tb_serialID.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "PIN No.", "PIN No."), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_serialID.Focus(); return; } if (String.IsNullOrEmpty(tb_name.Text.ToString()) || tb_name.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "Name", "Name"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_name.Focus(); return; } if (String.IsNullOrEmpty(cbb_class.Text.ToString()) || cbb_class.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "Class", "Class"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.cbb_class.Focus(); return; } if (String.IsNullOrEmpty(tb_adno.Text.ToString()) || tb_adno.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "Adno", "Adno"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_adno.Focus(); return; } if (String.IsNullOrEmpty(dp_dateofbirth.Text.ToString()) || dp_dateofbirth.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "DOB", "DOB"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dp_dateofbirth.Focus(); return; } if (String.IsNullOrEmpty(dp_disu.Text.ToString()) || dp_disu.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "DISU", "DISU"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dp_disu.Focus(); return; } if (cb_automanicsuspension.IsChecked == true) { if (String.IsNullOrEmpty(dp_datetolock.Text.ToString()) || dp_datetolock.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "Expire Date", "Expire Date"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dp_datetolock.Focus(); return; } } if (String.IsNullOrEmpty(tb_image.Text.ToString()) || tb_image.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "Image", "Image"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_image.Focus(); return; } if (DisableEditProfile()) { ProfileRF person = new ProfileRF(); person.PIN_NO = tb_serialID.Text; person.ADNO = tb_adno.Text; person.NAME = tb_name.Text; person.GENDER = ((bool)rb_male.IsChecked) ? Constant.Gender.Male : Constant.Gender.Female; person.CLASS = cbb_class.Text; //person.STATUS = cbb_status.Text; person.DOB = (DateTime)dp_dateofbirth.SelectedDate; person.DISU = (DateTime)dp_disu.SelectedDate; //if (person.CLASS == "Student") //{ // person.STUDENT = tb_student.Text; //} //else //{ // person.STUDENT = ""; //} person.EMAIL = tb_email.Text; person.IMAGE = tb_image.Text; person.ADDRESS = tb_address.Text; person.PHONE = tb_phone.Text; person.CHECK_DATE_TO_LOCK = (bool)cb_automanicsuspension.IsChecked; if (person.CHECK_DATE_TO_LOCK) { person.DATE_TO_LOCK = (DateTime)dp_datetolock.SelectedDate; } else { person.DATE_TO_LOCK = DateTime.MinValue; } person.PHONE = tb_phone.Text; try { SqliteDataAccess.UpdateProfileRF(person); mainModel.ReloadListProfileRFDGV(); editProfile.IsEnabled = true; MainTabControl.IsEnabled = true; save.Visibility = Visibility.Hidden; AccountListLocal.IsEnabled = true; } catch (Exception ex) { logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); editProfile.IsEnabled = true; MainTabControl.IsEnabled = true; save.Visibility = Visibility.Hidden; AccountListLocal.IsEnabled = true; } } } catch (Exception ex) { logFile.Error(ex.Message); Constant.mainWindowPointer.WriteLog(ex.Message); editProfile.IsEnabled = true; MainTabControl.IsEnabled = true; save.Visibility = Visibility.Hidden; AccountListLocal.IsEnabled = true; } }
private void CheckBox_Click(object sender, RoutedEventArgs e) { ProfileRF selectedProfile = (sender as System.Windows.Controls.CheckBox).DataContext as ProfileRF; Console.WriteLine("sacascas"); }
private void Btn_save_Click(object sender, RoutedEventArgs e) { try { if (String.IsNullOrEmpty(tb_name.Text.ToString()) || tb_name.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "Name", "Name"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_name.Focus(); return; } if (String.IsNullOrEmpty(cbb_class.Text.ToString()) || cbb_class.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "cbb_class", "cbb_class"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.cbb_class.Focus(); return; } if (String.IsNullOrEmpty(dp_dateofbirth.Text.ToString()) || dp_dateofbirth.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "dp_dateofbirth", "dp_dateofbirth"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dp_dateofbirth.Focus(); return; } if (cbb_class.Text.ToString() == "Student") { if (String.IsNullOrEmpty(tb_student.Text.ToString()) || tb_student.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "tb_studentName", "tb_studentName"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_student.Focus(); return; } } if (String.IsNullOrEmpty(tb_email.Text.ToString()) || tb_email.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "tb_email", "tb_email"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_email.Focus(); return; } if (String.IsNullOrEmpty(tb_address.Text.ToString()) || tb_address.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "tb_address", "tb_address"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_address.Focus(); return; } if (String.IsNullOrEmpty(tb_phone.Text.ToString()) || tb_phone.Text.ToString().Trim() == "") { System.Windows.Forms.MessageBox.Show(String.Format(Constant.messageValidate, "tb_phone", "tb_phone"), Constant.messageTitileWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_phone.Focus(); return; } if (DisableEditProfile()) { ProfileRF person = new ProfileRF(); person.SERIAL_ID = tb_serialID.Text; person.NAME = tb_name.Text; person.GENDER = ((bool)rb_male.IsChecked) ? Constant.Gender.Male : Constant.Gender.Female; person.CLASS = cbb_class.Text; person.BIRTHDAY = (DateTime)dp_dateofbirth.SelectedDate; if (person.CLASS == "Student") { person.STUDENT = tb_student.Text; } else { person.STUDENT = ""; } person.EMAIL = tb_email.Text; person.ADDRESS = tb_address.Text; person.PHONE = tb_phone.Text; try { SqliteDataAccess.UpdateProfileRF(person); mainModel.ReloadListProfileRFDGV(); edit.IsEnabled = true; save.Visibility = Visibility.Hidden; AccountListData.IsEnabled = true; } catch (Exception ex) { logFile.Error(ex.Message); edit.IsEnabled = true; save.Visibility = Visibility.Hidden; AccountListData.IsEnabled = true; } } } catch (Exception ex) { logFile.Error(ex.Message); edit.IsEnabled = true; save.Visibility = Visibility.Hidden; AccountListData.IsEnabled = true; } }