private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Enter Valid Data"); } else { DBEF te = new DBEF(); Question q = new Question(); q.ChapterId = ((KeyValuePair <string, string>)comboBox3.SelectedItem).Key; q.OptionA = textBox1.Text; q.OptionB = textBox2.Text; q.OptionC = textBox3.Text; q.OptionD = textBox4.Text; q.Correct = comboBox4.SelectedItem.ToString(); q.Statment = richTextBox1.Text; q.Id = "QU" + q.ChapterId + DateTime.Now.GetHashCode().ToString().Substring(4); te.Questions.Add(q); te.SaveChanges(); textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = richTextBox1.Text = ""; MessageBox.Show("New Question Added"); } }
private void register_Click_1(object sender, EventArgs e) { DBEF saarthi = new DBEF(); var fnm = fname.Text; var lnm = lname.Text; var mnm = mname.Text; var eml = email.Text; var pswd = password.Text; var cpswd = confpassword.Text; if (pswd != cpswd) { MessageBox.Show("Password and Confirm Password is not match Kindly Check!!"); } else if (pictureBox1.Image == null) { MessageBox.Show("Please Select an image"); } else { var learner = saarthi.Learners.Where(x => x.Email == eml).FirstOrDefault(); if (learner != null) { MessageBox.Show("This Email Id is Already Registerd Login With it!!!"); } else { Learner l = new Learner(); l.Email = eml; l.F_Name = fnm; l.L_Name = lnm; l.M_Name = mnm; l.Password = pswd; l.LearnerId = "L" + DateTime.Now.Year + "" + DateTime.Now.GetHashCode().ToString().Substring(4); if (pictureBox1.Image != null) { l.PhotoURL = @"C:\Users\RADADIYA KRINISH\Desktop\Krinish\Myproject\Myproject\Saarthi_E-learning\Saarthi\Saarthi\AppData\profilePic\" + l.LearnerId + ".bmp"; pictureBox1.Image.Save(l.PhotoURL, System.Drawing.Imaging.ImageFormat.Bmp); saarthi.Learners.Add(l); saarthi.SaveChanges(); //label8.Text = "Congratulations!!! You are registerd Please Login.."; MessageBox.Show("Congratulations!!! You are registerd Please Login.."); } else { MessageBox.Show("Please enter Yoyr Profile Pic"); } } } }
private void button2_Click(object sender, EventArgs e) { Result r = new Result(); r.Total = this.quiz_questions.Count; r.Obtained = this.answer; r.chepter = this.chp; r.std = this.std; r.Subject = this.sub; r.LearnerId = LoginInfo.learner.LearnerId; r.QuizOn = DateTime.Now; r.Id = "QUIZ" + DateTime.Now.Date + "" + DateTime.Now.GetHashCode().ToString().Substring(4); DBEF te = new DBEF(); te.Results.Add(r); te.SaveChanges(); panel.Visible = false; tableLayoutPanel2.Visible = true; result.Text = "Your Score is " + r.Obtained + "/" + r.Total; }