コード例 #1
0
        private void Cancel_Click(object sender, EventArgs e)
        {
            this.Hide();
            GroupProject datap = new GroupProject();

            datap.ShowDialog();
            this.Close();// close the form
        }
コード例 #2
0
 private void Cancel_Click(object sender, EventArgs e)
 {
     this.Hide();
     if (buffer > 0)
     {
         GroupProject gp = new GroupProject();
         gp.ShowDialog();
     }
     else
     {
         MarkEvaluationGroup mg = new MarkEvaluationGroup();
         mg.ShowDialog();
     }
     this.Close();
 }
コード例 #3
0
        // goes to manage group project
        private void button2_Click(object sender, EventArgs e)
        {
            GroupProject gp = new GroupProject();

            gp.ShowDialog();
        }
コード例 #4
0
        private void save_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(conURL);

            // connection opens
            con.Open();

            int ID = buffer;

            if (ID < 0)
            {
                try
                {
                    // here check whether boxes are empty for not
                    if (String.IsNullOrEmpty(comboBoxtitle.Text))
                    {
                        MessageBox.Show("Fill title must");
                    }
                    else
                    {
                        // command store in string then execute it by passing into sqlcommand object

                        string cmdText = "INSERT INTO GroupProject (ProjectId, GroupId, AssignmentDate) VALUES ((SELECT Id FROM Project where Title = @Title),@GroupId, @AssignmentDate)";

                        SqlCommand c = new SqlCommand(cmdText, con);

                        c.Parameters.Add(new SqlParameter("@Title", comboBoxtitle.Text));

                        c.Parameters.Add(new SqlParameter("@GroupId", GroupProject.groupId));

                        c.Parameters.Add(new SqlParameter("@AssignmentDate", DateTime.Now));
                        //execute it
                        int result = c.ExecuteNonQuery();
                        if (result < 0)
                        {
                            MessageBox.Show("Error");
                        }


                        // show dialog box if added in table of database
                        MessageBox.Show("Successfully Added");
                        con.Close();
                        this.Hide();
                        GroupProject datap = new GroupProject();
                        datap.ShowDialog();
                        this.Close(); // close the form
                    }
                }

                catch (Exception)
                {
                    MessageBox.Show("Enter title in correct Format!!. Title should be from drop down list");
                }
            }

            else
            {
                try
                {
                    if (!String.IsNullOrEmpty(comboBoxtitle.Text))
                    {
                        string     cmdText2 = "Update GroupProject SET ProjectId = (SELECT Id FROM Project where Title = @Title), AssignmentDate = @AssignmentDate WHERE ProjectId = @ProjectId AND GroupId = @GroupId";
                        SqlCommand c2       = new SqlCommand(cmdText2, con);
                        c2.Parameters.Add(new SqlParameter("@ProjectId", ID));
                        c2.Parameters.Add(new SqlParameter("@GroupId", GroupProject.groupId));
                        c2.Parameters.Add(new SqlParameter("@Title", comboBoxtitle.Text));
                        c2.Parameters.Add(new SqlParameter("@AssignmentDate", DateTime.Now));

                        c2.ExecuteNonQuery();
                        MessageBox.Show("Successfully Updated");
                        con.Close();
                        this.Hide();
                        GroupProject datap = new GroupProject();
                        datap.ShowDialog();
                        this.Close(); // close the form
                    }
                    else
                    {
                        throw new ArgumentNullException();
                    }
                }

                catch (Exception)
                {
                    MessageBox.Show("Enter title in correct Format!!. Title should be from drop down list");
                }
            }
        }