public void selectPrice(ClothesStore clothesStore)
 {
     connection.open();
     command = new SqlCommand("select price from ClothesStore where name='" + clothesStore.getName() + "'", connection.getConnection());
     clothesStore.setPrice(double.Parse(command.ExecuteScalar().ToString()));
     connection.close();
 }
 public void updateQuantityMinus(ClothesStore clothesStore)
 {
     connection.open();
     command = new SqlCommand("update ClothesStore set quantity=quantity-'" + clothesStore.getQuantity() + "' where name='" + clothesStore.getName() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void update(ClothesStore clothesStore)
 {
     connection.open();
     command = new SqlCommand("update ClothesStore set name='" + clothesStore.getName() + "',price='" + clothesStore.getPrice() + "',quantity='" + clothesStore.getQuantity() + "' ,total='" + clothesStore.getTotal() + "' where ID='" + clothesStore.getID() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void delete(ClothesStore clothesStore)
 {
     connection.open();
     command = new SqlCommand("delete from ClothesStore where name='" + clothesStore.getName() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void deleteClothes(string clothType)
 {
     clothesStore   = new ClothesStore();
     clothesStoreDB = new ClothesStoreDB();
     clothesStore.setName(clothType);
     clothesStoreDB.delete(clothesStore);
 }
 public void insert(ClothesStore clothesStore)
 {
     connection.open();
     command = new SqlCommand("insert into ClothesStore values('" + clothesStore.getName() + "' , '" + clothesStore.getPrice() + "' , '" + clothesStore.getQuantity() + "','" + clothesStore.getTotal() + "')", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
    public Boolean UpdateClothe(string prevoiusName, string name, double price, double quantity, double total)
    {
        Boolean check = false;

        clothesStore   = new ClothesStore();
        clothesStoreDB = new ClothesStoreDB();

        if (prevoiusName.Equals("NOT CHANAGEE"))
        {
            clothesStore.setName(name);
        }
        else
        {
            clothesStore.setName(name);
            check = clothesStoreDB.checkCloth(clothesStore);
            clothesStore.setName(prevoiusName);
        }
        clothesStore.setPrice(price);
        clothesStore.setQuantity(quantity);
        clothesStore.setTotal(total);

        if (check == true)
        {
            return(false);
        }
        else
        {
            int ID = clothesStoreDB.selectClotheId(clothesStore);
            clothesStore.setID(ID);
            clothesStore.setName(name);
            clothesStoreDB.update(clothesStore);
            return(true);
        }
    }
 public double getQuantity(string itemName)
 {
     clothesStore   = new ClothesStore();
     clothesStoreDB = new ClothesStoreDB();
     clothesStore.setName(itemName);
     clothesStoreDB.selectQuantity(clothesStore);
     return(clothesStore.getQuantity());
 }
 public void updateQuantityPlus(string clothesName, double quantity)
 {
     clothesStore   = new ClothesStore();
     clothesStoreDB = new ClothesStoreDB();
     clothesStore.setName(clothesName);
     clothesStore.setQuantity(quantity);
     clothesStoreDB.updateQuantityPlus(clothesStore);
 }
 public double getClothePrice(string name)
 {
     clothesStoreDB = new ClothesStoreDB();
     clothesStore   = new ClothesStore();
     clothesStore.setName(name);
     clothesStoreDB.selectPrice(clothesStore);
     return(clothesStore.getPrice());
 }
    public int selectClotheId(ClothesStore clothesStore)
    {
        connection.open();
        command = new SqlCommand("select ID from ClothesStore where name='" + clothesStore.getName() + "'", connection.getConnection());
        int ID = (int)command.ExecuteScalar();

        connection.close();
        return(ID);
    }
    public bool checkItemInStore(string itemName)
    {
        clothesStore   = new ClothesStore();
        clothesStoreDB = new ClothesStoreDB();
        clothesStore.setName(itemName);
        bool check = clothesStoreDB.checkCloth(clothesStore);

        return(check);
    }
 public bool checkItemQuantity(string itemName, double quantity)
 {
     clothesStore   = new ClothesStore();
     clothesStoreDB = new ClothesStoreDB();
     clothesStore.setName(itemName);
     clothesStoreDB.selectQuantity(clothesStore);
     if (quantity > clothesStore.getQuantity())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
    public Boolean checkCloth(ClothesStore clothesStore)
    {
        connection.open();
        command = new SqlCommand("select count(*) from ClothesStore where name='" + clothesStore.getName() + "'", connection.getConnection());

        int PriceCount = (int)command.ExecuteScalar();

        connection.close();

        if (PriceCount > 0)
        {
            return(true); // exiting item.
        }
        else
        {
            return(false); // new item.
        }
    }
 public Boolean insertClothes(string name, double price, double quantity, double total)
 {
     clothesStore   = new ClothesStore();
     clothesStoreDB = new ClothesStoreDB();
     clothesStore.setName(name);
     clothesStore.setPrice(price);
     clothesStore.setQuantity(quantity);
     clothesStore.setTotal(total);
     check = clothesStoreDB.checkCloth(clothesStore);
     if (check == true)
     {
         return(false);
     }
     else
     {
         clothesStoreDB.insert(clothesStore);
         return(true);
     }
 }