Skip to content

Commit a688e17

Browse files
committed
Merging Add_New_Category
2 parents fb88cca + 7aa7315 commit a688e17

File tree

7 files changed

+144
-25
lines changed

7 files changed

+144
-25
lines changed

Library_Management_System_v0.1/Library_Management_System_v0.1/Add_New_Author.Designer.cs

Lines changed: 16 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Library_Management_System_v0.1/Library_Management_System_v0.1/Add_New_Author.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Text;
88
using System.Threading.Tasks;
99
using System.Windows.Forms;
10-
10+
using MySql.Data.MySqlClient;
1111
namespace Library_Management_System_v0._1
1212
{
1313
public partial class Add_New_Author : Form
@@ -16,5 +16,47 @@ public Add_New_Author()
1616
{
1717
InitializeComponent();
1818
}
19+
20+
private void buttonSaveAuthor_Click(object sender, EventArgs e)
21+
{
22+
if (textBoxAddAuthor.Text == "")
23+
{
24+
25+
MessageBox.Show(" Invalid Entry ", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
26+
27+
28+
}
29+
else
30+
{
31+
DateTime dateTime = DateTime.Now;
32+
dateTime.ToString("yyyyMMddHHmmss");
33+
34+
String categoryName = textBoxAddAuthor.Text;
35+
int bookCount = 0;
36+
int isActive = 1;
37+
int user_login_id = 1;
38+
MySqlConnection connection = DataConnection.getDBConnection();
39+
String newAuthor_SQL = "INSERT INTO book_author (name,description,bookCount,createDateTime,updateDateTime,isActive,user_login_history_id) VALUES (@name,@description,@bookCount,@createDateTime,@updateDateTime,@isActive,@user_login_history_id)";
40+
MySqlConnection mySqlConnection = DataConnection.getDBConnection();
41+
MySqlCommand command_newBookCatergory = new MySqlCommand(newAuthor_SQL, mySqlConnection);
42+
command_newBookCatergory.CommandText = newAuthor_SQL;
43+
command_newBookCatergory.Parameters.AddWithValue("@name", categoryName);
44+
command_newBookCatergory.Parameters.AddWithValue("@description", "");
45+
command_newBookCatergory.Parameters.AddWithValue("@bookCount", bookCount);
46+
command_newBookCatergory.Parameters.AddWithValue("@createDateTime", dateTime);
47+
command_newBookCatergory.Parameters.AddWithValue("@updateDateTime", dateTime);
48+
command_newBookCatergory.Parameters.AddWithValue("@isActive", isActive);
49+
command_newBookCatergory.Parameters.AddWithValue("@user_login_history_id", user_login_id);
50+
51+
command_newBookCatergory.ExecuteNonQuery();
52+
53+
DialogResult dialogResult = MessageBox.Show(" Author Added ! ", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
54+
if(dialogResult == DialogResult.OK)
55+
{
56+
this.Close();
57+
}
58+
59+
}
60+
}
1961
}
2062
}

Library_Management_System_v0.1/Library_Management_System_v0.1/Add_New_Book_Type.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,19 @@ private void buttonSaveBookType_Click(object sender, EventArgs e)
2424
String addNewBookTypeQuery = "INSERT INTO book_type (name) VALUES (@name)";
2525

2626
MySqlConnection mySqlConnection = DataConnection.getDBConnection();
27+
2728
MySqlCommand newBookTypeCommand = new MySqlCommand(addNewBookTypeQuery, mySqlConnection);
2829
newBookTypeCommand.CommandText = addNewBookTypeQuery;
2930
newBookTypeCommand.Parameters.AddWithValue("@name", newBookType);
3031
newBookTypeCommand.ExecuteNonQuery();
32+
3133

32-
MessageBox.Show("New Book Type Added");
34+
DialogResult dialogResult = MessageBox.Show("New Book Type Added", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
35+
if (dialogResult == DialogResult.OK)
36+
{
37+
this.Close();
38+
new Register_new_books().Refresh();
39+
}
3340
}
3441
}
3542
}

Library_Management_System_v0.1/Library_Management_System_v0.1/Add_New_Category.Designer.cs

Lines changed: 15 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Library_Management_System_v0.1/Library_Management_System_v0.1/Add_New_Category.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Text;
88
using System.Threading.Tasks;
99
using System.Windows.Forms;
10-
10+
using MySql.Data.MySqlClient;
1111
namespace Library_Management_System_v0._1
1212
{
1313
public partial class Add_New_Category : Form
@@ -19,7 +19,42 @@ public Add_New_Category()
1919

2020
private void buttonSaveCategory_Click(object sender, EventArgs e)
2121
{
22+
if (textBoxAddCategory.Text == "")
23+
{
24+
25+
MessageBox.Show(" Invalid Entry ", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
26+
27+
28+
}
29+
else
30+
{
31+
DateTime dateTime = DateTime.Now;
32+
dateTime.ToString("yyyyMMddHHmmss");
33+
34+
String categoryName = textBoxAddCategory.Text;
35+
int bookCount = 0;
36+
int isActive = 1;
37+
int user_login_id = 1;
38+
MySqlConnection connection = DataConnection.getDBConnection();
39+
String newBookCategory_SQL = "INSERT INTO book_category (name,bookCount,createDateTime,updateDateTime,isActive,user_login_history_id) VALUES (@name,@bookCount,@createDateTime,@updateDateTime,@isActive,@user_login_history_id)";
40+
MySqlConnection mySqlConnection = DataConnection.getDBConnection();
41+
MySqlCommand command_newBookCatergory = new MySqlCommand(newBookCategory_SQL,mySqlConnection);
42+
command_newBookCatergory.CommandText = newBookCategory_SQL;
43+
command_newBookCatergory.Parameters.AddWithValue("@name", categoryName);
44+
command_newBookCatergory.Parameters.AddWithValue("@bookCount", bookCount);
45+
command_newBookCatergory.Parameters.AddWithValue("@createDateTime", dateTime);
46+
command_newBookCatergory.Parameters.AddWithValue("@updateDateTime", dateTime);
47+
command_newBookCatergory.Parameters.AddWithValue("@isActive", isActive);
48+
command_newBookCatergory.Parameters.AddWithValue("@user_login_history_id", user_login_id);
49+
50+
command_newBookCatergory.ExecuteNonQuery();
2251

52+
DialogResult dialogResult = MessageBox.Show(" Book Catergory Added ! ", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
53+
if (dialogResult == DialogResult.OK)
54+
{
55+
this.Close();
56+
}
57+
}
2358
}
2459
}
25-
}
60+
}

Library_Management_System_v0.1/Library_Management_System_v0.1/DataConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class DataConnection
1414
public static MySqlConnection getDBConnection()
1515
{
1616

17-
String conStr = "server=localhost;user id=root;password=123;persistsecurityinfo=True;port=3306;database=nanofoxy_library_management_system;SslMode=none";
17+
String conStr = "server=localhost;user id=root;password=;persistsecurityinfo=True;port=3306;database=nanofoxy_library_management_system;SslMode=none";
1818

1919
if (DataConnection.mySqlConnection == null) {
2020

Library_Management_System_v0.1/Library_Management_System_v0.1/Register_new_books.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Text;
88
using System.Threading.Tasks;
99
using System.Windows.Forms;
10+
using MySql.Data.MySqlClient;
11+
1012

1113
namespace Library_Management_System_v0._1
1214
{
@@ -15,8 +17,30 @@ public partial class Register_new_books : Form
1517
public Register_new_books()
1618
{
1719
InitializeComponent();
20+
fillComboType();
1821
}
1922

23+
void fillComboType()
24+
{
25+
26+
String selectBookType_SQL = "SELECT * FROM book_type";
27+
MySqlConnection mySqlConnection = DataConnection.getDBConnection();
28+
29+
MySqlCommand cmd_bookType = new MySqlCommand(selectBookType_SQL, mySqlConnection);
30+
MySqlDataReader DataReaderBookType;
31+
32+
DataReaderBookType = cmd_bookType.ExecuteReader();
33+
while (DataReaderBookType.Read()) {
34+
String bookType = DataReaderBookType.GetString("name");
35+
comboBoxBookType.Items.Add(bookType);
36+
37+
}
38+
39+
40+
41+
}
42+
43+
2044
private void label2_Click(object sender, EventArgs e)
2145
{
2246

0 commit comments

Comments
 (0)