示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (irQmDbContext db = new irQmDbContext())
                {
                    var user = db.User.First(u => u.UserName == txtusername.Text);
                    user.Email  = txtEmail.Text;
                    user.Name   = txtName.Text;
                    user.Family = txtFamily.Text;
                    user.Role   = (Roles.RoleSNames)comboRole.SelectedValue;
                    if (user.Role.ToString() == "limited")
                    {
                        btnSelectUser.Visible = false;
                    }
                    else
                    {
                        btnSelectUser.Visible = true;
                    }

                    db.SaveChanges();
                    lblMessage.Text = "عملیات تغییر اطلاعات با موفقیت انجام شد";
                }
            }
            catch { lblMessage.Text = "مشکلی در تغییر اطلاعات به وجود آمده است"; }
        }
示例#2
0
        private void btnRegister_Click(object sender, System.EventArgs e)
        {
            try
            {
                using (irQmDbContext db = new irQmDbContext())
                {
                    if (db.Lessons.Any(l => l.LessonName == txtLessonname.Text))
                    {
                        lblResult.Text      = "این درس قبلا ثبت شده است";
                        lblResult.ForeColor = Color.Red;
                        return;
                    }
                    if (string.IsNullOrEmpty(txtLessonname.Text.Trim()))
                    {
                        lblResult.Text      = "نام باید وارد شود";
                        lblResult.ForeColor = Color.Red;
                        return;
                    }

                    var lesson = new Lesson();
                    lesson.LessonName  = txtLessonname.Text.Trim();
                    lesson.Description = txtDesc.Text.Trim();
                    db.Lessons.Add(lesson);

                    db.SaveChanges();
                    lblResult.Text      = "ثبت با موفقیت انجام شد";
                    lblResult.ForeColor = Color.Green;
                }
            }
            catch
            {
                lblResult.Text      = "ایرادی در ثبت به وجود آمده است";
                lblResult.ForeColor = Color.Red;
            }
        }
示例#3
0
        private void Btnentire_Click(object sender, EventArgs e)
        {
            User user = new User();

            user.Email    = txtEmail.Text.Trim();
            user.UserName = txtusername.Text.ToLower().Trim();
            user.Password = txtpass.Text.GetHashCode().ToString();
            user.Name     = txtName.Text.Trim();
            user.Family   = txtFamily.Text;
            user.Role     = comboRole.SelectedItem.ToString() == "مدیر" ? Roles.RoleSNames.Admin: Roles.RoleSNames.limited;
            user.UserId   = Guid.NewGuid().ToString() + user.UserName.ToString().Substring(5);
            try
            {
                using (irQmDbContext db = new irQmDbContext())
                {
                    if (db.User.Any(u => u.UserName == txtusername.Text))
                    {
                        lblResult.Text      = "این نام کاربری قبلا ثبت شده است";
                        lblResult.ForeColor = Color.Red;
                        return;
                    }
                    db.User.Add(user);
                    db.SaveChanges();
                    lblResult.Text      = "ثبت انجام شد";
                    lblResult.ForeColor = Color.Green;
                    //linklogin.Visible = true;
                }
            }catch (Exception x)
            {
                lblResult.Text      = "ایرادی در ثبت به وجود آمده است";
                lblResult.ForeColor = Color.Red;
            }
        }
示例#4
0
        private bool RegisterMultiChoices(irQmDbContext db)
        {
            if (ucMultiOption1.Options.Count(o => o.IsTrue) < 1)
            {
                lblMessage.Text      = "گزینه یا گزینه های درست مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }

            var q = new MultiChoices();

            q.Id   = Guid.NewGuid().ToString();
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            {
                var tag = new Tag();
                tag.Value = tg;
                db.Tags.Add(tag);
            }
            foreach (var t in tagsInBox)
            {
                TagInQuestion <MultiChoices> tim = new TagInQuestion <MultiChoices>();
                tim.QuestionId = q.Id;
                tim.TagId      = t;
                db.TagInMultichoices.Add(tim);
            }
            var options = ucMultiOption1.Options;

            foreach (Option o in options)
            {
                o.MultiChoicesId = q.Id;
                db.Option.Add(o);
            }
            q.LessonName      = comboLesson.Text.Trim();
            q.CreatorUserId   = BaseCodes.Utilities.Globals.CurrentUser.UserId;
            q.MultiSelections = ucMultiOption1.MultiSelect;
            db.MultiChoicesQuestions.Add(q);

            db.SaveChanges();


            var newOptions = new List <Option>();

            for (var i = 0; i < ucMultiOption1.Options.Count; i++)
            {
                newOptions.Add(new Option());
            }
            ucMultiOption1.New(newOptions, ucMultiOption1.MultiSelect);
            return(true);
        }
示例#5
0
 private void ChangePassword(string password)
 {
     using (irQmDbContext db = new irQmDbContext())
     {
         var usr = db.User.First(u => u.UserId == user.UserId);
         usr.Password = password.GetHashCode().ToString();
         db.SaveChanges();
     }
     lblMessage.ForeColor = Color.LimeGreen;
     lblMessage.Text      = "عملیات تغییر رمز با موفقیت انجام شد";
 }
示例#6
0
        private bool RegisterTrueOrFalse(irQmDbContext db)
        {
            if (!ucTrueFalseAnswer1.isTrue && !ucTrueFalseAnswer1.isFalse)
            {
                lblMessage.Text      = "گزینه درست مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = new TFQuestion();

            q.Id   = Guid.NewGuid().ToString();
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            {
                var tag = new Tag();
                tag.Value = tg;
                db.Tags.Add(tag);
            }
            foreach (var t in tagsInBox)
            {
                TagInQuestion <TFQuestion> titf = new TagInQuestion <TFQuestion>();
                titf.QuestionId = q.Id;
                titf.TagId      = t;
                db.TagInTfQuestion.Add(titf);
            }
            //var to= new TFOption();

            //to.IsTrue = ucTrueFalseAnswer1.isTrue;
            //to.Id = Guid.NewGuid().ToString();
            //var fo = new TFOption();
            //fo.IsTrue = ucTrueFalseAnswer1.isFalse;
            //fo.Id = Guid.NewGuid().ToString();
            q.TrueOption  = ucTrueFalseAnswer1.isTrue;
            q.FalseOption = ucTrueFalseAnswer1.isFalse;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;

            db.TFQuestions.Add(q);

            db.SaveChanges();


            ucTrueFalseAnswer1.New();
            ucTrueFalseAnswer1.isTrue = true;
            return(true);
        }
示例#7
0
        private bool RegisterShortAnswerQuestion(irQmDbContext db)
        {
            if (ucShortAnswer1.StringList.Count == 0)
            {
                lblMessage.Text      = "جواب مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = new ShortAnswer();

            q.Id   = Guid.NewGuid().ToString();
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            {
                var tag = new Tag();
                tag.Value = tg;
                db.Tags.Add(tag);
            }
            foreach (var t in tagsInBox)
            {
                TagInQuestion <ShortAnswer> tagInQuestion = new TagInQuestion <ShortAnswer>();
                tagInQuestion.QuestionId = q.Id;
                tagInQuestion.TagId      = t;
                db.TagInShortAnswer.Add(tagInQuestion);
            }
            q.Answer = ucShortAnswer1.StringList;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;


            db.ShortAnswerQustions.Add(q);

            db.SaveChanges();


            ucShortAnswer1.New(new List <StringItem> {
                new StringItem(1), new StringItem(2), new StringItem(3)
            });


            return(true);
        }
示例#8
0
        private bool RegisterPracticalQuestion(irQmDbContext db)
        {
            var list = ucPracticalAnswer1.CheckList;

            if (list.Count == 0)
            {
                lblMessage.Text      = "چک لیست خالی است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = new Practical();

            q.Id   = Guid.NewGuid().ToString();
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            {
                var tag = new Tag();
                tag.Value = tg;
                db.Tags.Add(tag);
            }
            foreach (var t in tagsInBox)
            {
                TagInQuestion <Practical> tagInQuestion = new TagInQuestion <Practical>();
                tagInQuestion.QuestionId = q.Id;
                tagInQuestion.TagId      = t;
                db.TagInPractical.Add(tagInQuestion);
            }
            q.CheckList = list;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;

            db.PracticalQuestions.Add(q);

            db.SaveChanges();

            ucPracticalAnswer1.New(new List <StringItem>()
            {
                new StringItem(1), new StringItem(2), new StringItem(3)
            });
            return(true);
        }
示例#9
0
        private bool RegisterPuzzleQuestion(irQmDbContext db)
        {
            var pairs = ucPuzzleAnswer1.StringPairs;

            if (pairs.Count == 0)
            {
                lblMessage.Text      = "جواب مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = new Puzzle();

            q.Id   = Guid.NewGuid().ToString();
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            {
                var tag = new Tag();
                tag.Value = tg;
                db.Tags.Add(tag);
            }
            foreach (var t in tagsInBox)
            {
                TagInQuestion <Puzzle> tagInQuestion = new TagInQuestion <Puzzle>();
                tagInQuestion.QuestionId = q.Id;
                tagInQuestion.TagId      = t;
                db.TagInPuzzle.Add(tagInQuestion);
            }
            q.Pairs = pairs;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;

            db.PuzzleQuestions.Add(q);

            db.SaveChanges();

            ucPuzzleAnswer1.New();
            return(true);
        }
示例#10
0
        private bool RegisterTrueOrFalse(irQmDbContext db)
        {
            var saveInDb = false;

            if (!ucTrueFalseAnswer1.isTrue && !ucTrueFalseAnswer1.isFalse)
            {
                lblMessage.Text      = "گزینه درست مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = (TFQuestion)Question;

            if (db.TFQuestions.Contains(q))
            {
                saveInDb = true;
                db.TFQuestions.Remove(db.TFQuestions.First(qu => qu.Id == q.Id));
                db.SaveChanges();
            }

            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            //if (saveInDb)
            //{
            //    foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            //    {
            //        var tag = new Tag();
            //        tag.Value = tg;
            //        db.Tags.Add(tag);

            //    }
            //    foreach (var t in tagsBox1.Tags)
            //    {
            //        TagInQuestion<TFQuestion> titf = new TagInQuestion<TFQuestion>();
            //        titf.QuestionId = q.Id;
            //        titf.TagId = t;
            //        db.TagInTfQuestion.Add(titf);
            //    }
            //}
            //else
            {
                var qtags = new List <TagInQuestion <TFQuestion> >();
                foreach (var t in tagsInBox)
                {
                    TagInQuestion <TFQuestion> tagInQuestion = new TagInQuestion <TFQuestion>();
                    tagInQuestion.QuestionId = q.Id;
                    tagInQuestion.TagId      = t;
                    qtags.Add(tagInQuestion);
                }
                q.Tags = qtags;
            }
            q.EditTime = DateTime.UtcNow;
            //var to= new TFOption();

            //to.IsTrue = ucTrueFalseAnswer1.isTrue;
            //to.Id = Guid.NewGuid().ToString();
            //var fo = new TFOption();
            //fo.IsTrue = ucTrueFalseAnswer1.isFalse;
            //fo.Id = Guid.NewGuid().ToString();
            q.TrueOption  = ucTrueFalseAnswer1.isTrue;
            q.FalseOption = ucTrueFalseAnswer1.isFalse;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;

            if (saveInDb)
            {
                foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
                {
                    var tag = new Tag();
                    tag.Value = tg;
                    db.Tags.Add(tag);
                }
                db.TFQuestions.Add(q);

                db.SaveChanges();
            }

            return(true);
        }
示例#11
0
        private bool RegisterMultiChoices(irQmDbContext db)
        {
            var saveInDb = false;

            if (ucMultiOption1.Options.Count(o => o.IsTrue) < 1)
            {
                lblMessage.Text      = "گزینه یا گزینه های درست مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = (MultiChoices)Question;

            if (db.MultiChoicesQuestions.Contains(q))
            {
                saveInDb = true;
                db.MultiChoicesQuestions.Remove(db.MultiChoicesQuestions.First(qu => qu.Id == q.Id));
                db.SaveChanges();
            }

            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            //if (saveInDb)
            //{
            //    foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            //    {
            //        var tag = new Tag();
            //        tag.Value = tg;
            //        db.Tags.Add(tag);

            //    }
            //    foreach (var t in tagsBox1.Tags)
            //    {
            //        TagInQuestion<MultiChoices> tim = new TagInQuestion<MultiChoices>();
            //        tim.QuestionId = q.Id;
            //        tim.TagId = t;
            //        db.TagInMultichoices.Add(tim);
            //    }
            //}
            //else
            {
                var qtags = new List <TagInQuestion <MultiChoices> >();
                foreach (var t in tagsInBox)
                {
                    TagInQuestion <MultiChoices> tagInQuestion = new TagInQuestion <MultiChoices>();
                    tagInQuestion.QuestionId = q.Id;
                    tagInQuestion.TagId      = t;
                    qtags.Add(tagInQuestion);
                }
                q.Tags = qtags;
            }
            q.EditTime = DateTime.UtcNow;
            var options = ucMultiOption1.Options;

            foreach (Option o in options)
            {
                o.MultiChoicesId = q.Id;
                db.Option.Add(o);
            }
            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = BaseCodes.Utilities.Globals.CurrentUser.UserId;

            if (saveInDb)
            {
                foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
                {
                    var tag = new Tag();
                    tag.Value = tg;
                    db.Tags.Add(tag);
                }
                db.MultiChoicesQuestions.Add(q);

                db.SaveChanges();
            }


            return(true);
        }
示例#12
0
        private bool RegisterLongAnswerQuestion(irQmDbContext db)
        {
            var saveInDb = false;

            if (string.IsNullOrEmpty(ucLongAnswer1.Answer))
            {
                lblMessage.Text      = "جواب مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = (LongAnswer)Question;

            if (db.LongAnswerQuestions.Contains(q))
            {
                saveInDb = true;
                db.LongAnswerQuestions.Remove(db.LongAnswerQuestions.First(qu => qu.Id == q.Id));
                db.SaveChanges();
            }
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            //if (saveInDb)
            //{
            //    foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            //    {
            //        var tag = new Tag();
            //        tag.Value = tg;
            //        db.Tags.Add(tag);

            //    }
            //    foreach (var t in tagsBox1.Tags)
            //    {
            //        TagInQuestion<LongAnswer> tagInQuestion = new TagInQuestion<LongAnswer>();
            //        tagInQuestion.QuestionId = q.Id;
            //        tagInQuestion.TagId = t;
            //        db.TagInLongAnswer.Add(tagInQuestion);
            //    }
            //}
            //else
            {
                var qtags = new List <TagInQuestion <LongAnswer> >();
                foreach (var t in tagsInBox)
                {
                    TagInQuestion <LongAnswer> tagInQuestion = new TagInQuestion <LongAnswer>();
                    tagInQuestion.QuestionId = q.Id;
                    tagInQuestion.TagId      = t;
                    qtags.Add(tagInQuestion);
                }
                q.Tags = qtags;
            }
            q.EditTime = DateTime.UtcNow;
            q.Answer   = ucLongAnswer1.Answer;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;
            if (saveInDb)
            {
                foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
                {
                    var tag = new Tag();
                    tag.Value = tg;
                    db.Tags.Add(tag);
                }
                db.LongAnswerQuestions.Add(q);

                db.SaveChanges();
            }



            return(true);
        }
示例#13
0
        private bool RegisterPracticalQuestion(irQmDbContext db)
        {
            var saveInDb = false;
            var list     = ucPracticalAnswer1.CheckList;

            if (list.Count == 0)
            {
                lblMessage.Text      = "چک لیست خالی است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = (Practical)Question;

            if (db.PracticalQuestions.Contains(q))
            {
                saveInDb = true;
                db.PracticalQuestions.Remove(db.PracticalQuestions.First(qu => qu.Id == q.Id));
                db.SaveChanges();
            }

            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            //if (saveInDb)
            //{
            //    foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            //    {
            //        var tag = new Tag();
            //        tag.Value = tg;
            //        db.Tags.Add(tag);

            //    }



            //    foreach (var t in tagsBox1.Tags)
            //    {
            //        TagInQuestion<Practical> tagInQuestion = new TagInQuestion<Practical>();
            //        tagInQuestion.QuestionId = q.Id;
            //        tagInQuestion.TagId = t;
            //        db.TagInPractical.Add(tagInQuestion);
            //    }
            //}
            //else
            {
                var qtags = new List <TagInQuestion <Practical> >();
                foreach (var t in tagsInBox)
                {
                    TagInQuestion <Practical> tagInQuestion = new TagInQuestion <Practical>();
                    tagInQuestion.QuestionId = q.Id;
                    tagInQuestion.TagId      = t;
                    qtags.Add(tagInQuestion);
                }
                q.Tags = qtags;
            }
            q.EditTime  = DateTime.UtcNow;
            q.CheckList = list;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;
            if (saveInDb)
            {
                foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
                {
                    var tag = new Tag();
                    tag.Value = tg;
                    db.Tags.Add(tag);
                }
                db.PracticalQuestions.Add(q);

                db.SaveChanges();
            }

            return(true);
        }