public datainsertion() { InitializeComponent(); catAppDB = new CatAppDataClasses(DBConnectionString); this.DataContext = this; }
public noquecat() { InitializeComponent(); // Connect to the database and instantiate data context. catAppDB = new CatAppDataClasses(DBConnectionString); // Data context and observable collection are children of the main page. this.DataContext = this; }
public IList <Option> GetOptionList() { // Fetching data from local database IList <Option> OptionList = null; using (catAppDB = new CatAppDataClasses(DBConnectionString)) { IQueryable <Option> OptionQuery = from option1 in catAppDB.Options select option1; OptionList = OptionQuery.ToList(); } return(OptionList); }
public IList <Attempt_detail> GetAttempt_detailList() { // Fetching data from local database IList <Attempt_detail> Attempt_detailList = null; using (catAppDB = new CatAppDataClasses(DBConnectionString)) { IQueryable <Attempt_detail> Attempt_detailQuery = from attempt1 in catAppDB.Attempt_details select attempt1; Attempt_detailList = Attempt_detailQuery.ToList(); } return(Attempt_detailList); }
public IList <Test> GetTestList() { // Fetching data from local database IList <Test> TestList = null; using (catAppDB = new CatAppDataClasses(DBConnectionString)) { IQueryable <Test> TestQuery = from Ts in catAppDB.Tests select Ts; TestList = TestQuery.ToList(); } return(TestList); }
public IList <User> GetUserList() { // Fetching data from local database IList <User> UserList = null; using (catAppDB = new CatAppDataClasses(DBConnectionString)) { IQueryable <User> UserQuery = from Us in catAppDB.Users select Us; UserList = UserQuery.ToList(); } return(UserList); }
public Opt() { InitializeComponent(); // Connect to the database and instantiate data context. catAppDB = new CatAppDataClasses(DBConnectionString); // Data context and observable collection are children of the main page. this.DataContext = this; /* dt.Interval = new TimeSpan(0, 0, 0, 0, 1); * dt.Tick += new EventHandler(dt_Tick); * startDt = DateTime.Now; * dt.Start();*/ }
private void radioButton1_Click_1(object sender, RoutedEventArgs e) { RadioButton radio = sender as RadioButton; //Boolean b = true; //if (radio.Tag.ToString().Equals(b.ToString())) //{ // IsAnswerCorrect = "true"; // // radio.IsChecked = true; //} //else //{ // IsAnswerCorrect = "false"; // //radio.IsChecked = false; //} string cn = radio.Content.ToString(); string id = txtquesID.Text.ToString(); long qid; long.TryParse(id, out qid); var opp = (from Option opt in catAppDB.Options where opt.Q_id == qid select opt).Count(); /*var testid = from Question que in catAppDB.Questions * where que._id == qid * select que; * var quelst = testid.ToList();*/ var opp1 = from Option opt in catAppDB.Options where opt.Q_id == qid select opt; var opt1list = opp1.ToList(); for (int i = 0; i < opp; i++) { var opt2 = opt1list[i] as Option; string opt3 = opt2.Content.ToString(); if (opt3 == cn) { txtoptid.Text = opt2._id.ToString(); } } long optid; long.TryParse(txtoptid.Text, out optid); using (catAppDB = new CatAppDataClasses(DBConnectionString)) { Attempt_detail newAttempt_detail = new Attempt_detail { Q_id = qid, O_id = optid, A_id = 2, //Q_id=51, //O_id=1842, //_id=5002, //A_id=1, // // A_id=1, //O_id=optid, Mark_flag = true }; catAppDB.Attempt_details.InsertOnSubmit(newAttempt_detail); catAppDB.SubmitChanges(); //DialogClosed("OK"); } }
private void OK_Click(object sender, RoutedEventArgs e) { IDictionary <string, string> y = this.NavigationContext.QueryString; String b = Convert.ToString(y["TextData1"]); textBox2.Text = b.ToString(); MessageBox.Show("b" + textBox2.Text); String timeonoff = b.ToString(); long tmonoff; long.TryParse(timeonoff, out tmonoff); bool tmd; if (tmonoff == 0) { tmd = false; } else { tmd = true; } string s = textBox1.Text; long l; long.TryParse(s, out l); var timest = from Test t in catAppDB.Tests where t._id == l select t; Tests = new ObservableCollection <Test>(timest); var time = Tests.ToList(); var t2 = time[0] as Test; var tt = t2.Allowed_time; txtAllowed.Text = tt.ToString(); // txtAllowed.Text = Tests.ToString(); // MessageBox.Show("Allowed Time" + txtAllowed.Text); //var tt = Tests.ToList(); // int ts = tt[0].Allowed_time; // txtAllowed.Text = Tests.ToString(); string tmpstp = txtAllowed.Text; int l1; long uid = 0; int.TryParse(tmpstp, out l1); ll = l1; IList <User> UserList = this.GetUserList(); foreach (User usr1 in UserList) { uid = usr1._id; } using (catAppDB = new CatAppDataClasses(DBConnectionString)) { Attempt newAttempt = new Attempt { T_id = l, Timpstamp = l1, Elapsed_time = l1 - ltotal, U_id = uid, //T_id = 13, //Timpstamp = 2100, Complete = completed, //Elapsed_time = 200, Timed = tmd }; catAppDB.Attempts.InsertOnSubmit(newAttempt); catAppDB.SubmitChanges(); //DialogClosed("OK"); } }