示例#1
0
        private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CreatGroup cg = new CreatGroup();

            cg.Show();
            this.Hide();
        }
示例#2
0
        private void cmdCreateGroup_Click(object sender, EventArgs e)
        {
            //string q;
            SqlConnection s = new SqlConnection(conStr);

            s.Open();

            if (s.State == ConnectionState.Open)
            {
                string     Insert = "INSERT INTO [dbo].[Group](Created_On) VALUES ('" + Convert.ToDateTime(dTPgroupCreatdate.Value) + "')";
                SqlCommand cmd    = new SqlCommand(Insert, s);
                cmd.ExecuteNonQuery();
            }

            string     I  = "Select @@identity as id from [Group]";
            SqlCommand cm = new SqlCommand(I, s);

            SqlDataReader reader = cm.ExecuteReader();

            string id = "0";

            if (reader.Read())
            {
                id = (reader["id"].ToString());
                MessageBox.Show(id);
            }


            foreach (string small_s in tempstudentsid)
            {
                string q;
                if (cmbStatus.SelectedIndex == 0)
                {
                    q = "Insert into GroupStudent(GroupId, StudentId, Status, AssignmentDate) " +
                        "Values (" + id + "," + small_s.ToString() + ", 3 ,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')";
                }
                else
                {
                    q = "Insert into GroupStudent(GroupId, StudentId, Status, AssignmentDate) " +
                        "Values (" + id + "," + small_s.ToString() + ", 4 ,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')";
                }
                SqlCommand cmd = new SqlCommand(q, s);
                cmd.ExecuteNonQuery();
            }
            MessageBox.Show("SuccessFully Added");
            this.Hide();
            CreatGroup a = new CreatGroup();

            a.Show();
        }