using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace AzmoonGir
{
    public partial class FrmQreport : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\DbAzmoon.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
        DataTable dtAllQuestion;

        public FrmQreport()
        {
            InitializeComponent();
        }

        private void FrmQreport_Load(object sender, EventArgs e)
        {
            SqlDataAdapter da3 = new SqlDataAdapter("SelectAllGroup", con);
            da3.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataTable dt = new DataTable();
            da3.Fill(dt);
            CmbGroup.DataSource = dt;
            CmbGroup.DisplayMember = "GroupName";
            CmbGroup.ValueMember = "GroupID";

        


        }







        private void BtnShow_Click(object sender, EventArgs e)
        {
        
         SqlDataAdapter da2 = new SqlDataAdapter("ReportQuestionByGroup", con);
            da2.SelectCommand.CommandType = CommandType.StoredProcedure;
            dtAllQuestion = new DataTable();
            da2.SelectCommand.Parameters.AddWithValue("@groupid", CmbGroup.SelectedValue);  
            da2.Fill(dtAllQuestion);
            if (dtAllQuestion.Rows.Count == 0)
            {
                Frm_Message Fm = new Frm_Message();
                Fm.lbltext.Text = "برای این گروه سوالی ثبت نشده است";
                Fm.ImgClose.Visible = true;
                Fm.ImgYes.Visible = false;
                Fm.ImgNo.Visible = false;

                Fm.ShowDialog();
            }
            else
            {
                stiReportAllQuestion.Load("stiAllQuestion.mrt");
                stiReportAllQuestion.RegData(dtAllQuestion);
                stiReportAllQuestion.Show();
            }



        }







    }
}
