Beispiel #1
0
    private void BindGridQuestion()
    {
        int? getChaptersPerDay=0;
        int lessonCompleted = 0;
        int iSkip = 0;
        string username = hdnusername.Value;
        
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            var newuser = DataService.NewUser(username);
            if (newuser==0)
            {
                imgPrevious.Visible = false;
                getChaptersPerDay= DataService.GetTopicsPerChapter(lessonCompleted + 1);
                iSkip = 0;
            }
            else
            {
                //skip sum coursemst topic and take nect lesson 
                //iSkip=
                //getChaptersPerDay

            }
            grdchaptr.DataSource = DataService.LoadChapters(getChaptersPerDay);
            grdchaptr.DataBind();
        }
        
    }
Beispiel #2
0
 public static Int32 NewUser(string username)
 {
     Int32 result = 0;
     using (dbExtranetEntities db = new dbExtranetEntities())
     {
         result = db.Beg_Result.Where(x => x.Username == username).ToList().Count;
     }
     return result;
 }
Beispiel #3
0
    protected void Login_Click1(object sender, EventArgs e)
    {
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            using (var trans = db.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
            {
                try
                {
                    var userlog = db.Users.Single(a => a.Username == txtUserName.Text && a.Password == txtPassword.Text);
                    if (userlog != null)
                    {
                        if (chkRemember.Checked)
                        {
                            Response.Cookies["um"].Value = txtUserName.Text;
                            Response.Cookies["ptd"].Value = txtPassword.Text;
                            Response.Cookies["um"].Expires = DateTime.Now.AddDays(-1);
                            Response.Cookies["ptd"].Expires = DateTime.Now.AddDays(-1);
                        }
                        else
                        {
                            Response.Cookies["um"].Expires = DateTime.Now.AddDays(-1);
                            Response.Cookies["ptd"].Expires = DateTime.Now.AddDays(-1);

                        }
                        string utype;
                        utype = userlog.Usertype.ToString().Trim().ToUpper();
                        if (utype == "A")
                        {
                            Session["USERNAME"] = txtUserName.Text;
                            Session["ut"] = utype;
                            FormsAuthentication.RedirectFromLoginPage("admin", true); ;
                           
                        }
                        else if (utype == "U")
                        {

                            Session["USERNAME"] = txtUserName.Text;
                            Session["ut"] = utype;
                            Session["lgpr"] = userlog.LanguagePrefered;
                            FormsAuthentication.RedirectFromLoginPage("user", true); ;
                           // Response.Redirect("user",false);
                          
                        }
                    }
                    else
                    {
                        lblError.Text = "Invalid User or Password! ";
                    }
                }
                catch (Exception ex)
                {
                }
            
        }
        }
    }
Beispiel #4
0
    public static int? GetTopicsPerChapter(Int32 lessoncompleted)
    {
        int? result = 0;
        using (dbExtranetEntities db = new dbExtranetEntities())
        {

            result = db.CourseMsts.Where(x => x.Lesson == lessoncompleted).Select(x => x.Topics).SingleOrDefault();
        }
        return result;
    }
Beispiel #5
0
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     using (dbExtranetEntities db = new dbExtranetEntities())
     {
         using (var trans = db.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
         {
             try
             {
                 using (BinaryReader br = new BinaryReader(FileUpload11.PostedFile.InputStream))
                 {
                     byte[] bytes = br.ReadBytes((int)FileUpload11.PostedFile.InputStream.Length);
                     var bf= new Beg_Files
                     {
                         Name = Path.GetFileName(FileUpload11.PostedFile.FileName),
                         ContentType = "audio/mpeg3",
                         Play  = bytes,
                         BegAlphabetId = 1
                     };
                     db.Beg_Files.Add(bf);
                     db.SaveChanges();
                     trans.Commit();
                 }
                 //Response.Redirect(Request.Url.AbsoluteUri);
             }
             catch(Exception ex)
             {
                 trans.Rollback();
                 throw;
             }
         
         }
     }
     //using (BinaryReader br = new BinaryReader(FileUpload11.PostedFile.InputStream))
                 //{
                 //    byte[] bytes = br.ReadBytes((int)FileUpload11.PostedFile.InputStream.Length);
                 //    string strConnString = ConfigurationManager.ConnectionStrings["LearnData"].ConnectionString;
                 //    using (SqlConnection con = new SqlConnection(strConnString))
                 //    {
                 //        using (SqlCommand cmd = new SqlCommand())
                 //        {
                 //            cmd.CommandText = "insert into Beg_Files(Name, ContentType, Play) values (@Name, @ContentType, @Play)";
                 //            cmd.Parameters.AddWithValue("@Name", Path.GetFileName(FileUpload11.PostedFile.FileName));
                 //            cmd.Parameters.AddWithValue("@ContentType", "audio/mpeg3");
                 //            cmd.Parameters.AddWithValue("@Play", bytes);
                 //            cmd.Connection = con;
                 //            con.Open();
                 //            cmd.ExecuteNonQuery();
                 //            con.Close();
                 //        }
                 //    }
                 //}
                 //
             }
Beispiel #6
0
    public static int? GetNumQuestTaken(string username, int? getChaptersPerDay)
    {

        using (dbExtranetEntities db = new dbExtranetEntities())
        {

            List<int?> result1 = db.Beg_UserTest.Where(x => x.Username == username).Select(x => x.Course).ToList();
            List<int> result2 = db.Beg_Test.Select(x => x.Id).ToList();
            var differences = result2.Where(i => !result1.Contains(i)).ToList();
            int diff = differences[0];
            return diff;

        }

    }
Beispiel #7
0
    private void BindGrid()
    {
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            var query = db.tblFiles.Select(x => x).ToList();
        }


        //string strConnString = ConfigurationManager.ConnectionStrings["LearnData"].ConnectionString;
        //using (SqlConnection con = new SqlConnection(strConnString))
        //{
        //    using (SqlCommand cmd = new SqlCommand())
        //    {
        //        cmd.CommandText = "select Id, Name,Data from tblFiles"; 
        //        cmd.Connection = con;
        //        con.Open();
        //        //Repeater1.DataSource = cmd.ExecuteReader();
        //        //Repeater1.DataBind();
        //             DataList1.DataSource = cmd.ExecuteReader();
        //        DataList1.DataBind();
        //        con.Close();
        //    }
        //}
    }
Beispiel #8
0
    public static bool SendBacktoSameCourse(string testday, string username)
    {
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            using (var trans = db.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
            {
                try
                {
                    var removeusertest = db.Beg_UserTest.Where(x => x.Username == username && x.Day == testday).ToList();
                    db.Beg_UserTest.RemoveRange(removeusertest);
                    db.SaveChanges();
                    trans.Commit();

                    return false;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }
        }

    }
Beispiel #9
0
    public static List<LearningQuiz> LoadQuiz(int? getchaptersperday)
    {
        //4 quest
        //gets first record
        //List<Learning> randomList = LoadChapters(getchaptersperday);
        List<LearningQuiz> resultList;
        //randomList = randomList.Where(x => RandomService.GenerateRandom().Contains(x.BegPrId )).ToList();
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
//load question

            resultList =
                db.Beg_Test.AsNoTracking().Join(db.Beg_Translate, x => x.Id, y => y.begAlphabetId, (x, y) => new {x, y})
                    .Join(db.Beg_Files, a => a.x.Id, b => b.BegAlphabetId, (a, b) => new {a, b})
                    .Where(x => x.a.x.Id == getchaptersperday)
                    .Select(xy => new LearningQuiz()
                    {
                        IdTestquiz = xy.a.x.Id,
                        IdquizDay = xy.a.x.Day,
                        QuestionNum = xy.a.x.QuestionNumber,
                        Question = xy.a.x.Question,
                        An = xy.a.x.Answer,
                        BegPrId = xy.a.x.BegAlphabetId
                    }).ToList();
        }
        return resultList;
    }
Beispiel #10
0
    protected void OnClick_Next(object sender, EventArgs e)
    {
        //UpdateTimer.Enabled = true;
        int? getChaptersPerDay = 0;
        int? getNumQuestTaken = 0;
        int lessonCompleted = 0;
        int iSkip = 0;
        int i;
        ViewState["questnum"] = 0;
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            var newuser = DataService.NewUser(hdnusername.Value);
            if (newuser == 0)
            {
                getChaptersPerDay = DataService.GetTopicsPerChapter(lessonCompleted + 1);
                getNumQuestTaken = DataService.GetNumQuestTaken(hdnusername.Value, getChaptersPerDay);
                ViewState["questnum"] = getNumQuestTaken;
                imgPrevious.Visible = false;

                iSkip = 0;
            }
            else
            {
                ViewState["questnum"] = Convert.ToInt32(ViewState["questnum"]) + 1;
                //skip sum coursemst topic and take nect lesson 
                //iSkip=
                //getChaptersPerDay

            }
            List<DataService.LearningQuiz> quest= DataService.LoadQuiz(Convert.ToInt32(ViewState["questnum"]));
            lblQuest.Text = quest[0].QuestionNum + "   " + quest[0].Question;
            hdnAn.Value = Convert.ToString(quest[0].An);
            hdnMainQuestid.Value= Convert.ToString(quest[0].BegPrId);
            hdnTestQuestid.Value= Convert.ToString(quest[0].IdTestquiz);
            hdnTestQuestDay.Value = Convert.ToString(quest[0].IdquizDay);
        }
        grdchaptr.Visible = false;
        BindGridQuiz(getChaptersPerDay, Convert.ToInt32( hdnMainQuestid.Value));
        btnsubmit.Visible = true;

    }
Beispiel #11
0
    protected void btnSignup_Click(object sender, EventArgs e)
    {
        if (txtusername.Text != "" && txtPassword.Text != "" && txtConfirmPass.Text != "" && txtEmail.Text != "" && ddlPreferedLanguage.SelectedItem.Text!="Select" && 
            txtName.Text != "")
        {
            if (txtPassword.Text == txtConfirmPass.Text)
            {

                using (dbExtranetEntities db = new dbExtranetEntities())
                {
                    using (var trans = db.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
                    {
                        try
                        { 
                            var username = db.Users.Where(a=> a.Username == txtusername.Text).Select(x => x.Username).FirstOrDefault();
                            if (username == null)
                            {
                                var addUser = new User
                                {
                                    Username  = txtusername.Text,
                                    Password  = txtPassword.Text,
                                    Email = txtEmail.Text ,
                                    Name = txtName.Text,
                                    LanguagePrefered  = ddlPreferedLanguage.SelectedItem.Text,
                                   
                                };
                                db.Users.Add(addUser);
                            }
                            else
                            {
                                lblMsg.ForeColor = Color.Red;
                                lblMsg.Text = "Username Already Exists In Our Database";
                            }
                           
                            db.SaveChanges();
                            trans.Commit();
                            Response.Redirect("~/SignIn.aspx",false);

                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            throw;
                        }
                    }
                }
            
            //string cs = ConfigurationManager.ConnectionStrings["LearnData"].ConnectionString;
                //    using (SqlConnection con = new SqlConnection(cs))
                //    {

                //        SqlCommand cmduser =
                //            new SqlCommand("Select Username from Users where username ='******'", con);
                //    SqlDataAdapter sda = new SqlDataAdapter(cmduser);
                //    DataTable dt = new DataTable();
                //    sda.Fill(dt);
                //        if (dt.Rows.Count == 0)
                //        {

                //            SqlCommand cmd =
                //                new SqlCommand(
                //                    " Insert into Users values ('" + txtusername.Text + "','" + txtPassword.Text +
                //                    "', '" +
                //                    txtEmail.Text + "','" + txtName.Text + "' , '" + "U" + "')", con);
                //            con.Open();
                //            cmd.ExecuteNonQuery();
                //            lblMsg.ForeColor = Color.Green;
                //            lblMsg.Text = "Registration Successfull";
                //            Response.Redirect("~/SignIn.aspx");
                //            con.Close();
                //        }
                //        else
                //        {
                //        lblMsg.ForeColor = Color.Red;
                //        lblMsg.Text = "Username Already Exists In Our Database";
                //    }
                //}
            }
            else
            {
                lblMsg.ForeColor = Color.Red;
                lblMsg.Text = "Password Do Not Match";
            }
        }
        else
        {
            lblMsg.ForeColor=Color.Red;
            lblMsg.Text = "All Fields Are Required";

        }
    }
Beispiel #12
0
    public static List<Learning> LoadChapters(int? getchaptersperday)
    {
        List<Learning> resultList;
        using (dbExtranetEntities db = new dbExtranetEntities())
        {

            resultList = db.Beg_Alphabet.Join(db.Beg_Translate, x => x.Id, y => y.begAlphabetId, (x, y) => new {x, y})
                .Join(db.Beg_Files, a => a.x.Id, b => b.BegAlphabetId, (a, b) => new {a, b})
                .Take(Convert.ToInt32(getchaptersperday))
                .Select(xy => new Learning()
                {
                    BegPrId = xy.a.x.Id,
                    CapitalLetters = xy.a.x.CapitalLetter,
                    SmallLetters = xy.a.x.SmallLetter,
                    Kannada = xy.a.y.Kannada,
                    Hindi = xy.a.y.Hindi,
                    Play = xy.b.Play
                }).ToList();
        }
        return resultList;
    }
Beispiel #13
0
    public static List<Learning> LoadQuizWithRandomSet(int? getchaptersperday, Int32 id, string username)
    {
        // int? nam=0;
        List<Learning> resultList = null;
        List<Learning> resultRandomList = null;
        List<Learning> resultList1 = null;
        Int32 i = 0;
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            List<int?> randomnum = RandomService.GenerateRandom();
            var testid = db.Beg_UserTest.Where(x => x.Username == username).Select(x => x.Course).Distinct().ToList();


            //takequestion
            resultList =
                db.Beg_Test.AsNoTracking()
                    .Join(db.Beg_Translate, x => x.BegAlphabetId, y => y.begAlphabetId, (x, y) => new {x, y})
                    .Join(db.Beg_Files, a => a.x.BegAlphabetId, b => b.BegAlphabetId, (a, b) => new {a, b})
                    // .Take(Convert.ToInt32(getchaptersperday))
                    .Where(x => x.a.x.BegAlphabetId == id).Take(1)
                    .Select(xy => new Learning()
                    {
                        idName = xy.a.x.Id,
                        BegPrId = xy.a.x.BegAlphabetId,
                        Kannada = xy.a.y.Kannada,
                        Hindi = xy.a.y.Hindi,
                        Play = xy.b.Play
                    }).ToList();
            //   nam = resultList[0].idName;
            resultRandomList =
                db.Beg_Alphabet.Join(db.Beg_Translate, x => x.Id, y => y.begAlphabetId, (x, y) => new {x, y})
                    .Join(db.Beg_Files, a => a.x.Id, b => b.BegAlphabetId, (a, b) => new {a, b})
                    .Join(db.Beg_Test, aa => aa.a.x.Id, bb => bb.BegAlphabetId, (aa, bb) => new {aa, bb})
                    .Take(Convert.ToInt32(getchaptersperday))
                    .Where(xx => randomnum.Contains(xx.aa.a.x.Id))
                    .Select(xy => new Learning()
                    {
                        idName = xy.bb.Id,
                        BegPrId = xy.aa.a.x.Id,
                        Kannada = xy.aa.a.y.Kannada,
                        Hindi = xy.aa.a.y.Hindi,
                        Play = xy.aa.b.Play
                    }).ToList();


            resultList1 = resultList.Union(resultRandomList).ToList();

        }
        return resultList1;
    }
Beispiel #14
0
    public static void AnswerGiven(int testid, string username, int begid)
    {
        using (dbExtranetEntities db = new dbExtranetEntities())
        {
            using (var trans = db.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
            {
                try
                {
                    var getquestioninfo = db.Beg_Test.SingleOrDefault(x => x.Id == testid);
                    var getAnstext = db.Beg_Alphabet.SingleOrDefault(x => x.Id == begid);
                    var testgiven = new Beg_UserTest()
                    {
                        BegAlphabetId = getquestioninfo.BegAlphabetId,
                        Username = username,
                        Course = testid,
                        Day = getquestioninfo.Day,
                        Question = getquestioninfo.Question,
                        QuestionNumber = getquestioninfo.QuestionNumber,
                        Answer = getAnstext.CapitalLetter

                    };
                    db.Beg_UserTest.Add(testgiven);
                    db.SaveChanges();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }

            }
        }
    }
Beispiel #15
0
    public static bool ResultPassorFail(string testday, string username)
    {
        using (dbExtranetEntities db = new dbExtranetEntities())
        {

            bool res = false;
            var results = db.Beg_UserTest.AsNoTracking().Where(x => x.Day == testday && x.Username == username).ToList();

            foreach (var result in results)
            {
                if (result.Answer == result.Question)
                {
                    res = true;
                }
                else
                {
                    res = false;
                    break;
                }
            }
            return res;
        }

    }
Beispiel #16
0
 public static int GetquestAnswered(string testid, string username)
 {
     int? result;
     using (dbExtranetEntities db = new dbExtranetEntities())
     {
         result =
             db.Beg_UserTest.AsNoTracking()
                 .Where(x => x.Username == username && x.Day == testid.ToString())
                 .ToList()
                 .Count();
     }
     return result.GetValueOrDefault();
 }
Beispiel #17
0
 public static int GetCoursemst(int testid)
 {
     int? result;
     using (dbExtranetEntities db = new dbExtranetEntities())
     {
         //var getquestioninfo = db.Beg_Test.SingleOrDefault(x => x.Id == testid);
         result = db.CourseMsts.AsNoTracking().Where(x => x.Lesson == testid).Select(x => x.Topics).SingleOrDefault();
     }
     return result.GetValueOrDefault();
 }