예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string sqlconnection = "data source=.;initial catalog=hadafDB;integrated security=True";

            SqlConnection scon = new SqlConnection(sqlconnection);

            scon.Open();
            string selectstr = "select count(id) as dd,CoursName from Counter where Reshte='" + DropDownList1.SelectedItem.Value + "' group by CoursName";

            SqlDataAdapter sda = new SqlDataAdapter(selectstr, scon);
            DataSet        ds  = new DataSet();

            sda.Fill(ds);

            GridView1.DataSource = ds;
            GridView1.DataBind();
            scon.Close();


            studentcountRepository cir = new studentcountRepository();

            Session["comnpdata"] = cir.GetStdList(DropDownList1.SelectedItem.Value);
            GridView3.DataSource = Session["comnpdata"];
            GridView3.DataBind();
            //  Label2.Text = Session["reshte"].ToString();
            //  Label1.Text = Session["stdid"].ToString();
        }
예제 #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserRepository ar          = new UserRepository();
            enter          currentUser = ar.FindByUserName(Label1.Text);
            string         status      = currentUser.Status.ToString();

            if (status == "0")
            {
                //try
                //{
                int unit = 0;
                int sum;
                sum = 0;
                string succsesfulsave = "";
                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    if ((gvr.FindControl("CheckBox1") as CheckBox).Checked == true)
                    {
                        unit = gvr.Cells[2].Text.ToInt();
                        sum  = sum + unit;
                    }
                }
                Label2.Text = sum.ToString();

                if ((sum >= 12) && (sum <= 20))
                {
                    lblmessage.Text = "";
                    foreach (GridViewRow gvr in GridView1.Rows)
                    {
                        if ((gvr.FindControl("CheckBox1") as CheckBox).Checked == true)
                        {
                            try
                            {
                                CoursRepository air        = new CoursRepository();
                                Counter         newAccount = new Counter();
                                //  string reshte=
                                newAccount.Reshte    = Session["value"].ToString();
                                newAccount.stdid     = Label1.Text;
                                newAccount.CoursUnit = gvr.Cells[2].Text.ToInt();
                                newAccount.CoursName = gvr.Cells[1].Text;
                                air.Savecourse(newAccount);


                                //  HadafTools.ShowMessage(lblmessage, " ثبت با موفقیت انجام شد ", Color.Red);

                                succsesfulsave = "ok";
                            }
                            catch
                            {
                                HadafTools.ShowMessage(lblmessage, " ثبت امکانپذیر  نمی باشد ", Color.Red);
                            }
                        }
                    }
                    if (succsesfulsave == "ok")
                    {
                        UserRepository ur   = new UserRepository();
                        enter          user = ur.FindByUserName(Label1.Text);
                        user.Status = int.Parse("1");
                        ur.Savestatus(user);


                        studentcountRepository str = new studentcountRepository();
                        Student newstd             = new Student();
                        newstd.stdid  = Label1.Text;
                        newstd.Reshte = Session["value"].ToString();
                        str.Save(newstd);
                        Redirector.Goto(Redirector.PageName.ok);
                    }
                }

                else
                {
                    HadafTools.ShowMessage(lblmessage, " تعداد واحد مجاز نمی باشد ", Color.Red);
                }
                // }
                //catch
                //{
                //    HadafTools.ShowMessage(lblmessage, " ثبت امکانپذیر  نمی باشد ", Color.Red);
                //}
            }
            else
            {
                HadafTools.ShowMessage(lblmessage, " پیش ثبت توسط این نام کاربری قبلا انجام شد ", Color.Red);
            }
        }