示例#1
0
    protected void btnprint_Click(object sender, EventArgs e)
    {
        int  FormID = int.Parse(Request.QueryString["frmID"]);
        int  Year   = int.Parse(Request.QueryString["year"]);
        Guid GUID   = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

        RegisterUser_CreatedUser(null, null);
        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            AnswersForm answfrm = context.AnswersForm.FirstOrDefault(frm => frm.QuestionFormID == FormID && frm.Year == Year && frm.UserID == GUID);

            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load(Server.MapPath("CrystalReport.rpt"));

            /* setDbInfo(cryRpt, ConfigurationManager.AppSettings["server"],
             *   ConfigurationManager.AppSettings["Db"],
             *   ConfigurationManager.AppSettings["UserID"],
             *   ConfigurationManager.AppSettings["Password"]);*/
            cryRpt.Refresh();
            cryRpt.SetParameterValue("frmid", answfrm.ID);
            this.Response.Charset         = "UTF-8";
            this.Response.ContentEncoding = System.Text.Encoding.UTF8;
            this.Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            cryRpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.RichText, this.Response, true, "Report");
        }
    }
示例#2
0
 private void BindGrid()
 {
     using (QuestionaireEntities context = new QuestionaireEntities())
     {
         GridView1.DataSource = context.QuestionsForms.Where(qfrm => (qfrm.idDeleted != true || qfrm.idDeleted == null)).ToList();
         GridView1.DataBind();
     }
 }
示例#3
0
 private void BindGrid()
 {
     using (QuestionaireEntities context = new QuestionaireEntities())
     {
         int            FormID = int.Parse(Request.QueryString["frmID"]);
         QuestionsForms qfrm   = context.QuestionsForms.First(frm => frm.ID == FormID);
         txtformName.Text       = qfrm.FormName;
         txtClarification.Text  = qfrm.Clarification;
         grdQuestion.DataSource = context.Questions.Where(qs => qs.FormID == FormID && (qs.IsDeleted != true || qs.IsDeleted == null)).ToList();
         grdQuestion.DataBind();
     }
 }
示例#4
0
    protected void Unnamed_Click(object sender, EventArgs e)
    {
        LinkButton  chk    = (LinkButton)sender;
        GridViewRow gr     = (GridViewRow)chk.Parent.Parent;
        int         formid = int.Parse(grdQuestion.DataKeys[gr.RowIndex].Value.ToString());

        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            context.Questions.First(qfrm => qfrm.ID == formid).IsDeleted = true;
            context.SaveChanges();
        }
        BindGrid();
    }
示例#5
0
    private void BindGrid()
    {
        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            int  FormID = int.Parse(Request.QueryString["frmID"]);
            Guid GUID   = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
            GridView1.DataSource = context.AnswersForm.Where(frm => frm.QuestionFormID == FormID && frm.UserID == GUID)
                                   .Select(ans => new { Id = ans.QuestionsForms.ID, FormName = ans.QuestionsForms.FormName, Year = ans.Year })
                                   .ToList();


            GridView1.DataBind();
        }
    }
示例#6
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            int FormID = int.Parse(Request.QueryString["frmID"]);

            DateTimeFormatInfo DTFormat = new DateTimeFormatInfo();
            QuestionsForms     qfrm     = context.QuestionsForms.First(frm => frm.ID == FormID);
            qfrm.FormName      = txtformName.Text;
            qfrm.Clarification = txtClarification.Text;

            context.SaveChanges();
            Response.Redirect("Qformslist");
        }
    }
示例#7
0
    private void BindGrid()
    {
        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            int         FormID  = int.Parse(Request.QueryString["frmID"]);
            int         Year    = int.Parse(Request.QueryString["year"]);
            Guid        GUID    = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
            AnswersForm answfrm = context.AnswersForm.FirstOrDefault(frm => frm.QuestionFormID == FormID && frm.Year == Year && frm.UserID == GUID);
            if (answfrm == null)
            {
                QuestionsForms qfrm = context.QuestionsForms.First(frm => frm.ID == FormID);
                txtformName.Text = qfrm.FormName;

                grdQuestion.DataSource = context.Questions.Where(qs => qs.FormID == FormID && (qs.IsDeleted != true || qs.IsDeleted == null)).ToList();
                grdQuestion.DataBind();
                grdAnswers.Visible  = false;
                grdQuestion.Visible = true;
            }
            else
            {
                txtAuditor.Text     = answfrm.AuditorName;
                txtAuditorOn.Text   = answfrm.AuditorOnName;
                txtDate.Text        = answfrm.HijriDate;
                txtOpsCode.Text     = answfrm.OpsCode;
                txtOpsName.Text     = answfrm.OpsName;
                txtReviewer.Text    = answfrm.ReviewerName;
                txtReviewerOn.Text  = answfrm.ReviewerOnName;
                txtAuditSign.Text   = answfrm.Sign1;
                txtAuditonSign.Text = answfrm.Sign2;
                foreach (Questions row in context.Questions.Where(que => que.FormID == FormID).ToList())
                {
                    if (!context.Answers.Any(ans => ans.AnswerFormID == answfrm.ID && ans.QuestionID == row.ID))
                    {
                        Answers ans = new Answers();
                        ans.AnswerFormID = answfrm.ID;
                        ans.QuestionID   = row.ID;
                        context.Answers.Add(ans);
                        context.SaveChanges();
                    }
                }
                grdAnswers.DataSource = context.Answers.Where(ans => ans.AnswerFormID == answfrm.ID).Select(ans => new { Id = ans.ID, QuestionText = ans.Questions.QuestionText, Answer = ans.AnswerBody }).ToList();
                grdAnswers.DataBind();
                grdAnswers.Visible  = true;
                grdQuestion.Visible = false;
            }
        }
    }
示例#8
0
    protected void btnAddQst_Click(object sender, EventArgs e)
    {
        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            DateTimeFormatInfo DTFormat = new DateTimeFormatInfo();


            DTFormat = new System.Globalization.CultureInfo("ar-sa", false).DateTimeFormat;
            DTFormat.FullDateTimePattern = "dd/MM/yyyy";
            Questions dept = new Questions();
            string    x    = DateTime.Now.ToString("dd/MM/yyyy", DTFormat);
            dept.QuestionText = txtQuestion.Text;
            dept.FormID       = int.Parse(Request.QueryString["frmID"]);
            dept.IsDeleted    = false;
            context.Questions.Add(dept);
            context.SaveChanges();
            BindGrid();
        }
    }
示例#9
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            DateTimeFormatInfo DTFormat = new DateTimeFormatInfo();


            DTFormat = new System.Globalization.CultureInfo("ar-sa", false).DateTimeFormat;
            DTFormat.FullDateTimePattern = "dd/MM/yyyy";
            QuestionsForms dept = new QuestionsForms();
            dept.CreatedDate = DateTime.Now;
            string x = DateTime.Now.ToString("dd/MM/yyyy", DTFormat);
            dept.FormName      = txtformName.Text;
            dept.Clarification = txtClarification.Text;
            dept.idDeleted     = false;
            context.QuestionsForms.Add(dept);
            context.SaveChanges();
            Response.Redirect("QformUpdate?frmID=" + dept.ID);
        }
    }
示例#10
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        int         FormID = int.Parse(Request.QueryString["frmID"]);
        int         Year   = int.Parse(Request.QueryString["year"]);
        Guid        GUID   = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
        CultureInfo arSA   = new CultureInfo("ar-SA");

        arSA.DateTimeFormat.Calendar = new HijriCalendar();

        var day = Int32.Parse(string.Join("",
                                          txtDate.Text.Split('/')[2].Select(c => char.GetNumericValue(c))));   // 30
        var month = Int32.Parse(string.Join("",
                                            txtDate.Text.Split('/')[1].Select(c => char.GetNumericValue(c)))); // 12
        var year = Int32.Parse(string.Join("",
                                           txtDate.Text.Split('/')[0].Select(c => char.GetNumericValue(c))));


        using (QuestionaireEntities context = new QuestionaireEntities())
        {
            AnswersForm answfrm = context.AnswersForm.FirstOrDefault(frm => frm.QuestionFormID == FormID && frm.Year == Year && frm.UserID == GUID);
            if (answfrm == null)
            {
                answfrm                = new AnswersForm();
                answfrm.AuditorName    = txtAuditor.Text;
                answfrm.AuditorOnName  = txtAuditorOn.Text;
                answfrm.CreateDate     = DateTime.ParseExact(day.ToString() + "/" + month.ToString() + "/" + year.ToString(), "d/M/yyyy", arSA);
                answfrm.HijriDate      = txtDate.Text;
                answfrm.OpsCode        = txtOpsCode.Text;
                answfrm.OpsName        = txtOpsName.Text;
                answfrm.QuestionFormID = FormID;
                answfrm.ReviewerName   = txtReviewer.Text;
                answfrm.ReviewerOnName = txtReviewerOn.Text;
                answfrm.UserID         = GUID;
                answfrm.Year           = Year;
                answfrm.Sign1          = txtAuditSign.Text;
                answfrm.Sign2          = txtAuditonSign.Text;
                context.AnswersForm.Add(answfrm);
                context.SaveChanges();

                foreach (GridViewRow row in grdQuestion.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        Answers ans = new Answers();
                        ans.AnswerBody   = ((RadioButton)row.FindControl("rdyes")).Checked;
                        ans.AnswerFormID = answfrm.ID;
                        ans.QuestionID   = (int)grdQuestion.DataKeys[row.RowIndex].Value;
                        context.Answers.Add(ans);
                        context.SaveChanges();
                    }
                }
            }
            else
            {
                answfrm.AuditorName   = txtAuditor.Text;
                answfrm.AuditorOnName = txtAuditorOn.Text;

                answfrm.CreateDate     = DateTime.ParseExact(day.ToString() + "/" + month.ToString() + "/" + year.ToString(), "d/M/yyyy", arSA);
                answfrm.HijriDate      = txtDate.Text;
                answfrm.OpsCode        = txtOpsCode.Text;
                answfrm.OpsName        = txtOpsName.Text;
                answfrm.QuestionFormID = FormID;
                answfrm.ReviewerName   = txtReviewer.Text;
                answfrm.ReviewerOnName = txtReviewerOn.Text;
                answfrm.UserID         = GUID;
                answfrm.Year           = Year;
                answfrm.Sign1          = txtAuditSign.Text;
                answfrm.Sign2          = txtAuditonSign.Text;
                context.SaveChanges();
                foreach (GridViewRow row in grdAnswers.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        int     ansID = (int)grdAnswers.DataKeys[row.RowIndex].Value;
                        Answers ans   = context.Answers.First(answ => answ.ID == ansID);

                        ans.AnswerBody   = ((RadioButton)row.FindControl("rdyes")).Checked;
                        ans.AnswerFormID = answfrm.ID;
                        context.SaveChanges();
                    }
                }
            }

            //  Response.Redirect("Qformslist");
        }
    }