Exemple #1
0
        public bool addUser(String employeeName, String userName, String password, String designation)
        {
            DatabaseOperations operations   = new DatabaseOperations();
            String             addUserQuery = "INSERT INTO UserDetails (UserName, Password) VALUES ('" + userName + "','" + password + "')";
            int lastEmployeeID;

            if (operations.executeSelectQuery("SELECT TOP 1 EmployeeID FROM EmployeeDetails ORDER BY EmployeeID DESC").Rows.Count > 0)
            {
                lastEmployeeID = int.Parse(operations.executeSelectQuery("SELECT TOP 1 EmployeeID FROM EmployeeDetails ORDER BY EmployeeID DESC").Rows[0][0].ToString());
            }
            else
            {
                lastEmployeeID = 101;
            }
            int    designationID    = int.Parse(operations.executeSelectQuery("SELECT DesignationID FROM Designation WHERE DesignationName='" + designation.ToLower() + "'").Rows[0][0].ToString());
            String addEmployeeQuery = "INSERT INTO EmployeeDetails VALUES(" + (lastEmployeeID + 1) + "," + designationID + ",'" + employeeName + "','" + userName + "')";

            try
            {
                if (operations.executeInsUpdDelQuery(addUserQuery) == 1 && operations.executeInsUpdDelQuery(addEmployeeQuery) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public bool addNewOrder(Order newOrder)
        {
            DatabaseOperations operations = new DatabaseOperations();

            try
            {
                int       paperTypeID     = int.Parse(operations.executeSelectQuery("SELECT PaperTypeID FROM PaperType WHERE PaperTypeName='" + newOrder.PaperType + "'").Rows[0][0].ToString());
                int       statusTypeID    = int.Parse(operations.executeSelectQuery("SELECT OrderStatusID FROM OrderStatus WHERE OrderStatusName='" + newOrder.OrderStatus + "'").Rows[0][0].ToString());
                DataTable customerDetails = operations.executeSelectQuery("SELECT * FROM CustomerDetails WHERE CustomerName='" + newOrder.Customer.Name + "' AND CustomerContactNumber=" + newOrder.Customer.ContactNumber);
                if (customerDetails.Rows.Count == 0)
                {
                    DataTable allCustomerDetails = operations.executeSelectQuery("SELECT * FROM CustomerDetails");
                    if (allCustomerDetails.Rows.Count == 0)
                    {
                        operations.executeInsUpdDelQuery("INSERT INTO CustomerDetails (CustomerID, CustomerName, CustomerAddress, CustomerContactNumber) VALUES (" + 1 + ",'" + newOrder.Customer.Name + "','" + newOrder.Customer.Address + "," + newOrder.Customer.ContactNumber + ")");
                        newOrder.Customer.ID = 1;
                    }
                    else
                    {
                        int lastCustomerID = (int)allCustomerDetails.Rows[allCustomerDetails.Rows.Count - 1][0];
                        operations.executeInsUpdDelQuery("INSERT INTO CustomerDetails (CustomerID, CustomerName, CustomerAddress, CustomerContactNumber) VALUES (" + (lastCustomerID + 1) + ",'" + newOrder.Customer.Name + "','" + newOrder.Customer.Address + "'," + newOrder.Customer.ContactNumber + ")");
                        newOrder.Customer.ID = lastCustomerID + 1;
                    }
                    int i = operations.executeInsUpdDelQuery("INSERT INTO OrderDetails (OrderID, CustomerID, DesignID, PaperTypeID, OrderStatusID, Quantity, Size, DeliveryDate, PerProductCost, AdvancePayment, OrderDelivered, Color) VALUES (" + newOrder.OrderID + "," + newOrder.Customer.ID + ",'" + newOrder.DesignID + "'," + paperTypeID + "," + statusTypeID + "," + newOrder.Quantity + ",'" + newOrder.Size + "','" + newOrder.DeliveryDate + "'," + newOrder.UnitPrice + "," + newOrder.AdvancePayment + ",0,'" + newOrder.Color + "')");
                    int j = operations.executeUpdImageQuery("OrderDetails", "FinalDesignToBePrinted", newOrder.FinalizedDesign, "OrderID", newOrder.OrderID.ToString());
                    if (i == 1 && j == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    newOrder.Customer.ID = int.Parse(customerDetails.Rows[0][0].ToString());
                    int i = operations.executeInsUpdDelQuery("INSERT INTO OrderDetails (OrderID, CustomerID, DesignID, PaperTypeID, OrderStatusID, Quantity, Size, DeliveryDate, PerProductCost, AdvancePayment, OrderDelivered, Color) VALUES (" + newOrder.OrderID + "," + newOrder.Customer.ID + ",'" + newOrder.DesignID + "'," + paperTypeID + "," + statusTypeID + "," + newOrder.Quantity + ",'" + newOrder.Size + "','" + newOrder.DeliveryDate + "'," + newOrder.UnitPrice + "," + newOrder.AdvancePayment + ",0,'" + newOrder.Color + "')");
                    int j = operations.executeUpdImageQuery("OrderDetails", "FinalDesignToBePrinted", newOrder.FinalizedDesign, "OrderID", newOrder.OrderID.ToString());
                    if (i == 1 && j == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #3
0
        public bool editDesign(Design d)
        {
            DatabaseOperations operations = new DatabaseOperations();
            int paperTypeID = int.Parse(operations.executeSelectQuery("SELECT PaperTypeID FROM PaperType WHERE PaperType.PaperTypeName='" + d.DesignPaperType + "'").Rows[0][0].ToString());

            return(operations.executeInsUpdDelQuery("UPDATE Design SET DesignName='" + d.DesignName + "', Size='" + d.DesignSize + "', PaperTypeID=" + paperTypeID + " WHERE DesignID='" + d.DesignID + "'") == 1);
        }
Exemple #4
0
 public bool changePassword(String userName, String oldPassword, string newPassword)
 {
     try
     {
         DatabaseOperations operations = new DatabaseOperations();
         DataTable          users      = new DataTable();
         users = operations.executeSelectQuery("Select * from UserDetails where UserName='******' AND Password='******'");
         if (users.Rows.Count == 1)
         {
             if (operations.executeInsUpdDelQuery("UPDATE UserDetails SET Password='******' WHERE UserName='******'") == 1)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool applyPayment(int orderID, int paymentAmount)
        {
            DatabaseOperations operations = new DatabaseOperations();

            if (operations.executeInsUpdDelQuery("UPDATE OrderDetails SET AdvancePayment=AdvancePayment+" + paymentAmount + "WHERE OrderID=" + orderID) == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        public bool deleteUser(String userName)
        {
            DatabaseOperations operations          = new DatabaseOperations();
            String             deleteUserQuery     = "DELETE FROM UserDetails WHERE UserName='******'";
            String             deleteEmployeeQuery = "DELETE FROM EmployeeDetails WHERE UserName='******'";


            try
            {
                if (operations.executeInsUpdDelQuery(deleteUserQuery) == 1 && operations.executeInsUpdDelQuery(deleteEmployeeQuery) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #7
0
        public bool addCategory(string categoryName)
        {
            DatabaseOperations operations  = new DatabaseOperations();
            DataTable          categoryIDs = operations.executeSelectQuery("SELECT CategoryID FROM Category");
            int lastcategoryID             = 0;

            if (categoryIDs.Rows.Count > 0)
            {
                lastcategoryID = int.Parse(categoryIDs.Rows[categoryIDs.Rows.Count - 1][0].ToString());
            }
            if (operations.executeInsUpdDelQuery("INSERT INTO Category VALUES(" + (lastcategoryID + 1) + ",'" + categoryName + "')") == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #8
0
        public bool addProduct(string categoryName, string productName)
        {
            DatabaseOperations operations = new DatabaseOperations();
            int       categoryID          = int.Parse(operations.executeSelectQuery("SELECT CategoryID FROM Category WHERE CategoryName='" + categoryName + "'").Rows[0][0].ToString());
            DataTable productIDs          = operations.executeSelectQuery("SELECT ProductID FROM Product");
            int       lastProductID       = 0;

            if (productIDs.Rows.Count > 0)
            {
                lastProductID = int.Parse(productIDs.Rows[productIDs.Rows.Count - 1][0].ToString());
            }
            if (operations.executeInsUpdDelQuery("INSERT INTO Product VALUES(" + (lastProductID + 1) + "," + categoryID + ",'" + productName + "')") == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #9
0
        public bool editOrder(Order order)
        {
            DatabaseOperations operations = new DatabaseOperations();
            int paperTypeID  = int.Parse(operations.executeSelectQuery("SELECT PaperTypeID FROM PaperType WHERE PaperTypeName='" + order.PaperType + "'").Rows[0][0].ToString());
            int statusTypeID = int.Parse(operations.executeSelectQuery("SELECT OrderStatusID FROM OrderStatus WHERE OrderStatusName='" + order.OrderStatus + "'").Rows[0][0].ToString());
            int i            = operations.executeInsUpdDelQuery("UPDATE OrderDetails SET DesignID='" + order.DesignID + "', PaperTypeID=" + paperTypeID + ", Size='" + order.Size + "', OrderStatusID=" + statusTypeID + ", Quantity=" + order.Quantity + ", DeliveryDate='" + order.DeliveryDate.ToString() + "', PerProductCost=" + order.UnitPrice + ", AdvancePayment=" + order.AdvancePayment + " WHERE OrderID=" + order.OrderID);
            int j            = 1;

            if (order.FinalizedDesign != "Click Here")
            {
                j = operations.executeUpdImageQuery("OrderDetails", "FinalDesignToBePrinted", order.FinalizedDesign, "OrderID", order.OrderID.ToString());
            }
            if (i == 1 && j == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #10
0
        public bool setOrderStatus(int orderID, string status)
        {
            DatabaseOperations operations = new DatabaseOperations();

            try
            {
                int statusID = int.Parse(operations.executeSelectQuery("SELECT OrderStatusID FROM OrderStatus WHERE OrderStatusName='" + status + "'").Rows[0][0].ToString());
                if (operations.executeInsUpdDelQuery("UPDATE OrderDetails SET OrderStatusID=" + statusID + " WHERE OrderID=" + orderID) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #11
0
        public bool resetPassword(String userName)
        {
            DatabaseOperations operations         = new DatabaseOperations();
            String             resetPasswordQuery = "UPDATE UserDetails SET Password='******' WHERE UserName='******'";

            try
            {
                if (operations.executeInsUpdDelQuery(resetPasswordQuery) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #12
0
 public bool saveDesign(Design d)
 {
     try
     {
         DatabaseOperations operations = new DatabaseOperations();
         int paperTypeID = int.Parse(operations.executeSelectQuery("SELECT PaperTypeID FROM PaperType WHERE PaperType.PaperTypeName='" + d.DesignPaperType + "'").Rows[0][0].ToString());
         int productID   = int.Parse(operations.executeSelectQuery("SELECT ProductID FROM Product WHERE Product.ProductName='" + d.ProductName + "'").Rows[0][0].ToString());
         int i           = operations.executeInsUpdDelQuery("INSERT INTO Design (DesignID, DesignName, ProductID, PaperTypeID, Size) VALUES('" + d.DesignID + "','" + d.DesignName + "'," + productID + "," + paperTypeID + ",'" + d.DesignSize + "')");
         int j           = operations.executeUpdImageQuery("Design", "DesignFile", d.DesignFilePath, "DesignID", d.DesignID);
         if (i == 1 && j == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #13
0
        public int deleteOrder(int orderID)
        {
            DatabaseOperations operations = new DatabaseOperations();

            return(operations.executeInsUpdDelQuery("DELETE FROM OrderDetails WHERE OrderID=" + orderID));
        }