public override void btnDelete_Click(object sender, EventArgs e)
 {
     if (txtOverDueID.Text != "")
     {
         DialogResult dr = MessageBox.Show("Do you want to delete " + "'s Details ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             con.Open();
             if (con.State == System.Data.ConnectionState.Open)
             {
                 string q = "DELETE libraryOverDue  where overdue_ID ='" + txtOverDueID.Text + "' ";
                 Console.Write(q);
                 SqlCommand cmd = new SqlCommand(q, con);
                 cmd.ExecuteNonQuery();
                 MainClass.showMsgLibrary("Successfully Deleted!", "Success", "Success");
             }
         }
         else { }
     }
     else
     {
         MainClass.showMsg("Select a record that you want to delete!", "error", "error");
     }
     con.Close();
     showOverduePaymentsDetails();
     MainClass.disable_reset(panel6);
     lblMain.Text = "View";
 }
Example #2
0
        private void btnReturnBooks_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                if (con.State == System.Data.ConnectionState.Open)
                {
                    string q = "DELETE libraryReserveBooks  where reserve_ID ='" + ReserveIDText.Text + "' ";
                    Console.Write(q);
                    SqlCommand cmd = new SqlCommand(q, con);
                    cmd.ExecuteNonQuery();

                    SqlCommand cmd2 = con.CreateCommand();
                    cmd2.CommandType = CommandType.Text;
                    cmd2.CommandText = "UPDATE libraryBooks set quantity= quantity+1 where name='" + BookNameText.Text + "'";
                    cmd2.ExecuteNonQuery();
                    MainClass.showMsgLibrary("Book has returned!", "Success", "Success");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            con.Close();
            dataClear();
            showDetails(txtMemberID.Text);
        }
        public override void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtReserveID.Text != "")
            {
                DialogResult dr = MessageBox.Show("Do you want to delete Reservation" + txtReserveID.Text + " Details ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "DELETE libraryReserveBooks  where reserve_ID ='" + txtReserveID.Text + "' ";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsgLibrary("Successfully Deleted!", "Success", "Success");

                            SqlCommand cmd2 = con.CreateCommand();
                            cmd2.CommandType = CommandType.Text;
                            cmd2.CommandText = "UPDATE libraryBooks set quantity= quantity+1 where name='" + txtBookName.Text + "'";
                            cmd2.ExecuteNonQuery();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error");
                    }
                }
                else
                {
                }
            }
            else
            {
                MainClass.showMsg("Select a record that you want to delete!", "error", "error");
            }
            con.Close();
            showReserveDetails();
            lblMain.Text = "View";
            MainClass.disable_reset(panel6);
        }
        private void btnReserve_Click(object sender, EventArgs e)
        {
            if (btnStatus == "add")
            {
                if (ReserveIDNull.Visible || BookIDNull.Visible || BookNameNull.Visible || MemberIDNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            int        bookQty = 0;
                            SqlCommand cmd3    = con.CreateCommand();
                            cmd3.CommandType = CommandType.Text;
                            cmd3.CommandText = "SELECT * FROM libraryBooks WHERE name='" + txtBookName.Text + "'";
                            cmd3.ExecuteNonQuery();
                            DataTable      dt2 = new DataTable();
                            SqlDataAdapter da2 = new SqlDataAdapter(cmd3);
                            da2.Fill(dt2);
                            foreach (DataRow dr2 in dt2.Rows)
                            {
                                bookQty = int.Parse(dr2["quantity"].ToString());
                            }

                            if (bookQty > 0)
                            {
                                SqlCommand cmd = con.CreateCommand();
                                cmd.CommandType = CommandType.Text;
                                cmd.CommandText = "INSERT INTO libraryReserveBooks (reserve_ID, book_ID, bookName, member_ID, reserveDate, dueDate)  VALUES ('" + txtReserveID.Text + "', '" + txtBookID.Text + "', '" + txtBookName.Text + "', '" + txtMemberID.Text + "', '" + ReserveDate.Text + "', '" + DueDate.Text + "')";
                                cmd.ExecuteNonQuery();
                                MainClass.showMsgLibrary("Successfull Reserved!", "Success", "Success");

                                SqlCommand cmd2 = con.CreateCommand();
                                cmd2.CommandType = CommandType.Text;
                                cmd2.CommandText = "UPDATE libraryBooks set quantity= quantity-1 where name='" + txtBookName.Text + "'";
                                cmd2.ExecuteNonQuery();
                            }
                            else
                            {
                                MainClass.showMsgLibrary("Book has already reserved!", "Warning", "Error");
                            }
                        }
                    }
                    catch
                    {
                        int reserveID = 0;
                        int bookID    = 0;
                        int memberID  = 0;

                        try
                        {
                            reserveID = int.Parse(txtReserveID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Reserve ID should be a numerical value!", "Warning", "Error");
                        }

                        try
                        {
                            bookID = int.Parse(txtBookID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Book ID should be a numerical value!", "Warning", "Error");
                        }
                        try
                        {
                            memberID = int.Parse(txtMemberID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Member ID should be a numerical value!", "Warning", "Error");
                        }
                    }

                    con.Close();
                    showReserveDetails();
                    lblMain.Text = "View";
                    MainClass.disable_reset(panel6);
                }
            }
            else if (btnStatus == "update")
            {
                if (ReserveIDNull.Visible || BookIDNull.Visible || MemberIDNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            int        bookQty = 0;
                            SqlCommand cmd3    = con.CreateCommand();
                            cmd3.CommandType = CommandType.Text;
                            cmd3.CommandText = "SELECT * FROM libraryBooks WHERE name='" + txtBookName.Text + "'";
                            cmd3.ExecuteNonQuery();
                            DataTable      dt2 = new DataTable();
                            SqlDataAdapter da2 = new SqlDataAdapter(cmd3);
                            da2.Fill(dt2);
                            foreach (DataRow dr2 in dt2.Rows)
                            {
                                bookQty = int.Parse(dr2["quantity"].ToString());
                            }

                            if (bookQty > 0)
                            {
                                string q = "UPDATE libraryReserveBooks SET reserve_ID ='" + txtReserveID.Text + "' ,book_ID='" + txtBookID.Text + "',bookName='" + txtBookName.Text + "', member_ID='" + txtMemberID.Text + "',reserveDate='" + ReserveDate.Text + "',dueDate='" + DueDate.Text + "' where reserve_ID ='" + txtReserveID.Text + "' ";
                                Console.Write(q);
                                SqlCommand cmd = new SqlCommand(q, con);
                                cmd.ExecuteNonQuery();
                                MainClass.showMsgLibrary("Successfull Updated!", "Success", "Success");

                                SqlCommand cmd2 = con.CreateCommand();
                                cmd2.CommandType = CommandType.Text;
                                cmd2.CommandText = "UPDATE libraryBooks set quantity= quantity-1 where name='" + txtBookName.Text + "'";
                                cmd2.ExecuteNonQuery();
                            }
                            else
                            {
                                MainClass.showMsgLibrary("all books has reserved!", "Warning", "Error");
                            }
                        }
                    }
                    catch
                    {
                        int bookID   = 0;
                        int memberID = 0;

                        try
                        {
                            bookID = int.Parse(txtBookID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Book ID should be a numerical value!", "Warning", "Error");
                        }
                        try
                        {
                            memberID = int.Parse(txtMemberID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Member ID should be a numerical value!", "Warning", "Error");
                        }
                    }
                }
            }
            con.Close();
            showReserveDetails();
            lblMain.Text = "View";
            MainClass.disable_reset(panel6);
        }
        private void btnCalculateAndSubmit_Click(object sender, EventArgs e)
        {
            if (btnStatus == "add")
            {
                try
                {
                    int days, amount, total;

                    days = Convert.ToInt32(txtDueDays.Text);
                    amount = Convert.ToInt32(txtPerDayAmount.Text);

                    total = days * amount;
                    totalAmount.Text = total.ToString();
                }
                catch
                {
                    
                }
                if (OverDueIDNull.Visible || MemberIDNull.Visible || DueDateNull.Visible || DueDaysNull.Visible || PerDayAmountNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "INSERT INTO libraryOverDue (overdue_ID, member_ID, dueDate, noOfDueDays, totalAmount) VALUES ('" + txtOverDueID.Text + "','" + txtMemberID.Text + "','" + DueDate.Text + "','" + txtDueDays.Text + "','" + totalAmount.Text + "')";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsg(" Payment added Successfully!", "Success", "success");
                        }
                    }
                    catch
                    {
                        int overdue_ID = 0;
                        int member_ID = 0;

                        try
                        {
                            overdue_ID = int.Parse(txtOverDueID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Overdue ID should be a numerical value!", "Warning", "Error");
                        }
                        try
                        {
                            member_ID = int.Parse(txtMemberID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Member ID should be a numerical value!", "Warning", "Error");
                        }
                    }
                }
                con.Close();
                lblMain.Text = "View";
                showOverduePaymentsDetails();                
                MainClass.disable_reset(panel6);
            }
              else if (btnStatus == "update")
              {
                try
                {
                    int days, amount, total;

                    days = Convert.ToInt32(txtDueDays.Text);
                    amount = Convert.ToInt32(txtPerDayAmount.Text);

                    total = days * amount;
                    totalAmount.Text = total.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }
                if (OverDueIDNull.Visible || MemberIDNull.Visible || DueDateNull.Visible || DueDaysNull.Visible || PerDayAmountNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "UPDATE libraryOverDue SET overdue_ID ='" + txtOverDueID.Text + "' ,member_ID='" + txtMemberID.Text + "',dueDate='" + DueDate.Text + "',noOfDueDays='" + txtDueDays.Text + "',totalAmount='" + totalAmount.Text + "' where overdue_ID ='" + txtOverDueID.Text + "' ";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsg("Details Updated Successfully", "Success", "success");
                        }
                    }
                    catch
                    {

                    }     
                }
                con.Close();
                lblMain.Text = "View";
                showOverduePaymentsDetails();
                MainClass.disable_reset(panel6);              
            }
           }
Example #6
0
        private void btnAddMembers_Click(object sender, EventArgs e)
        {
            if (btnStatus == "add")
            {
                if (MemberIDNull.Visible || FNameNull.Visible || LNameNull.Visible || AddressNull.Visible || ContactNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "INSERT INTO libraryMember (member_ID, FirstName, LastName, address, contactNo, addDate) VALUES ('" + txtMemberID.Text + "','" + txtFName.Text + "','" + txtLName.Text + "','" + txtAddress.Text + "','" + txtContact.Text + "','" + AddDate.Text + "')";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsg(txtFName.Text + " 's Details Added Successfully", "Success", "success");
                        }
                    }
                    catch
                    {
                        int member_ID = 0;
                        int contactNo = 0;

                        try
                        {
                            member_ID = int.Parse(txtMemberID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Member ID should be a numerical Value!", "Warning", "Error");
                        }
                        try
                        {
                            contactNo = int.Parse(txtContact.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Contact no should be an integer!", "Warning", "Error");
                        }
                    }
                }
                con.Close();
                lblMain.Text = "View";
            }

            else if (btnStatus == "update")
            {
                if (MemberIDNull.Visible || FNameNull.Visible || LNameNull.Visible || AddressNull.Visible || ContactNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "UPDATE libraryMember SET member_ID ='" + txtMemberID.Text + "' ,FirstName='" + txtFName.Text + "',LastName='" + txtLName.Text + "',address='" + txtAddress.Text + "',contactNo='" + txtContact.Text + "',addDate='" + AddDate.Text + "' where member_ID ='" + txtMemberID.Text + "' ";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsg(txtFName.Text + " 's Details Updated Successfully", "Success", "success");
                        }
                    }
                    catch
                    {
                        int contactNo = 0;

                        try
                        {
                            contactNo = int.Parse(txtContact.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Contact no should be a numerical!", "Warning", "Error");
                        }
                    }
                }
            }
            con.Close();
            showMemberDetails();
            MainClass.disable_reset(panel6);
            lblMain.Text = "View";
        }
Example #7
0
        private void btnAddBooks_Click(object sender, EventArgs e)
        {
            if (btnStatus == "add")
            {
                if (BookIDNull.Visible || BookNameNull.Visible || AuthorNull.Visible)
                {
                    MainClass.showMsg("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "INSERT INTO libraryBooks (book_ID, name, author, quantity, addDate) VALUES ('" + txtBookID.Text + "','" + txtBookName.Text + "','" + txtAuthor.Text + "', '1', '" + AddDate.Text + "')";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsgLibrary(txtBookName.Text + "Successfully Added!", "Success", "Success");
                        }
                    }
                    catch
                    {
                        int book_ID = 0;

                        try
                        {
                            book_ID = int.Parse(txtBookID.Text);
                        }
                        catch
                        {
                            MainClass.showMsg("Book ID should be an numerical value!", "Warning", "Error");
                        }
                    }
                }
                con.Close();
                lblMain.Text = "View";
            }
            else if (btnStatus == "update")
            {
                if (BookIDNull.Visible || BookNameNull.Visible || AuthorNull.Visible)
                {
                    MainClass.showMsg("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "UPDATE libraryBooks SET book_ID ='" + txtBookID.Text + "' ,name='" + txtBookName.Text + "',author='" + txtAuthor.Text + "',quantity='1',addDate='" + AddDate.Text + "' where book_ID ='" + txtBookID.Text + "' ";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsgLibrary("Successfull Updated!", "Success", "Success");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error");
                    }
                }
            }
            con.Close();
            showBookDetails();
            MainClass.disable_reset(panel6);
            lblMain.Text = "View";
        }