public void SaveData(ShootingData data) { DatabaseIDU db = new DatabaseIDU(); doneSave = db.insert(data); saveData = false; }
public DataRecords() { InitializeComponent(); List <ShootingData> allData = new List <ShootingData>(); DatabaseIDU db = new DatabaseIDU(); if (Login.loginAdmin == 1) { allData = db.GetShootingData(); shootDataGridView.DataSource = allData; } else if (Login.loginOther == 1) { allData = db.GetShootingDataTrainee(Login.TraineeId); shootDataGridView.DataSource = allData; } }
private void registrationButton_Click(object sender, EventArgs e) { int doReg = 0; Trainee hasTrainee = new Trainee(); DatabaseIDU database = new DatabaseIDU(); try { if (passwordTextBox.Text == rePasswordTextBox.Text) { Trainee trainee = new Trainee(); trainee.TraineeId = idTextBox.Text; trainee.TraineeName = nameTaxtBox.Text; trainee.BatchNo = batchTaxtBox.Text; trainee.UserName = userNameTextBox.Text; trainee.Password = passwordTextBox.Text; hasTrainee = database.CheckTrainee(trainee); if (hasTrainee.UserName == trainee.UserName) { MessageBox.Show("Username already exists.Please try another one."); } else if (hasTrainee.TraineeId == trainee.TraineeId) { MessageBox.Show("Trainee id must be unique."); } else { doReg = database.Registration(trainee); if (doReg > 0) { MessageBox.Show("Registration successful."); } } } else { MessageBox.Show("Password did not match."); } } catch (Exception ex) { MessageBox.Show("Error occured."); } }
private void startToolStripButton_Click(object sender, EventArgs e) { string countData = ""; if (Login.loginOther == 1) { try { DatabaseIDU data = new DatabaseIDU(); countData = data.CountData(Login.TraineeId); VideoProcess.fileNameEnd = Login.TraineeId + countData; } catch (Exception ex) { } if (File.Exists(Login.fileName + VideoProcess.fileNameEnd + "Log" + ".txt")) { File.Delete(Login.fileName + VideoProcess.fileNameEnd + "Log" + ".txt"); } if (File.Exists(Login.fileName + VideoProcess.fileNameEnd + ".txt")) { File.Delete(Login.fileName + VideoProcess.fileNameEnd + ".txt"); } ShootPointController.getController().resetPoint(); targetTimer.isRunning = true; targetTimer.singleShotTime = 0; VideoProcess.getPoint = 1; VideoProcess.count = 1; //Starting counter startCounter(); setControlToolButton(false, true, true); mainTargetInfo.setShotLabelInfo(0, 0); } else { MessageBox.Show("Please,Login as trainee"); } //gbLogin.Visible = true; //dtLogin.Value = DateTime.Now; }
private void loginButton_Click(object sender, EventArgs e) { int doLogin = 0; Login login = new Login(); Trainee aTrainee = new Trainee(); DatabaseIDU database = new DatabaseIDU(); if (userNameTextBox.Text == "" || passwordTextBox.Text == "") { MessageBox.Show("Please Enter Username And Password"); } else { try { login.UserName = userNameTextBox.Text; login.Password = passwordTextBox.Text; login.Role = roleComboBox.SelectedItem.ToString(); login.Now = Convert.ToDateTime(dateTimeTextBox.Text); if (login.Role == "Others") { aTrainee = database.Login(login); if (aTrainee.TraineeId != null) { Login.loginOther = 1; Login.BaNo = aTrainee.BatchNo; Login.ShooterName = aTrainee.TraineeName; Login.TraineeId = aTrainee.TraineeId; MessageBox.Show("You are successfully logged in."); mainForm.SetMenuItem(1); this.Dispose(); } else { MessageBox.Show("Incorrect username or password.Please try again"); } } else if (login.Role == "Admin") { int doneLogin = database.AdminLogin(login); if (doneLogin == 1) { Login.loginAdmin = 1; MessageBox.Show("You are successfully logged in."); //MainForm main = new MainForm(); //Application.Run(main); mainForm.SetMenuItem(1); this.Dispose(); } else { MessageBox.Show("Incorrect username or password.Please try again."); } } } catch (Exception ex) { MessageBox.Show("Error Occured..."); //throw new Exception("Error", ex); } } }