Пример #1
0
        private void btn_Editroup_Save_Click(object sender, EventArgs e)
        {
            string GroupName    = txt_EditGroup_GroupName.Text.ToString();
            string GroupNumber  = txt_EditGroup_GroupNo.Text.ToString();
            int    NoOfMember   = int.Parse(txt_EditGroup_NumberOfMember.Text);
            string ProjectTitle = txt_EditGroup_ProjectTitle.Text.ToString();
            string semester     = cmb_EditGroup_SemesterChooser.Text.ToString();
            string subject      = temporaryCourse;
            string username     = temporaryUser;

            db_accountDataContext db1 = new db_accountDataContext();
            tb_group acc1             = db1.tb_groups.SingleOrDefault(x => x.grp_groupNumber == GroupNumber);

            acc1.grp_groupName      = GroupName;
            acc1.grp_projectTitle   = ProjectTitle;
            acc1.grp_NumberOfMember = NoOfMember;
            acc1.grp_semester       = semester;
            acc1.grp_subject        = subject;
            acc1.grp_userName       = username;
            // db1.tb_groups.InsertOnSubmit(acc1);
            db1.SubmitChanges();


            foreach (string[] V1 in DataClass.EDitGroupTemporaryList)
            {
                string ax = V1[0];
                string bx = V1[1];
                string cx = V1[2];
                string dx = V1[3];
                // MessageBox.Show(V1[1]);


                db_accountDataContext db  = new db_accountDataContext();
                tb_groupMember        acc = db.tb_groupMembers.SingleOrDefault(x => x.grpm_stdId == bx);

                acc.grpm_stdName     = ax;
                acc.grpm_section     = cx;
                acc.grpm_stdPart     = dx;
                acc.grpm_stdMark     = 0;
                acc.grpm_groupNumber = GroupNumber;
                acc.grpm_subject     = subject;
                acc.grpm_semester    = semester;
                acc.grpm_username    = username;
                //db.tb_groupMembers.InsertOnSubmit(acc);
                db.SubmitChanges();

                MessageBox.Show("Success");
            }
        }
Пример #2
0
 partial void Deletetb_groupMember(tb_groupMember instance);
Пример #3
0
 partial void Updatetb_groupMember(tb_groupMember instance);
Пример #4
0
 partial void Inserttb_groupMember(tb_groupMember instance);
Пример #5
0
        private void btn_SaveGroup_Click(object sender, EventArgs e)
        {
            if ((txt_CreateGroup_NumberOfMember.Text != "") && (txt_CreateGroup_GroupName.Text != "") && (txt_CreateGroup_GroupNumber.Text != "") && (txt_CreateGroup_ProjectTitle.Text != "") && (cmb_CreateGroup_SemesterChooser.Text != "          Semester"))
            {
                string GroupName    = txt_CreateGroup_GroupName.Text.ToString();
                string GroupNumber  = txt_CreateGroup_GroupNumber.Text.ToString();
                int    NoOfMember   = int.Parse(txt_CreateGroup_NumberOfMember.Text);
                string ProjectTitle = txt_CreateGroup_ProjectTitle.Text.ToString();
                string semester     = cmb_CreateGroup_SemesterChooser.Text.ToString();
                string subject      = temporaryCourse;
                string username     = temporaryUser;



                if ((NoOfMember >= 1) && (NoOfMember <= 4))
                {
                    using (SqlConnection connection = new SqlConnection(@"Data Source=DESKTOP-UH9DSCF\SQLEXPRESS;Initial Catalog=Database;Integrated Security=True"))
                    {
                        SqlCommand command = new SqlCommand();
                        command.Connection = connection;

                        command.CommandType = System.Data.CommandType.Text;
                        command.CommandText = @"INSERT INTO [tb_group] ([grp_groupNumber], [grp_groupName],[grp_projecttitle],[grp_NumberOfMember],[grp_semester],[grp_subject],[grp_userName]) VALUES ( @number, @name,@title,@member,@sem,@sub,@user)";
                        command.Parameters.Add("@number", SqlDbType.VarChar, 150).Value = GroupNumber;
                        command.Parameters.Add("@name", SqlDbType.VarChar, 150).Value   = GroupName;
                        command.Parameters.Add("@title", SqlDbType.VarChar, 150).Value  = ProjectTitle;
                        command.Parameters.Add("@member", SqlDbType.Int).Value          = NoOfMember;
                        command.Parameters.Add("@sem", SqlDbType.VarChar, 150).Value    = semester;
                        command.Parameters.Add("@sub", SqlDbType.VarChar, 150).Value    = subject;
                        command.Parameters.Add("@user", SqlDbType.VarChar, 150).Value   = username;

                        connection.Open();

                        command.ExecuteNonQuery();
                    }



                    /*  db_accountDataContext db1 = new db_accountDataContext();
                     * tb_group acc1 = new tb_group();
                     * acc1.grp_groupNumber = GroupNumber;
                     * acc1.grp_groupName = GroupName;
                     * acc1.grp_projectTitle = ProjectTitle;
                     * acc1.grp_NumberOfMember = NoOfMember;
                     * acc1.grp_semester = semester;
                     * acc1.grp_subject = subject;
                     * acc1.grp_userName = username;
                     * db1.tb_groups.InsertOnSubmit(acc1);
                     * db1.SubmitChanges();*/


                    int mark = 0;



                    foreach (string[] V1 in DataClass.CreateGroupTemporary)
                    {
                        string ax = V1[0];
                        string bx = V1[1];
                        string cx = V1[2];
                        string dx = V1[3];



                        // MessageBox.Show(V1[1]);



                        using (SqlConnection connection = new SqlConnection(@"Data Source=DESKTOP-UH9DSCF\SQLEXPRESS;Initial Catalog=Database;Integrated Security=True"))
                        {
                            SqlCommand command = new SqlCommand();
                            command.Connection = connection;

                            command.CommandType = System.Data.CommandType.Text;
                            command.CommandText = @"INSERT INTO [tb_groupMember] ([grpm_stdName], [grpm_stdId],[grpm_section],[grpm_stdPart],[grpm_stdMark],[grpm_groupNumber],[grpm_subject],[grpm_semester]) VALUES (@a,@b,@c,@d,@e,@f,@g,@h)";
                            command.Parameters.Add("@a", SqlDbType.VarChar, 150).Value = ax;
                            command.Parameters.Add("@b", SqlDbType.VarChar, 150).Value = bx;
                            command.Parameters.Add("@c", SqlDbType.VarChar, 150).Value = cx;
                            command.Parameters.Add("@d", SqlDbType.VarChar, 150).Value = dx;

                            command.Parameters.Add("@e", SqlDbType.Int).Value          = mark;
                            command.Parameters.Add("@f", SqlDbType.VarChar, 150).Value = GroupNumber;
                            command.Parameters.Add("@g", SqlDbType.VarChar, 150).Value = subject;
                            command.Parameters.Add("@h", SqlDbType.VarChar, 150).Value = semester;


                            connection.Open();

                            command.ExecuteNonQuery();
                        }



                        db_accountDataContext db  = new db_accountDataContext();
                        tb_groupMember        acc = new tb_groupMember();
                        acc.grpm_stdName     = ax;
                        acc.grpm_stdId       = bx;
                        acc.grpm_section     = cx;
                        acc.grpm_stdPart     = dx;
                        acc.grpm_stdMark     = 0;
                        acc.grpm_groupNumber = GroupNumber;
                        acc.grpm_subject     = subject;
                        acc.grpm_semester    = semester;
                        acc.grpm_username    = username;
                        db.tb_groupMembers.InsertOnSubmit(acc);
                        db.SubmitChanges();
                    }
                    MessageBox.Show("Group Created Successfully");
                    DataClass.CreateGroupAddStudent.Clear();
                    DataClass.CreateGroupTemporary.Clear();
                    fl_CreateGroup.Controls.Clear();
                    txt_CreateGroup_NumberOfMember.Text = "";
                    txt_CreateGroup_GroupName.Text      = "";
                    txt_CreateGroup_GroupNumber.Text    = "";
                    txt_CreateGroup_ProjectTitle.Text   = "";
                }
                else
                {
                    MessageBox.Show("Invalid Group Number. Group Member should be maximum 4");
                }
            }


            else
            {
                MessageBox.Show("Please Fill all the required Fields");
            }
        }