Ejemplo n.º 1
0
    public void updateInsert(string locationName, ListView listView)
    {
        locationClothesControl   = new LocationClothesControl();
        locationClothesContent   = new LocationClothesContent();
        locationClothesContentDB = new LocationClothesContentDB();
        int locationClothesID = locationClothesControl.getID(locationName);

        foreach (ListViewItem item in listView.Items)
        {
            string name     = item.SubItems[0].Text;
            double price    = double.Parse(item.SubItems[1].Text);
            double quantity = double.Parse(item.SubItems[2].Text);
            double total    = double.Parse(item.SubItems[3].Text);

            locationClothesContent.setName(name);
            locationClothesContent.setLocationClothesID(locationClothesID);
            locationClothesContent.setQuantity(quantity);
            bool check = locationClothesContentDB.checkIfExist(locationClothesContent);
            if (check == true)
            {
                locationClothesContentDB.update(locationClothesContent);
            }
            else
            {
                locationClothesContent.setPrice(price);
                locationClothesContent.setQuantity(quantity);
                locationClothesContent.setTotal(total);
                locationClothesContentDB.insert(locationClothesContent);
            }
        }
    }
Ejemplo n.º 2
0
    public void fillListView(ListView listView, string locationName)
    {
        locationClothesControl   = new LocationClothesControl();
        locationClothesContent   = new LocationClothesContent();
        locationClothesContentDB = new LocationClothesContentDB();
        //bool check = locationClothesControl.checkIfLocationHasClothes(locationName);
        double total = locationClothesControl.getTotal(locationName);

        if (total == 0)
        {
            listView.Items.Clear();
        }
        else
        {
            int ID = locationClothesControl.getID(locationName);
            connection = new DBConnection();
            listView.Items.Clear();
            locationClothesContent.setLocationClothesID(ID);
            SqlDataReader reader = locationClothesContentDB.fillListView(locationClothesContent);
            while (reader.Read())
            {
                ListViewItem lvi = new ListViewItem(reader["name"].ToString());
                lvi.SubItems.Add(reader["price"].ToString());
                lvi.SubItems.Add(reader["quantity"].ToString());
                lvi.SubItems.Add(reader["total"].ToString());
                listView.Items.Add(lvi);
            }
            connection.close();
        }
    }
Ejemplo n.º 3
0
 public void deleteCheckedItems(ListView listView, string locationName)
 {
     clothesStoreControl      = new ClothesStoreControl();
     locationClothesContent   = new LocationClothesContent();
     locationClothesContentDB = new LocationClothesContentDB();
     if (listView.CheckedItems.Count == 0)
     {
         return;
     }
     else
     {
         foreach (ListViewItem item in listView.CheckedItems)
         {
             string name     = item.SubItems[0].Text;
             double price    = double.Parse(item.SubItems[1].Text);
             double quantity = double.Parse(item.SubItems[2].Text);
             double total    = double.Parse(item.SubItems[3].Text);
             item.Remove();
             this.deletedClothesItems(name, locationName);
             bool flag = clothesStoreControl.insertClothes(name, price, quantity, total);
             if (flag == true)
             {
                 //inserted in store
             }
             else
             {
                 //update quantity in store
                 clothesStoreControl.updateQuantityPlus(name, quantity);
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void insert(ListView listView)
 {
     if (listView.Items.Count == 0)
     {
         return;
     }
     else
     {
         locationClothesContent   = new LocationClothesContent();
         locationClothesContentDB = new LocationClothesContentDB();
         locationClothesControl   = new LocationClothesControl();
         clothesStoreControl      = new ClothesStoreControl();
         int locationClothesID = locationClothesControl.getLastID();
         foreach (ListViewItem lvi in listView.Items)
         {
             string name     = lvi.SubItems[0].Text;
             double price    = double.Parse(lvi.SubItems[1].Text);
             double quantity = double.Parse(lvi.SubItems[2].Text);
             double total    = double.Parse(lvi.SubItems[3].Text);
             locationClothesContent.setName(name);
             locationClothesContent.setPrice(price);
             locationClothesContent.setQuantity(quantity);
             locationClothesContent.setTotal(total);
             locationClothesContent.setLocationClothesID(locationClothesID);
             clothesStoreControl.updateQuantityMinus(name, quantity);
             locationClothesContentDB.insert(locationClothesContent);
         }
     }
 }
 public void updateItem(LocationClothesContent locationClothesContent)
 {
     connection.open();
     command = new SqlCommand("update LocationClothesContent set quantity='" + locationClothesContent.getQuantity() + "' , total='" + locationClothesContent.getTotal() + "' where name='" + locationClothesContent.getName() + "' and locationClothesID='" + locationClothesContent.getLocationClothesID() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void delete(LocationClothesContent locationClothesContent)
 {
     connection.open();
     command = new SqlCommand("delete from LocationClothesContent where name='" + locationClothesContent.getName() + "' and locationClothesID='" + locationClothesContent.getLocationClothesID() + "'", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
 public void insert(LocationClothesContent locationClothesContent)
 {
     connection.open();
     command = new SqlCommand("insert into LocationClothesContent values('" + locationClothesContent.getName() + "' , '" + locationClothesContent.getPrice() + "' , '" + locationClothesContent.getQuantity() + "' , '" + locationClothesContent.getTotal() + "' , '" + locationClothesContent.getLocationClothesID() + "')", connection.getConnection());
     command.ExecuteNonQuery();
     connection.close();
 }
    public SqlDataReader fillListView(LocationClothesContent locationClothesContent)
    {
        connection.open();
        command = new SqlCommand("select * from LocationClothesContent where locationClothesID='" + locationClothesContent.getLocationClothesID() + "'", connection.getConnection());
        SqlDataReader reader = command.ExecuteReader();

        return(reader);
    }
Ejemplo n.º 9
0
    public void deletedClothesItems(string itemName, string locationName)
    {
        locationClothesControl   = new LocationClothesControl();
        locationClothesContent   = new LocationClothesContent();
        locationClothesContentDB = new LocationClothesContentDB();
        int locationClothesID = locationClothesControl.getID(locationName);

        locationClothesContent.setName(itemName);
        locationClothesContent.setLocationClothesID(locationClothesID);
        locationClothesContentDB.delete(locationClothesContent);
    }
Ejemplo n.º 10
0
    public void updateItem(string itemName, double quantity, double total, string locationName)
    {
        locationClothesControl   = new LocationClothesControl();
        locationClothesContent   = new LocationClothesContent();
        locationClothesContentDB = new LocationClothesContentDB();
        int locationClothesID = locationClothesControl.getID(locationName);

        locationClothesContent.setLocationClothesID(locationClothesID);
        locationClothesContent.setName(itemName);
        locationClothesContent.setQuantity(quantity);
        locationClothesContent.setTotal(total);
        locationClothesContentDB.updateItem(locationClothesContent);
    }
    public bool checkIfExist(LocationClothesContent locationClothesContent)
    {
        connection.open();
        command = new SqlCommand("select count(*) from LocationClothesContent where name='" + locationClothesContent.getName() + "'", connection.getConnection());

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

        connection.close();

        if (count > 0)
        {
            return(true); // exiting item.
        }
        else
        {
            return(false); // new item.
        }
    }
Ejemplo n.º 12
0
    public void insertItem(string itemName, double price, double quantity, double total, string locationName, ListView listview)
    {
        locationClothesControl   = new LocationClothesControl();
        locationClothesContent   = new LocationClothesContent();
        locationClothesContentDB = new LocationClothesContentDB();
        int locationClothesID = locationClothesControl.getID(locationName);

        locationClothesContent.setLocationClothesID(locationClothesID);
        locationClothesContent.setName(itemName);
        locationClothesContent.setPrice(price);
        locationClothesContent.setQuantity(quantity);
        locationClothesContent.setTotal(total);
        locationClothesContentDB.insert(locationClothesContent);
        //insert to listView
        ListViewItem item = new ListViewItem(itemName);

        item.SubItems.Add(price.ToString());
        item.SubItems.Add(quantity.ToString());
        item.SubItems.Add(total.ToString());
        listview.Items.Add(item);
    }