private void btn_delete_auth_Click(object sender, EventArgs e)
 {
     sql           = $"delete from \"Authentication_Info\"  where login_id = {FunctionsClass.GetColumnStr(dgv_auth, "login_id")}";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(selectStr, dgv_auth, connection);
 }
        private void button1_Click(object sender, EventArgs e)
        {
            var values = new string[] {
                FunctionsClass.GetColumnStr(dgv_staff, "contact_id"),
                FunctionsClass.GetColumnStr(dgv_staff, "section_id"),
                FunctionsClass.GetColumnStr(dgv_staff, "login_id"),
                FunctionsClass.GetColumnStr(dgv_staff, "first_name"),
                FunctionsClass.GetColumnStr(dgv_staff, "last_name"),
                FunctionsClass.GetColumnStr(dgv_staff, "job_description"),
                FunctionsClass.GetColumnStr(dgv_staff, "salary")
            };

            //insert into "Staff"(contact_id, section_id, login_id, first_name, last_name, job_description, salary) values(3, 46, 3, 'ali', 'veli', 'ogretim', 3000)
            sql           = $"insert into \"Staff\"(contact_id, section_id, login_id, first_name, last_name, job_description, salary) values({values[0]}, {values[1]}, {values[2]}, '{values[3]}', '{values[4]}', '{values[5]}', {values[6]})";
            using var cmd = new NpgsqlCommand(sql, connection);
            try
            {
                cmd.ExecuteNonQuery();
                FunctionsClass.SelectData(select, dgv_staff, connection);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
        private void btn_add_book_Click(object sender, EventArgs e)
        {
            int    author_id    = Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_books, "author_id"));
            int    section_id   = Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_books, "section_id"));
            int    publisher_id = Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_books, "publisher_id"));
            int    page_count   = Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_books, "page_count"));
            int    price        = Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_books, "price"));
            string title        = FunctionsClass.GetColumnStr(dgv_books, "title");
            string edition      = FunctionsClass.GetColumnStr(dgv_books, "edition");
            string category     = FunctionsClass.GetColumnStr(dgv_books, "category");

            sql = $"insert into \"Book\" (author_id,section_id,publisher_id,page_count,price,title,edition,category)" +
                  $" values({author_id}, {section_id}, {publisher_id}, {page_count}, {price}, '{title}', '{edition}', '{category}' ); ";

            using var cmd = new NpgsqlCommand(sql, connection);
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            FunctionsClass.SelectData(select_book, dgv_books, connection);
        }
 private void btn_delete_documentary_Click(object sender, EventArgs e)
 {
     sql           = $"delete from \"Documentary\" where digital_id = {FunctionsClass.GetColumnStr(dgv_documentary, "digital_id")}";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(selectDoc, dgv_documentary, connection);
 }
        private void btn_add_documentary_Click(object sender, EventArgs e)
        {
            //string title = FunctionsClass.GetColumnStr(dgv_books, "title");
            //string edition = FunctionsClass.GetColumnStr(dgv_books, "edition");
            //string category = FunctionsClass.GetColumnStr(dgv_books, "category");
            string[] values    = new string[6];
            string[] prmNames  = new string[] { "section_id", "title", "URL", "director", "duration", "subject" };
            var      prmNamesC = String.Join(",", prmNames);

            for (int i = 0; i < 6; i++)
            {
                values[i] = FunctionsClass.GetColumnStr(dgv_documentary, prmNames[i]);
            }

            //sql = $"insert into \"Digital_Material\" ({prmNames[0]}, {prmNames[1]}, \"{prmNames[2]}\") values ('{values[0]}','{values[1]}','{values[2]}'; insert into \"Documentary\" (digital_id, {prmNames[3]}, {prmNames[4]}, {prmNames[5]})" +
            //    $"values ({values[3]},'{values[4]}','{values[5]}')";

            sql = $"select* from documentary_add({values[0]},'{values[1]}','{values[2]}','{values[3]}','{values[4]}','{values[5]}')";

            try
            {
                using var cmd = new NpgsqlCommand(sql, connection);
                cmd.ExecuteNonQuery();
                FunctionsClass.SelectData(selectDoc, dgv_documentary, connection);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
        private void btn_add_course_Click(object sender, EventArgs e)
        {
            string[] values    = new string[6];
            string[] prmNames  = new string[] { "section_id", "title", "URL", "tutor", "video_count", "field" };
            var      prmNamesC = String.Join(",", prmNames);

            for (int i = 0; i < 6; i++)
            {
                values[i] = FunctionsClass.GetColumnStr(dgv_course, prmNames[i]);
            }

            //sql = $"insert into \"Digital_Material\" ({prmNames[0]}, {prmNames[1]}, \"{prmNames[2]}\") values ('{values[0]}','{values[1]}','{values[2]}'; insert into \"Documentary\" (digital_id, {prmNames[3]}, {prmNames[4]}, {prmNames[5]})" +
            //    $"values ({values[3]},'{values[4]}','{values[5]}')";

            sql = $"select* from course_add({values[0]},'{values[1]}','{values[2]}','{values[3]}','{values[4]}','{values[5]}')";

            try
            {
                using var cmd = new NpgsqlCommand(sql, connection);
                cmd.ExecuteNonQuery();
                FunctionsClass.SelectData(selectCourse, dgv_course, connection);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            FunctionsClass.SelectData(selectCourse, dgv_course, connection);
        }
 private void btn_delete_contact_Click(object sender, EventArgs e)
 {
     sql           = @"select * from contact_delete(:_id)";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.Parameters.AddWithValue("_id", Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_contacts, "contact_id")));
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(sql, dgv_contacts, connection);
 }
 private void button2_Click(object sender, EventArgs e)
 {
     sql           = $"delete from \"Staff\" where staff_id = {FunctionsClass.GetColumnStr(dgv_staff, "staff_id")}";
     using var cmd = new NpgsqlCommand(sql, connection);
     //var rowIndex = dgv_authors.CurrentCell.RowIndex;
     //cmd.Parameters.AddWithValue("_id", Convert.ToInt32());
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(select, dgv_staff, connection);
 }
 private void btn_add_publisher_Click(object sender, EventArgs e)
 {
     sql           = @"select * from publisher_insert(:_contact_id, :_name)";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.Parameters.AddWithValue("_contact_id", Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_publishers, "contact_id")));
     cmd.Parameters.AddWithValue("_name", FunctionsClass.GetColumnStr(dgv_publishers, "name"));
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(select_publisher, dgv_publishers, connection);
 }
 private void btn_delete_author_Click(object sender, EventArgs e)
 {
     sql           = @"select * from author_delete(:_id)";
     using var cmd = new NpgsqlCommand(sql, connection);
     //var rowIndex = dgv_authors.CurrentCell.RowIndex;
     cmd.Parameters.AddWithValue("_id", Convert.ToInt32(FunctionsClass.GetColumnStr(dgv_authors, "author_id")));
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(select_author, dgv_authors, connection);
 }
Exemplo n.º 11
0
        private void btn_add_access_Click(object sender, EventArgs e)
        {
            var login_id = FunctionsClass.GetColumnStr(dgv_access, "login_id");
            var book_id  = FunctionsClass.GetColumnStr(dgv_access, "book_id");

            sql           = $"insert into \"Exclusive_Access\" (login_id, book_id) values ({login_id}, {book_id})";
            using var cmd = new NpgsqlCommand(sql, connection);
            cmd.ExecuteNonQuery();
            FunctionsClass.SelectData(selectStr, dgv_access, connection);
        }
        private void btn_add_author_Click(object sender, EventArgs e)
        {
            sql = @"select * from author_insert(:_name, :_surname);";

            using var cmd = new NpgsqlCommand(sql, connection);
            //var rowIndex = dgv_authors.CurrentCell.RowIndex;
            cmd.Parameters.AddWithValue("_name", FunctionsClass.GetColumnStr(dgv_authors, "first_name"));
            cmd.Parameters.AddWithValue("_surname", FunctionsClass.GetColumnStr(dgv_authors, "last_name"));
            cmd.ExecuteNonQuery();
            FunctionsClass.SelectData(select_author, dgv_authors, connection);
        }
 private void btn_add_contact_Click(object sender, EventArgs e)
 {
     sql           = @"select * from contact_insert(:_address, :_email, :_phone)";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.Parameters.AddWithValue("_address", FunctionsClass.GetColumnStr(dgv_contacts, "address"));
     cmd.Parameters.AddWithValue("_email", FunctionsClass.GetColumnStr(dgv_contacts, "e-mail"));
     cmd.Parameters.AddWithValue("_phone", FunctionsClass.GetColumnStr(dgv_contacts, "phone_number"));
     selectedContactId = Convert.ToInt32(cmd.ExecuteScalar().ToString());
     MessageBox.Show($"Iletisim olusturuldu, {selectedContactId} id'sini kullaniniz!");
     this.Close();
     //FunctionsClass.SelectData(selectStr, dgv_contacts, connection);
 }
        private void btn_add_auth_Click(object sender, EventArgs e)
        {
            var passwd = FunctionsClass.GetColumnStr(dgv_auth, "password");

            sql           = $"insert into \"Authentication_Info\"(password) values('{passwd}')";
            using var cmd = new NpgsqlCommand(sql, connection);
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            FunctionsClass.SelectData(selectStr, dgv_auth, connection);
        }
 private void btn_delete_member_Click(object sender, EventArgs e)
 {
     sql           = $"delete from \"Member\" where member_id = {FunctionsClass.GetColumnStr(dgv_members, "member_id")}";
     using var cmd = new NpgsqlCommand(sql, connection);
     //var rowIndex = dgv_authors.CurrentCell.RowIndex;
     //cmd.Parameters.AddWithValue("_id", Convert.ToInt32());
     try
     {
         cmd.ExecuteNonQuery();
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
     cmd.ExecuteNonQuery();
     RefreshTables();
 }
 private void btn_delete_book_Click(object sender, EventArgs e)
 {
     sql           = $"delete from \"Book\" where book_id = {FunctionsClass.GetColumnStr(dgv_books, "book_id")}";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.ExecuteNonQuery();
 }
Exemplo n.º 17
0
 private void btn_delete_access_Click(object sender, EventArgs e)
 {
     sql           = sql = $"delete from \"Exclusive_Access\" where access_id = {FunctionsClass.GetColumnStr(dgv_access, "access_id")}";
     using var cmd = new NpgsqlCommand(sql, connection);
     cmd.ExecuteNonQuery();
     FunctionsClass.SelectData(selectStr, dgv_access, connection);
 }