Ejemplo n.º 1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dataGridView1.Columns[12].Index && (e.RowIndex >= 0 && e.RowIndex < dataGridView1.Rows.Count - 1))
            {
                int             index = e.RowIndex;
                DataGridViewRow row   = dataGridView1.Rows[index];
                String          id    = row.Cells[13].Value.ToString();

                imag_viewer view = new imag_viewer(id);
                view.Show();
            }
        }
Ejemplo n.º 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dataGridView1.Columns["edit_button"].Index && (e.RowIndex >= 0))
            {
                int             index = e.RowIndex;
                DataGridViewRow row   = dataGridView1.Rows[index];

                DialogResult result = MessageBox.Show("Book Name:\t" + row.Cells[1].Value.ToString() + "\n\nDo you Want to update this book ?", "Wellcome User", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    String    id   = row.Cells[0].Value.ToString();
                    book_edit edit = new book_edit(id);
                    edit.Show();
                }
            }

            if (account == 1)
            {
                if (e.ColumnIndex == dataGridView1.Columns["delete_button"].Index && (e.RowIndex >= 0))
                {
                    int             index = e.RowIndex;
                    DataGridViewRow row   = dataGridView1.Rows[index];

                    DialogResult result = MessageBox.Show("Book Name:\t" + row.Cells[1].Value.ToString() + "\n\nDo you Want to Delete this book ?", "Wellcome User", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        String id = row.Cells[0].Value.ToString();

                        try
                        {
                            String        con    = ConfigurationManager.ConnectionStrings["WindowsFormsApplication1.Properties.Settings.librarayManagementConnectionString"].ConnectionString;
                            SqlConnection sqlCon = new SqlConnection(con);
                            sqlCon.Open();

                            String query = "DELETE  FROM book_registration WHERE book_id='" + id + "'";

                            SqlCommand cmd = new SqlCommand(query, sqlCon);

                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Record has been Deleted");

                            sqlCon.Close();

                            loadbook();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }

            if (e.ColumnIndex == dataGridView1.Columns["review_button"].Index && (e.RowIndex >= 0))
            {
                int             index = e.RowIndex;
                DataGridViewRow row   = dataGridView1.Rows[index];
                String          id    = row.Cells[0].Value.ToString();

                commentReview comment = new commentReview(id);
                comment.Show();
            }

            if (e.ColumnIndex == dataGridView1.Columns[12].Index && (e.RowIndex >= 0))
            {
                int             index = e.RowIndex;
                DataGridViewRow row   = dataGridView1.Rows[index];
                String          id    = row.Cells[0].Value.ToString();

                imag_viewer view = new imag_viewer(id);
                view.Show();
            }
        }