Пример #1
0
 private void bind(string id)
 {
     if (id.Equals("0"))
     {
         grdMcqMater.DataSource = null;
     }
     else
     {
         obj1 = new McqMasterDataManager();
         grdMcqMater.DataSource = obj1.GetMcqListwithPaperID(Convert.ToInt16(id));
     }
     grdMcqMater.DataBind();
 }
Пример #2
0
        protected void grdMcqMater_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Delete_Question")
            {
                int         rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                GridViewRow grid     = grdMcqMater.Rows[rowIndex];
                int         id       = Convert.ToInt32(((Label)grid.FindControl("lblID")).Text);

                obj1 = new McqMasterDataManager();
                obj1.DeleteMcqDetail(id);
                Clear();
                bind(ddlYearPaper.SelectedValue.ToString());
                msgbox("Mcq Deleted successfully!!!");
            }
        }
Пример #3
0
        protected void btnAddAnswer_Click(object sender, EventArgs e)
        {
            double timeValue;
            string filename, extension, filepath;

            if (!opt1.Checked && !opt2.Checked && !opt3.Checked && !opt4.Checked)
            {
                msgbox("Select atleast one correct Answer");
                return;
            }

            if (CommonAnswer.HasFile || !string.IsNullOrEmpty(CommonAns.Text))
            {
                if (!string.IsNullOrEmpty(txtAnswer1.Text) || !string.IsNullOrEmpty(txtAnswer2.Text) || !string.IsNullOrEmpty(txtAnswer3.Text) || !string.IsNullOrEmpty(txtAnswer4.Text))
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'For Common Answer image no need of answer text or image'});", true);
                    return;
                }
                if (!string.IsNullOrEmpty(lblAnswer1.Text) || AnswerImage1.HasFile)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'For Common Answer image no need of answer text or image'});", true);
                    return;
                }
                if (!string.IsNullOrEmpty(lblAnswer2.Text) || AnswerImage2.HasFile)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'For Common Answer image no need of answer text or image'});", true);
                    return;
                }
                if (!string.IsNullOrEmpty(lblAnswer3.Text) || AnswerImage3.HasFile)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'For Common Answer image no need of answer text or image'});", true);
                    return;
                }
                if (!string.IsNullOrEmpty(lblAnswer4.Text) || AnswerImage4.HasFile)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'For Common Answer image no need of answer text or image'});", true);
                    return;
                }
            }

            if (!CommonAnswer.HasFile && string.IsNullOrEmpty(CommonAns.Text))
            {
                if (!string.IsNullOrEmpty(txtAnswer1.Text) && !string.IsNullOrEmpty(txtAnswer2.Text) && !string.IsNullOrEmpty(txtAnswer3.Text) && !string.IsNullOrEmpty(txtAnswer4.Text))
                {
                }
                else
                {
                    if (string.IsNullOrEmpty(lblAnswer1.Text) && !AnswerImage1.HasFile)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'Answer can be either image or text or common image'});", true);
                        //Tell.text("Client details validation fails", this);
                        Page.Validate("ValidationGroup2");
                        return;
                    }
                    if (string.IsNullOrEmpty(lblAnswer2.Text) && !AnswerImage2.HasFile)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'Answer can be either image or text or common image'});", true);
                        //Tell.text("Client details validation fails", this);
                        Page.Validate("ValidationGroup2");
                        return;
                    }
                    if (string.IsNullOrEmpty(lblAnswer3.Text) && !AnswerImage3.HasFile)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'Answer can be either image or text or common image'});", true);
                        //Tell.text("Client details validation fails", this);
                        Page.Validate("ValidationGroup2");
                        return;
                    }
                    if (string.IsNullOrEmpty(lblAnswer3.Text) && !AnswerImage3.HasFile)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "swal({title:'',text:'Answer can be either image or text or common image'});", true);
                        //Tell.text("Client details validation fails", this);
                        Page.Validate("ValidationGroup2");
                        return;
                    }
                }
            }
            if (CommonAnswer.HasFile || !string.IsNullOrEmpty(CommonAns.Text))
            {
                AnswerType.Value = "NONE";
            }
            else
            {
                if (!string.IsNullOrEmpty(txtAnswer1.Text))
                {
                    AnswerType.Value = "TEXT";
                }
                else
                {
                    AnswerType.Value = "IMAGE";
                }
            }



            if (QuestionImage.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(QuestionImage.PostedFile.FileName);
                extension = Path.GetExtension(QuestionImage.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/QuestionImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    QuestionImage.PostedFile.SaveAs(filepath);
                }
                QuestionImageLink.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (QuestionImage2.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(QuestionImage2.PostedFile.FileName);
                extension = Path.GetExtension(QuestionImage2.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/QuestionImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    QuestionImage2.PostedFile.SaveAs(filepath);
                }
                QuestionImageLink2.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (QuestionAudio.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(QuestionAudio.PostedFile.FileName);
                extension = Path.GetExtension(QuestionAudio.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/QuestionAudio") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    QuestionAudio.PostedFile.SaveAs(filepath);
                }
                QuestionAudioLink.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (SolutionImage.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(SolutionImage.PostedFile.FileName);
                extension = Path.GetExtension(SolutionImage.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/SolutionImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    SolutionImage.PostedFile.SaveAs(filepath);
                }
                SolutionImageLink.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (HintAudio.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(HintAudio.PostedFile.FileName);
                extension = Path.GetExtension(HintAudio.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/SolutionAudio") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    HintAudio.PostedFile.SaveAs(filepath);
                }
                HintAudioLink.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (HintVideo.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(HintVideo.PostedFile.FileName);
                extension = Path.GetExtension(HintVideo.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/SolutionVideo") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    HintVideo.PostedFile.SaveAs(filepath);
                }
                VideoLink.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (document.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(document.PostedFile.FileName);
                extension = Path.GetExtension(document.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/SolutionDocument") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    document.PostedFile.SaveAs(filepath);
                }
                SupportedDocumentLink.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (document2.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(document2.PostedFile.FileName);
                extension = Path.GetExtension(document2.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/SolutionDocument") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    document2.PostedFile.SaveAs(filepath);
                }
                SupportedDocumentLink2.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (document3.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(document3.PostedFile.FileName);
                extension = Path.GetExtension(document3.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/SolutionDocument") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    document3.PostedFile.SaveAs(filepath);
                }
                SupportedDocumentLink3.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (CommonAnswer.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(CommonAnswer.PostedFile.FileName);
                extension = Path.GetExtension(CommonAnswer.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/CommonAnswer") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    CommonAnswer.PostedFile.SaveAs(filepath);
                }
                CommonAns.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (AnswerImage1.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(AnswerImage1.PostedFile.FileName);
                extension = Path.GetExtension(AnswerImage1.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/AnswerImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    AnswerImage1.PostedFile.SaveAs(filepath);
                }
                lblAnswer1.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (AnswerImage2.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(AnswerImage2.PostedFile.FileName);
                extension = Path.GetExtension(AnswerImage2.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/AnswerImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    AnswerImage2.PostedFile.SaveAs(filepath);
                }
                lblAnswer2.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (AnswerImage3.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(AnswerImage3.PostedFile.FileName);
                extension = Path.GetExtension(AnswerImage3.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/AnswerImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    AnswerImage3.PostedFile.SaveAs(filepath);
                }
                lblAnswer3.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }
            if (AnswerImage4.HasFile)
            {
                filename  = Path.GetFileNameWithoutExtension(AnswerImage4.PostedFile.FileName);
                extension = Path.GetExtension(AnswerImage4.PostedFile.FileName);
                filepath  = Server.MapPath("~/Upload/AnswerImage") + "\\" + filename + DateTime.Now.ToString("_ddMMyyyyhhmmss") + extension;

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                else
                {
                    AnswerImage4.PostedFile.SaveAs(filepath);
                }
                lblAnswer4.Text = filepath.Substring(filepath.LastIndexOf("\\") + 1);
            }

            obj = new McqMaster();
            obj.TopicwisePaperID = Convert.ToInt16(ddlTopicPaper.SelectedValue);
            obj.YearwisePaperID  = Convert.ToInt16(ddlYearPaper.SelectedValue);
            obj.QuestionText1    = txtText1.Text;
            obj.QuestionText2    = txtQuestionText2.Text;
            obj.HintText         = txtSolution.Text;
            obj.VideoUrl         = txtVideoUrl.Text;
            obj.Marks            = Convert.ToInt16("0" + txtMarks.Text);
            if (double.TryParse(txtTime.Text, out timeValue))
            {
                TimeSpan time = TimeSpan.FromSeconds(timeValue);
                obj.TimeToSolve = time;
            }
            else
            {
                msgbox("Invalid 'Time To Solve' value");
                return;
            }
            //obj.IsVisible = chkVisible.Checked;
            obj.CreatedBy = 1;
            obj.UpdatedBy = 1;
            obj.McqID     = Convert.ToInt16(lblMcqID.Text);
            if (lblMcqID.Text.Equals("-1"))
            {
                obj.QuestionImageLink      = QuestionImageLink.Text;
                obj.QuestionImage2         = QuestionImageLink2.Text;
                obj.QuestionAudioLink      = QuestionAudioLink.Text;
                obj.SolutionImageLink      = SolutionImageLink.Text;
                obj.SolutionAudioLink      = HintAudioLink.Text;
                obj.VideoLink              = VideoLink.Text;
                obj.SupportedDocumentLink  = SupportedDocumentLink.Text;
                obj.SupportedDocumentLink2 = SupportedDocumentLink2.Text;
                obj.SupportedDocumentLink3 = SupportedDocumentLink3.Text;
                obj.CommonAnswerImage      = CommonAns.Text;
                obj1 = new McqMasterDataManager();
                obj1.AddMcqDetail(obj);

                //Adding Answer 1
                obj2             = new AnswerMaster();
                obj2.Answer      = txtAnswer1.Text;
                obj2.SN          = "a";
                obj2.McqID       = 0;
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer1.Text;
                obj2.Correct     = opt1.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.AddAnswerDetail(obj2);

                obj2             = new AnswerMaster();
                obj2.Answer      = txtAnswer2.Text;
                obj2.SN          = "b";
                obj2.McqID       = 0;
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer2.Text;
                obj2.Correct     = opt2.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.AddAnswerDetail(obj2);

                obj2             = new AnswerMaster();
                obj2.Answer      = txtAnswer3.Text;
                obj2.SN          = "c";
                obj2.McqID       = 0;
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer3.Text;
                obj2.Correct     = opt3.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.AddAnswerDetail(obj2);

                obj2             = new AnswerMaster();
                obj2.Answer      = txtAnswer4.Text;
                obj2.SN          = "d";
                obj2.McqID       = 0;
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer4.Text;
                obj2.Correct     = opt4.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.AddAnswerDetail(obj2);
                msgbox("Mcq Added successfully!!!");
            }
            else
            {
                obj.QuestionImageLink      = QuestionImageLink.Text;
                obj.QuestionImage2         = QuestionImageLink2.Text;
                obj.QuestionAudioLink      = QuestionAudioLink.Text;
                obj.SolutionImageLink      = SolutionImageLink.Text;
                obj.SolutionAudioLink      = HintAudioLink.Text;
                obj.VideoLink              = VideoLink.Text;
                obj.SupportedDocumentLink  = SupportedDocumentLink.Text;
                obj.SupportedDocumentLink2 = SupportedDocumentLink2.Text;
                obj.SupportedDocumentLink3 = SupportedDocumentLink3.Text;
                obj.CommonAnswerImage      = CommonAns.Text;
                obj1 = new McqMasterDataManager();
                obj1.UpdateMcqDetail(obj);

                //Adding Answer 1
                obj2             = new AnswerMaster();
                obj2.McqAnswerID = Convert.ToInt16("0" + lblAnswerID1.Text);
                obj2.Answer      = txtAnswer1.Text;
                obj2.SN          = "a";
                obj2.McqID       = Convert.ToInt16("0" + lblMcqID.Text);
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer1.Text;
                obj2.Correct     = opt1.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.UpdateAnswerDetail(obj2);

                obj2             = new AnswerMaster();
                obj2.McqAnswerID = Convert.ToInt16("0" + lblAnswerID2.Text);
                obj2.Answer      = txtAnswer2.Text;
                obj2.SN          = "b";
                obj2.McqID       = Convert.ToInt16("0" + lblMcqID.Text);
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer2.Text;
                obj2.Correct     = opt2.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.UpdateAnswerDetail(obj2);

                obj2             = new AnswerMaster();
                obj2.Answer      = txtAnswer3.Text;
                obj2.McqAnswerID = Convert.ToInt16("0" + lblAnswerID3.Text);
                obj2.SN          = "c";
                obj2.McqID       = Convert.ToInt16("0" + lblMcqID.Text);
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer3.Text;
                obj2.Correct     = opt3.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.UpdateAnswerDetail(obj2);

                obj2             = new AnswerMaster();
                obj2.McqAnswerID = Convert.ToInt16("0" + lblAnswerID4.Text);
                obj2.Answer      = txtAnswer4.Text;
                obj2.SN          = "d";
                obj2.McqID       = Convert.ToInt16("0" + lblMcqID.Text);
                obj2.AnswerType  = AnswerType.Value;
                obj2.AnswerImage = lblAnswer4.Text;
                obj2.Correct     = opt4.Checked ? 1 : 0;
                obj3             = new AnswerMasterDataManager();
                obj3.UpdateAnswerDetail(obj2);
                msgbox("Mcq updated successfully!!!");
            }
            Clear();
            bind(ddlYearPaper.SelectedValue.ToString());
        }