private void AddProjectAdvisorDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int currentRow        = int.Parse(e.RowIndex.ToString());
            int curentcolumnindex = int.Parse(e.ColumnIndex.ToString());
            int AdvisorId         = Convert.ToInt32(AddProjectAdvisorDataGridView.Rows[currentRow].Cells[1].Value);

            if (curentcolumnindex == 0)
            {
                SqlConnection conn = new SqlConnection(conURL);
                conn.Open();
                String     AddCMD     = "INSERT INTO ProjectAdvisor (AdvisorId, ProjectId, AdvisorRole, AssignmentDate) VALUES (@adid, @prid, @arole, @asgnDate)";
                SqlCommand AddCommand = new SqlCommand(AddCMD, conn);
                AddCommand.Parameters.Add(new SqlParameter("adid", AdvisorId));
                AddCommand.Parameters.Add(new SqlParameter("prid", projectId));

                String     getAdvisorRoleIdCMD     = String.Format("SELECT Id FROM Lookup WHERE Value = '{0}'", AdvisorRoleComboBox.Text);
                SqlCommand getAdvisorRoleIdCommand = new SqlCommand(getAdvisorRoleIdCMD, conn);
                int        AdvisorRoleId           = (Int32)getAdvisorRoleIdCommand.ExecuteScalar();
                AddCommand.Parameters.Add(new SqlParameter("arole", AdvisorRoleId));

                AddCommand.Parameters.Add(new SqlParameter("asgnDate", DateTime.Today));

                int count = AddCommand.ExecuteNonQuery();

                AddProjectAdvisor form = new AddProjectAdvisor(projectId);
                form.Show();
                this.Hide();
            }
        }
Ejemplo n.º 2
0
        private void ProjectsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int currentRow        = int.Parse(e.RowIndex.ToString());
            int curentcolumnindex = int.Parse(e.ColumnIndex.ToString());
            int ProjectId         = Convert.ToInt32(ProjectsGridView.Rows[currentRow].Cells[2].Value);

            if (curentcolumnindex == 0)
            {
                AddProjectAdvisor form = new AddProjectAdvisor(ProjectId);
                form.Show();
                this.Hide();
            }
            if (curentcolumnindex == 1)
            {
                ViewProjectAdvisor form = new ViewProjectAdvisor(ProjectId);
                form.Show();
                this.Hide();
            }
        }