private void ManageProject_Click(object sender, EventArgs e) { ManageProject E6 = new ManageProject(); E6.Show(); this.Hide(); }
private void Save_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(conURL); con.Open(); if (flag > 0) { bool j = myvalidations(); if (j == true) { SqlCommand cmd1; string updateproject = "Update Project set Title=@Title,Description=@Description WHERE Project.Id= @flag1"; cmd1 = new SqlCommand(updateproject, con); cmd1.Parameters.AddWithValue("@flag1", flag); cmd1.Parameters.AddWithValue("@Title", Title.Text); if (String.IsNullOrEmpty(Description.Text)) { cmd1.Parameters.AddWithValue("@Description", DBNull.Value); } else { cmd1.Parameters.AddWithValue("@Description", Description.Text); } cmd1.ExecuteNonQuery(); con.Close(); MessageBox.Show("Project Details Successfully Updated "); ManageProject f3 = new ManageProject(); f3.Show(); this.Close(); } } else { bool j = myvalidations(); if (j == true) { SqlCommand cmd1; string insertpr = "INSERT INTO Project(Title,Description) values(@Title,@Description)"; cmd1 = new SqlCommand(insertpr, con); cmd1.Parameters.AddWithValue("@Title", Title.Text); if (String.IsNullOrEmpty(Description.Text)) { cmd1.Parameters.AddWithValue("@Description", DBNull.Value); } else { cmd1.Parameters.AddWithValue("@Description", Description.Text); } int i = cmd1.ExecuteNonQuery(); con.Close(); clearfields(); MessageBox.Show(i + " Row(s) Inserted "); } } }
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { SqlConnection con = new SqlConnection(conURL); con.Open(); int currentRow = int.Parse(e.RowIndex.ToString()); int currentColumnIndex = int.Parse(e.ColumnIndex.ToString()); int id = Convert.ToInt32(dataGridView1.Rows[currentRow].Cells[2].Value.ToString()); if (currentColumnIndex == 0) { AddProject fe = new AddProject(id); fe.Show(); this.Hide(); } if (currentColumnIndex == 1) { var confirmResult = MessageBox.Show("Are you sure to delete this item ??", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { SqlCommand cmd1; SqlCommand cmd2; SqlCommand cmd3; string deleteproject = "DELETE FROM Project Where Id = @num"; string deleteprojectadv = "DELETE FROM ProjectAdvisor Where ProjectId = @num"; string deletegrouppr = "DELETE FROM GroupProject Where ProjectId = @num"; cmd1 = new SqlCommand(deleteproject, con); cmd2 = new SqlCommand(deleteprojectadv, con); cmd3 = new SqlCommand(deletegrouppr, con); cmd1.Parameters.AddWithValue("@num", id); cmd2.Parameters.AddWithValue("@num", id); cmd3.Parameters.AddWithValue("@num", id); cmd3.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); cmd1.ExecuteNonQuery(); con.Close(); MessageBox.Show("Record deleted succesfully"); ManageProject fm = new ManageProject(); this.Close(); fm.Show(); } } }