private void dTRDataGridView_RowLeave(object sender, DataGridViewCellEventArgs e) { //if (User.UserLevel == 3) //{ // labelSuper.Text = @"Note: Authorized User."; // labelSuper.ForeColor = Color.Green; if (dTRBindingSource?.Current == null) { return; } if (dTRDataGridView.Rows.Count > 0) { if (dTRDataGridView.IsCurrentRowDirty) { Validate(); ((DTR)dTRBindingSource.Current).IsSource = true; ((DTR)dTRBindingSource.Current).EditedBy = User.UserName; ((DTR)dTRBindingSource.Current).EditedOn = DateTime.Now; ((DTR)dTRBindingSource.Current).EmployeeId = ((EmployeeData)listBox1.SelectedItem).EnrolleeId; ((DTR)dTRBindingSource.Current).EmployeeNo = ((EmployeeData)listBox1.SelectedItem).EnrolleeNo; dTRBindingSource.EndEdit(); var iResult = DTRManager.Save((DTR)dTRBindingSource.Current); Console.WriteLine(iResult > 0 ? @"Row Saved." : @"Row Save Error."); } } //} //else //{ // dTRDataGridView.CancelEdit(); // labelSuper.Text = @"Note: User is not authorized to modify record(s)."; // labelSuper.ForeColor = Color.Red; //} }
private void SaveDTR() { foreach (var dtr in _listDTR) { if (dtr.DTRId > 0) { int iResult = DTRManager.Save(dtr); if (iResult > 0) { Console.WriteLine(dtr.DTRId.ToString() + " " + dtr.DTRDay); } } } }
private void dTRDataGridView_RowLeave(object sender, DataGridViewCellEventArgs e) { if (dTRBindingSource?.Current == null) { return; } if (dTRDataGridView.Rows.Count > 0) { if (dTRDataGridView.IsCurrentRowDirty) { Validate(); ((DTR)dTRBindingSource.Current).IsSource = true; ((DTR)dTRBindingSource.Current).EditedBy = User.UserName; ((DTR)dTRBindingSource.Current).EditedOn = DateTime.Now; ((DTR)dTRBindingSource.Current).EmployeeId = ((EmployeeData)listBox1.SelectedItem).EnrolleeId; ((DTR)dTRBindingSource.Current).EmployeeNo = ((EmployeeData)listBox1.SelectedItem).EnrolleeNo; dTRBindingSource.EndEdit(); var iResult = DTRManager.Save((DTR)dTRBindingSource.Current); Console.WriteLine(iResult > 0 ? @"Row Saved." : @"Row Save Error."); } } }
private void buttonSave_Click(object sender, EventArgs e) { var bSuccessfull = false; var setNme = String.Format(@"USB{0}", DateTime.Now); Application.DoEvents(); Thread.Sleep(200); machineInsNameTextBox.Text = setNme; //save machine instance var iResult = SaveMachineInstance(); if (iResult <= 0) { return; } var listLogs = DTRManagement.RemoveDuplicateUsb(_listDat, iResult); var iiResult = MachineManager.Save(listLogs); if (iiResult <= 0) { return; } List <MacDumpLog> listMacDump; var listDTR = DTRManagement.LoadEnrolleeAttendanceDtrAll(EmployeeManager.GetAll(true), out listMacDump, User.UserName); //save DTR var iiiResult = DTRManager.Save(listDTR); if (iiiResult > 0) { bSuccessfull = true; } //save macDump if (listMacDump.Count > 0) { var tempMacDump = new List <MacDumpLog>(); foreach (var dumpLog in listMacDump) { if (dumpLog.MacDumpDate != null) { tempMacDump.Add(dumpLog); } } var iiiiResult = MacDumpLogManager.Save(tempMacDump); if (iiiiResult > 0) { Console.WriteLine(@"MacDump Successfully Record."); } } if (bSuccessfull) { MessageBox.Show(@"DTR Generated Successfully. Kindly Close the form and go to DTR Management", @"Save - DTR", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(@"Error occured during save.", @"Error Save - DTR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }