private void btnSubmit_Click(object sender, RoutedEventArgs e) { try { if (pssRegPassword.Password == pssConfirmPass.Password) { User nwUser = new User() { Name = txtName.Text, Surname = txtSurname.Text, Activated = false, PasswordHash = PasswordHashing.HashPassword(pssRegPassword.Password), UserName = txtUserName.Text }; DbInsert.InsertUser(nwUser); MessageBox.Show("New User " + nwUser.Name + " " + nwUser.Surname + " Created!", "PASSWORD MISMATCH", MessageBoxButton.OK, MessageBoxImage.Information); txtName.Text = string.Empty; txtSurname.Text = string.Empty; pssConfirmPass.Password = string.Empty; pssRegPassword.Password = string.Empty; } else { pssConfirmPass.Password = string.Empty; pssRegPassword.Password = string.Empty; MessageBox.Show("Password does not match", "PASSWORD MISMATCH", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch (Exception) { // } }
void ResetTable(SqlConnection connection) { ScriptExecutor exe = new ScriptExecutor(); int c = (int)new SqlCommand(@"use itiSchoolDB SELECT count(*) as IsExists FROM dbo.sysobjects where id = object_id('Classroom')", connection).ExecuteScalar(); if (c > 0) { new SqlCommand("DROP TABLE Classroom", connection).ExecuteScalar(); } int s = (int)new SqlCommand(@"use itiSchoolDB SELECT count(*) as IsExists FROM dbo.sysobjects where id = object_id('Student')", connection).ExecuteScalar(); if (s > 0) { new SqlCommand("DROP TABLE Student", connection).ExecuteScalar(); } int t = (int)new SqlCommand(@"use itiSchoolDB SELECT count(*) as IsExists FROM dbo.sysobjects where id = object_id('Teacher')", connection).ExecuteScalar(); if (t > 0) { new SqlCommand("DROP TABLE Teacher", connection).ExecuteScalar(); } exe.ScriptExe(DbInit.CreateTableTeacher(), connection); exe.ScriptExe(DbInsert.InsertTeacherTable(), connection); exe.ScriptExe(DbInit.CreateTableStudent(), connection); exe.ScriptExe(DbInsert.InsertStudentTable(), connection); exe.ScriptExe(DbInit.CreateTableClassroom(), connection); exe.ScriptExe(DbInsert.InsertClassroomTable(), connection); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (dtpDate.SelectedDate == null) { MessageBox.Show("Please select the date first", "Date Missing", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else if (cmbInstructorName.SelectedValue == null) { MessageBox.Show("Please select the instructor first", "Instructor Missing", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { if (dtgData.Items.OfType <InstructorLearnerSchedule>().Where(x => x.Complete == false && x.Cancel == false && x.NoShow == false).Any()) { MessageBox.Show("The schedule is incomplete", "INCOMPLETE DATA", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { var completedList = dtgData.Items.OfType <InstructorLearnerSchedule>().Where(x => x.Complete == true || x.NoShow == true || x.Cancel == true).ToList(); DbInsert.ScheduleRecons(completedList, Globals.LogInID); MessageBox.Show("Schedule data saved", "DATA SAVED", MessageBoxButton.OK, MessageBoxImage.Information); //Reload window var mainWindow = Application.Current.Windows.Cast <Window>().FirstOrDefault(window => window is MainWindow) as MainWindow; DailySheet nwDailySheet = new DailySheet(); mainWindow.grdMain.Children.Clear(); mainWindow.grdMain.Children.Add(nwDailySheet); } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { Customer cust = new Customer() { ID = Convert.ToInt32(txtID.Text), DateOfBirth = Convert.ToDateTime(dtpDOB.SelectedDate), ExpiryDate = Convert.ToDateTime(dtpExpire.SelectedDate), FirstName = txtName.Text, IdentityNumber = txtIDNum.Text, NextOfKin = txtKin.Text, //PDLNumber = txtPDL.Text, NextOfKinPhoneNumber = txtKinContact.Text, PhoneNumber1 = txtPhoneNum1.Text, PhoneNumber2 = txtPhoneNum2.Text, Surname = txtSurname.Text, Valid = dtpValid.SelectedDate }; DbInsert.UpdateCustomerData(cust); MessageBox.Show("Customer Data Updated!", "Data Changed", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { MessageBox.Show("SYSTEM ERROR!", "An error occurred contact system admin.", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnReset_Click(object sender, RoutedEventArgs e) { PaswordReset nwPassReset = new PaswordReset() { Date = DateTime.Now, SupervisorID = Globals.LogInID, UserID = Convert.ToByte(cmbUserName.SelectedValue) }; var hashedUserPass = PasswordHashing.HashPassword("###"); var hashedSupervisorPass = PasswordHashing.HashPassword(txtPassword.Password); if (DbAccess.GetUserPasswordHashByID(Globals.LogInID).Any()) { if (PasswordHashing.ValidatePassword(txtPassword.Password, DbAccess.GetUserPasswordHashByID(Globals.LogInID))) { DbInsert.ResetPassword(nwPassReset, hashedUserPass); MessageBox.Show("Password Reset", "USER DATA", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Supervisor Password does not match", "USER DATA", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } }
public ContentResult verify(int code) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"code -> {security.sha256(code.ToString())}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); string html; try { DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); Status status = insert.verify(code); if (status.response == 0) { html = @"<html><head><meta charset = 'UTF-8' ></head>" + "<center><h2>Bildiriş<br>Təşəkkürlər, siz e-poçtunuzu təstiq etdiniz!</h2></center></html>"; return(base.Content("", "text/html")); } else { html = @"<html><head><meta charset = 'UTF-8'></head><center><h2>Bildiriş<br>Təəssüfki e-poçtunuz təstiq olunmadı</h2></center></html>"; } } catch (Exception ex) { html = @$ "<html><head><meta charset = 'UTF-8'><center><h2>Bildiriş<br>Server xətası:{ex.Message}</h2></center></html>"; } return(base.Content($"{html}", "text/html")); }
/// <summary> /// insert redundant crystal forms summary info to db table /// </summary> public void UpdateCfGroupInfo() { InitializeDbTable(); DataTable cfGroupTable = InitializeTable(); Dictionary <int, Dictionary <int, List <string> > > familyReduntCfHash = GetRedundantCFs(); /* string queryString = string.Format ("Select Distinct GroupSeqID From {0};", * GroupDbTableNames.dbTableNames[GroupDbTableNames.SgInterfaces]);*/ string queryString = string.Format("Select Distinct GroupSeqID From {0};", GroupDbTableNames.dbTableNames[GroupDbTableNames.HomoSeqInfo]); DataTable groupTable = ProtCidSettings.protcidQuery.Query(queryString); ProtCidSettings.progressInfo.ResetCurrentProgressInfo(); ProtCidSettings.progressInfo.totalStepNum = groupTable.Rows.Count; ProtCidSettings.progressInfo.totalOperationNum = groupTable.Rows.Count; ProtCidSettings.progressInfo.currentOperationLabel = "Update CF Info."; int groupId = 0; foreach (DataRow dRow in groupTable.Rows) { groupId = Convert.ToInt32(dRow["GroupSeqID"].ToString()); ProtCidSettings.progressInfo.currentOperationNum++; ProtCidSettings.progressInfo.currentStepNum++; ProtCidSettings.progressInfo.currentFileName = groupId.ToString(); GetNonReduntCfGroupsInFamily(groupId, familyReduntCfHash[groupId], ref cfGroupTable); } DbInsert dbInsert = new DbInsert(); dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, cfGroupTable); // DbBuilder.dbConnect.DisconnectFromDatabase (); }
public static void Run(int size, int iterations, string simDesc, string boardPath, bool dbInsert) { Statistics stats = new Statistics(new Simulation() { SimulationId = Guid.NewGuid(), Description = simDesc, SimulationDate = DateTime.Now, AIType = (int)AIType.Random }); try { Random random = new Random(); for (int i = 0; i < iterations; i++) { Game game = new Game(); game.GameId = Guid.NewGuid(); game.SimulationId = stats.Simulation.SimulationId; game.GameNumber = i + 1; string s = Files.Read(boardPath); Board board = GridParser.Parse(s, size); HuntTargetAI RandAI = new HuntTargetAI(board, game.GameId, random); stats.Shots.AddRange(RandAI.Play()); stats.Games.Add(game); } if(dbInsert) DbInsert.Insert(stats); Console.WriteLine("Done"); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static string InsertStudentName(NameObject name) { SqlParameter[] sqlParameters = new SqlParameter[3]; sqlParameters[0] = new SqlParameter() { ParameterName = "@FirstName", SqlDbType = SqlDbType.VarChar, Value = name.FirstName, Size = 50 }; sqlParameters[1] = new SqlParameter() { ParameterName = "@LastName", SqlDbType = SqlDbType.VarChar, Value = name.LastName, Size = 50 }; sqlParameters[2] = new SqlParameter() { ParameterName = "@ReturnValue", SqlDbType = SqlDbType.VarChar, Size = 140, Direction = ParameterDirection.Output }; return(DbInsert.Save("spInsertStudentName", sqlParameters)); }
public void T5_check_if_tables_are_filled() { using (SqlConnection connection = new SqlConnection(DbInit.GetConnectionString())) { connection.Open(); ResetTables(connection); ScriptExecutor exe = new ScriptExecutor(); exe.ScriptExe(DbInsert.InsertTeacherTable(), connection); exe.ScriptExe(DbInsert.InsertStudentTable(), connection); exe.ScriptExe(DbInsert.InsertClassroomTable(), connection); DataTable datatableStudent = new DataTable(); DataTable datatableTeacher = new DataTable(); DataTable datatableClassroom = new DataTable(); string teachers = "select count(*) from Teacher"; string students = "select count(*) from Student"; string classrooms = "select count(*) from Classroom"; SqlCommand cmd1 = new SqlCommand(teachers, connection); SqlCommand cmd2 = new SqlCommand(students, connection); SqlCommand cmd3 = new SqlCommand(classrooms, connection); int sqlresult1 = (Int32)cmd1.ExecuteScalar(); int sqlresult2 = (Int32)cmd2.ExecuteScalar(); int sqlresult3 = (Int32)cmd3.ExecuteScalar(); sqlresult1.Should().Be(9); sqlresult2.Should().Be(11); sqlresult3.Should().Be(8); connection.Close(); } }
private void dtgMaintenance_CurrentCellChanged(object sender, EventArgs e) { var selectedRow = dtgMaintenance.SelectedItem as Maintenace; if (selectedRow != null) { DbInsert.UpdateMaintenaceData(selectedRow); } }
private void dtgFueling_CurrentCellChanged(object sender, EventArgs e) { var selectedRow = dtgFueling.SelectedItem as VehicleFueling; if (selectedRow != null) { DbInsert.UpdateFuelingeData(selectedRow); } }
private void dtgInstructors_CurrentCellChanged(object sender, EventArgs e) { var selectedRow = dtgInstructors.SelectedItem as Instructor; if (selectedRow != null) { DbInsert.UpdateInstructorrData(selectedRow); } }
public List <Status> activateAds(string username, string pass, int aID, int isActive) { DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); List <Status> status = new List <Status>(); status = insert.activateAds(username, pass, aID, isActive); return(status); }
public Status ChangePassByMail(string newPass, string mail, string otp) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"newPass = {security.sha256(newPass)}\nmail -> {mail}\ncode -> {otp.ToString()} ", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.ResetPasswordByMail(newPass, mail, otp)); }
public ActionResult uProfile(UpdateProfileStruct uProfile) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log(Newtonsoft.Json.JsonConvert.SerializeObject(uProfile).ToString(), MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(Ok(insert.uProfile(uProfile))); }
public Status NewAdvertisement([FromForm] NewAdvertisementStruct obj) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log(Newtonsoft.Json.JsonConvert.SerializeObject(obj).ToString(), MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); // return return(insert.addNewAdvert(obj)); }
private void dtgUsers_CurrentCellChanged(object sender, EventArgs e) { var selectedRow = dtgUsers.SelectedItem as User; if (dtgUsers.SelectedItem != null) { DbInsert.UpdateUserData(selectedRow); dtgUsers.SelectedIndex = -1; LoadDataGrid(); } }
public ActionResult <Status> VerifyUserNewPhone(string userToken = "", string requestToken = "", int phone = 0, int otp = 0) { //boshluq var -> Kimse kodu bilse api ni calishdirib istediyi nomre yaza biler movcud olamayan bele var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"userToken -> {userToken}\nrequestToken = {requestToken}\nphone = {phone}\ncode = {otp.ToString()}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.VerifyUserNewPhone(userToken, requestToken, phone, otp)); }
public Status ActivateUser(int code) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"code -> {security.sha256(code.ToString())}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.verify(code)); }
private void chkComplete_Unchecked(object sender, RoutedEventArgs e) { var selectedItem = invoiceDataGrid.SelectedItem as InvoiceData; if (selectedItem != null) { selectedItem.Cancelled = false; selectedItem.CancelledBy = 0; selectedItem.CancellationReason = ""; DbInsert.CancelSale(selectedItem); } }
private void chkComplete_Checked(object sender, RoutedEventArgs e) { var selectedItem = invoiceDataGrid.SelectedItem as InvoiceData; if (selectedItem != null) { selectedItem.Cancelled = true; selectedItem.CancelledBy = Globals.LogInID; selectedItem.CancellationReason = "Double Sale"; DbInsert.CancelSale(selectedItem); } }
public ActionResult <Status> uPass(string userToken = "", string requestToken = "", string newPass = "") { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"userToken = {userToken} \n requestToken = {requestToken} \n newPass = {newPass}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.uPass(userToken, requestToken, newPass)); }
public ActionResult <Status> uAd(string userToken = "", string requestToken = "", int aID = 0, string aName = "", string aDescription = "", int aPrice = 0) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"userToken -> {userToken} \n requestToken -> {requestToken} \n aID -> {aID} \n aName -> {aName} \n aDescription -> {aDescription} \n aPrice -> {aPrice}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.uAd(userToken, requestToken, aID, aName, aDescription, aPrice)); }
public ActionResult <Status> deleteAd(string userToken = "", string requestToken = "", int aID = 0) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"userToken -> {userToken} \n requestToken -> {requestToken} \n aID -> {aID} ", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.deleteAd(userToken, requestToken, aID)); }
public Status SendResetSMS(long phone = 0) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"phone = {phone}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.SendResetSMS(phone)); }
public Status UpdateUserPhone(string userToken = "", string requestToken = "", long newPhone = 0) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"userToken = {userToken}\nrequestToken = {requestToken}\nnewPhone -> {newPhone}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.UpdateUserPhone(userToken, requestToken, newPhone)); }
public Status SendMail(string mail) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"mail -> {mail}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); return(insert.sendResetMail(mail)); // return // status = insert.newAdvertisement(obj); }
public ActionResult <Status> earnMoney(int advertID, string userToken, string requestToken) { var ipAddress = HttpContext.Connection.RemoteIpAddress; communication.log($"userToken -> {userToken}\requestToken -> {requestToken}", MethodBase.GetCurrentMethod().Name, ipAddress.ToString()); Status status; DbInsert insert = new DbInsert(Configuration, _hostingEnvironment); status = insert.EarnMoney(advertID, userToken, requestToken); return(Ok(status)); }
public void ParseDBInsertLogFile(string fileName, DbConnect dbConnect) { DbInsert dbInsert = new DbInsert(); StreamReader dataReader = new StreamReader(fileName); string line = ""; while ((line = dataReader.ReadLine()) != null) { if (line.ToUpper().IndexOf("INSERT INTO") > -1) { dbInsert.InsertDataIntoDb(dbConnect, line); } } dataReader.Close(); }