Ejemplo n.º 1
0
        public bool orderExists(int orderID)
        {
            DatabaseOperations operations = new DatabaseOperations();

            if (operations.executeSelectQuery("SELECT * FROM OrderDetails WHERE OrderID=" + orderID).Rows.Count == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        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);
            }
        }
Ejemplo n.º 3
0
        public bool isOrderDelivered(int orderID)
        {
            DatabaseOperations operations = new DatabaseOperations();
            int del = int.Parse(operations.executeSelectQuery("SELECT OrderStatusID FROM OrderStatus WHERE OrderStatusName='Delivered'").Rows[0][0].ToString());

            if (int.Parse(operations.executeSelectQuery("SELECT OrderStatusID FROM OrderDetails WHERE OrderID=" + orderID).Rows[0][0].ToString()) == del)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public DataTable searchOrder(DateTime deliveryDate)
        {
            DatabaseOperations operations   = new DatabaseOperations();
            DataTable          orderDetails = operations.executeSelectQuery("SELECT * FROM OrderDetails WHERE DeliverDate='" + deliveryDate + "'");

            if (orderDetails.Rows.Count > 0)
            {
                return(orderDetails);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public DataTable searchOrder(int orderID)
        {
            DatabaseOperations operations   = new DatabaseOperations();
            DataTable          orderDetails = operations.executeSelectQuery("SELECT * FROM OrderDetails WHERE OrderID=" + orderID);

            if (orderDetails.Rows.Count > 0)
            {
                return(orderDetails);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        public int returnNextOrderID()
        {
            DatabaseOperations operations = new DatabaseOperations();
            DataTable          dt         = operations.getTableData("OrderDetails", "OrderID");

            if (dt.Rows.Count == 0)
            {
                return(10001);
            }
            else
            {
                return((int)dt.Rows[dt.Rows.Count - 1][0] + 1);
            }
        }
Ejemplo n.º 7
0
        public DataTable searchOrder(int orderID)
        {
            DatabaseOperations operations   = new DatabaseOperations();
            DataTable          orderDetails = operations.executeSelectQuery("SELECT OrderDetails.OrderID, CustomerDetails.CustomerName, CustomerDetails.CustomerContactNumber, OrderDetails.DeliveryDate, OrderDetails.Quantity, Category.CategoryName, OrderStatus.OrderStatusName FROM OrderStatus,CustomerDetails,OrderDetails, Category, Product, Design WHERE OrderStatus.OrderStatusID=OrderDetails.OrderStatusID and OrderDetails.CustomerID=CustomerDetails.CustomerID AND Category.CategoryID = Product.CategoryID AND Product.ProductID = Design.ProductID AND Design.DesignID = OrderDetails.DesignID AND OrderDetails.OrderID=" + orderID);

            if (orderDetails.Rows.Count > 0)
            {
                return(orderDetails);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
        public DataSet getAllOrders()
        {
            DatabaseOperations operations   = new DatabaseOperations();
            DataTable          orderDetails = operations.executeSelectQuery("SELECT OrderDetails.CustomerID,OrderDetails.OrderID,OrderDetails.DeliveryDate,OrderDetails.Quantity,OrderStatus.OrderStatusName,CustomerDetails.CustomerName FROM OrderStatus,OrderDetails,CustomerDetails WHERE OrderStatus.OrderStatusID=OrderDetails.OrderStatusID and CustomerDetails.CustomerID=OrderDetails.CustomerID").Copy();

            orderDetails.TableName = "order";
            DataTable status = operations.executeSelectQuery("Select OrderStatusName from OrderStatus").Copy();

            status.TableName = "status";
            DataSet ds = new DataSet();

            ds.Tables.Add(orderDetails);
            ds.Tables.Add(status);
            //CustomerDetails.CustomerName FROM OrderDetails,CustomerDetails where CustomerDetails.CustomerID=OrderDetails.CustomerID'");
            return(ds);
        }
Ejemplo n.º 9
0
        public LoginStatus isValidUser(String username, String password)
        {
            Employee           employee   = null;
            DatabaseOperations operations = new DatabaseOperations();
            DataTable          users      = new DataTable();

            users = operations.executeSelectQuery("Select * from UserDetails where UserName='******' AND Password='******'");
            if (users.Rows.Count == 1)
            {
                DataTable userType = new DataTable();
                userType = operations.executeSelectQuery("Select DesignationName FROM Designation where DesignationID =(Select DesignationID from EmployeeDetails where UserName='******')");

                if (userType.Rows[0][0].ToString().Equals("Admin"))
                {
                    employee = new Admin();
                }
                else if (userType.Rows[0][0].ToString().Equals("Receptionist"))
                {
                    employee = new Receptionist();
                }
                else if (userType.Rows[0][0].ToString().Equals("Designer"))
                {
                    employee = new Designer();
                }
                else if (userType.Rows[0][0].ToString().Equals("Manufacturing Worker"))
                {
                    employee = new ManufacturingWorker();
                }

                employee.EmployeeName = username;
                if (username.Equals(password))
                {
                    return(new LoginStatus(true, true, employee));
                }
                else
                {
                    return(new LoginStatus(false, true, employee));
                }
            }
            else
            {
                return(new LoginStatus(false, false, employee));
            }
        }
Ejemplo n.º 10
0
        public DataTable searchOrder(String customerName)
        {
            DatabaseOperations operations      = new DatabaseOperations();
            DataTable          customerDetails = operations.executeSelectQuery("SELECT CustomerID FROM CustomerDetails WHERE CustomerName=" + customerName);

            if (customerDetails.Rows.Count > 0)
            {
                DataTable orderDetails = operations.executeSelectQuery("SELECT * FROM OrderDetails WHERE CustomerID=" + customerDetails.Rows[0][0]);
                if (orderDetails.Rows.Count > 0)
                {
                    return(orderDetails);
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
Ejemplo n.º 11
0
        public List <Design> getDesignByName(string designName)
        {
            DatabaseOperations operations = new DatabaseOperations();
            DataTable          designs    = operations.executeSelectQuery("SELECT * FROM Design WHERE Design.DesignName LIKE '" + designName + "%'");
            List <Design>      designList = new List <Design>();

            foreach (DataRow dr in designs.Rows)
            {
                Design d = new Design();
                d.DesignID   = dr[0].ToString();
                d.DesignName = dr[1].ToString();
                d.DesignFile = (byte[])dr[2];
                string paperTypeName = operations.executeSelectQuery("SELECT PaperTypeName FROM PaperType WHERE PaperType.PaperTypeID=" + dr[5].ToString()).Rows[0][0].ToString();
                d.DesignPaperType = paperTypeName;
                d.DesignSize      = dr[6].ToString();
                designList.Add(d);
            }
            return(designList);
        }
Ejemplo n.º 12
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);
            }
        }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
        public List <Design> getAllDesigns(string productName)
        {
            DatabaseOperations operations = new DatabaseOperations();
            int           productID       = int.Parse(operations.executeSelectQuery("SELECT ProductID FROM Product WHERE Product.ProductName='" + productName + "'").Rows[0][0].ToString());
            DataTable     designs         = operations.executeSelectQuery("SELECT * FROM Design WHERE Design.ProductID=" + productID);
            List <Design> designList      = new List <Design>();

            foreach (DataRow dr in designs.Rows)
            {
                Design d = new Design();
                d.DesignID   = dr[0].ToString();
                d.DesignName = dr[1].ToString();
                d.DesignFile = (byte[])dr[2];
                string paperTypeName = operations.executeSelectQuery("SELECT PaperTypeName FROM PaperType WHERE PaperType.PaperTypeID=" + dr[5].ToString()).Rows[0][0].ToString();
                d.DesignPaperType = paperTypeName;
                d.DesignSize      = dr[6].ToString();
                designList.Add(d);
            }
            return(designList);
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
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;
            }
        }
Ejemplo n.º 18
0
        public Order getOrderByID(int orderID)
        {
            DatabaseOperations operations   = new DatabaseOperations();
            DataTable          orderDetails = operations.executeSelectQuery("SELECT * FROM OrderDetails WHERE OrderID=" + orderID);
            Order order = new Order();

            order.OrderID        = int.Parse(orderDetails.Rows[0][0].ToString());
            order.DesignID       = orderDetails.Rows[0][2].ToString();
            order.Quantity       = int.Parse(orderDetails.Rows[0][3].ToString());
            order.Size           = orderDetails.Rows[0][6].ToString();
            order.DesignFile     = (byte[])orderDetails.Rows[0][7];
            order.DeliveryDate   = ((DateTime)orderDetails.Rows[0][8]);
            order.UnitPrice      = int.Parse(orderDetails.Rows[0][9].ToString());
            order.AdvancePayment = int.Parse(orderDetails.Rows[0][10].ToString());
            DataTable customerDetails = operations.executeSelectQuery("SELECT * FROM CustomerDetails WHERE CustomerID=" + orderDetails.Rows[0][1].ToString());

            order.Customer    = new Customer(int.Parse(customerDetails.Rows[0][0].ToString()), customerDetails.Rows[0][1].ToString(), customerDetails.Rows[0][2].ToString(), long.Parse(customerDetails.Rows[0][3].ToString()));
            order.DesigName   = operations.executeSelectQuery("Select DesignName from Design WHERE DesignID='" + order.DesignID + "'").Rows[0][0].ToString();
            order.PaperType   = operations.executeSelectQuery("Select PaperTypeName from PaperType WHERE PaperTypeID=" + orderDetails.Rows[0][4].ToString()).Rows[0][0].ToString();
            order.OrderStatus = operations.executeSelectQuery("Select OrderStatusName from OrderStatus WHERE OrderStatusID=" + orderDetails.Rows[0][4].ToString()).Rows[0][0].ToString();
            return(order);
        }
Ejemplo n.º 19
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;
            }
        }
Ejemplo n.º 20
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);
     }
 }
Ejemplo n.º 21
0
        public int deleteOrder(int orderID)
        {
            DatabaseOperations operations = new DatabaseOperations();

            return(operations.executeInsUpdDelQuery("DELETE FROM OrderDetails WHERE OrderID=" + orderID));
        }
        public DataTable remainingPayments()
        {
            DatabaseOperations operations = new DatabaseOperations();

            return(operations.executeSelectQuery("Select OrderDetails.OrderID, CustomerDetails.CustomerName, CustomerDetails.CustomerContactNumber, OrderDetails.DeliveryDate, OrderDetails.AdvancePayment, ((OrderDetails.Quantity * OrderDetails.PerProductCost)- OrderDetails.AdvancePayment) AS RemainingPayment, (OrderDetails.Quantity*OrderDetails.PerProductCost) AS TotalCost FROM OrderDetails, CustomerDetails WHERE OrderDetails.CustomerID=CustomerDetails.CustomerID AND ((OrderDetails.Quantity * OrderDetails.PerProductCost)- OrderDetails.AdvancePayment)>0"));
        }