public void deleteDevices(string deviceName)
 {
     devicesStore   = new DevicesStore();
     devicesStoreDB = new DevicesStoreDB();
     devicesStore.setName(deviceName);
     devicesStoreDB.delete(devicesStore);
 }
    public Boolean UpdateDevice(string prevoiusName, string name, double price, double quantity, double total)
    {
        Boolean check = false;

        devicesStore   = new DevicesStore();
        devicesStoreDB = new DevicesStoreDB();

        if (prevoiusName.Equals("NOT CHANAGEE"))
        {
            devicesStore.setName(name);
        }
        else
        {
            devicesStore.setName(name);
            check = devicesStoreDB.checkDevice(devicesStore);
            devicesStore.setName(prevoiusName);
        }
        devicesStore.setPrice(price);
        devicesStore.setQuantity(quantity);
        devicesStore.setTotal(total);

        if (check == true)
        {
            return(false);
        }
        else
        {
            int ID = devicesStoreDB.selectDeviceId(devicesStore);
            devicesStore.setID(ID);
            devicesStore.setName(name);
            devicesStoreDB.update(devicesStore);
            return(true);
        }
    }
 public void selectPrice(DevicesStore devicesStore)
 {
     connection.open();
     command = new SqlCommand("select price from EquipsStore where name='" + devicesStore.getName() + "'", connection.getConnection());
     devicesStore.setPrice(double.Parse(command.ExecuteScalar().ToString()));
     connection.close();
 }
 public void updateQuantityMinus(DevicesStore devicesStore)
 {
     connection.open();
     command = new SqlCommand("update EquipsStore set quantity=quantity-'" + devicesStore.getQuantity() + "' where name='" + devicesStore.getName() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void update(DevicesStore devicesStore)
 {
     connection.open();
     command = new SqlCommand("update EquipsStore set name='" + devicesStore.getName() + "',price='" + devicesStore.getPrice() + "',quantity='" + devicesStore.getQuantity() + "' ,total='" + devicesStore.getTotal() + "' where ID='" + devicesStore.getID() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void delete(DevicesStore devicesStore)
 {
     connection.open();
     command = new SqlCommand("delete from EquipsStore where name='" + devicesStore.getName() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void insert(DevicesStore devicesStore)
 {
     connection.open();
     command = new SqlCommand("insert into EquipsStore values('" + devicesStore.getName() + "' , '" + devicesStore.getPrice() + "' , '" + devicesStore.getQuantity() + "','" + devicesStore.getTotal() + "')", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public double getQuantity(string itemName)
 {
     devicesStore   = new DevicesStore();
     devicesStoreDB = new DevicesStoreDB();
     devicesStore.setName(itemName);
     devicesStoreDB.selectQuantity(devicesStore);
     return(devicesStore.getQuantity());
 }
 public void updateQuantityPlus(string deviceName, double quantity)
 {
     devicesStore   = new DevicesStore();
     devicesStoreDB = new DevicesStoreDB();
     devicesStore.setName(deviceName);
     devicesStore.setQuantity(quantity);
     devicesStoreDB.updateQuantityPlus(devicesStore);
 }
 public double getDevicePrice(string name)
 {
     devicesStoreDB = new DevicesStoreDB();
     devicesStore   = new DevicesStore();
     devicesStore.setName(name);
     devicesStoreDB.selectPrice(devicesStore);
     return(devicesStore.getPrice());
 }
    public bool checkItemInStore(string itemName)
    {
        devicesStore   = new DevicesStore();
        devicesStoreDB = new DevicesStoreDB();
        devicesStore.setName(itemName);
        bool check = devicesStoreDB.checkDevice(devicesStore);

        return(check);
    }
    public int selectDeviceId(DevicesStore devicesStore)
    {
        connection.open();
        command = new SqlCommand("select ID from EquipsStore where name='" + devicesStore.getName() + "'", connection.getConnection());
        int ID = (int)command.ExecuteScalar();

        connection.close();
        return(ID);
    }
 public bool checkItemQuantity(string itemName, double quantity)
 {
     devicesStore   = new DevicesStore();
     devicesStoreDB = new DevicesStoreDB();
     devicesStore.setName(itemName);
     devicesStoreDB.selectQuantity(devicesStore);
     if (quantity > devicesStore.getQuantity())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
    public Boolean checkDevice(DevicesStore devicesStore)
    {
        connection.open();
        command = new SqlCommand("select count(*) from EquipsStore where name='" + devicesStore.getName() + "'", connection.getConnection());

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

        connection.close();

        if (check > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
 public Boolean insertDevices(string name, double price, double quantity, double total)
 {
     devicesStore   = new DevicesStore();
     devicesStoreDB = new DevicesStoreDB();
     devicesStore.setName(name);
     devicesStore.setPrice(price);
     devicesStore.setQuantity(quantity);
     devicesStore.setTotal(total);
     check = devicesStoreDB.checkDevice(devicesStore);
     if (check == true)
     {
         return(false);
     }
     else
     {
         devicesStoreDB.insert(devicesStore);
         return(true);
     }
 }