Exemplo n.º 1
0
        private void NoExistsButton_Click(object sender, EventArgs e)
        {
            MainConn NewConObj = new MainConn();

            NoExistsButton.Enabled = false;

            for (int i = 0; i < MainGrid.Rows.Count - 1; i++)
            {
                if (int.Parse(MainGrid.Rows[i].Cells["Existencia"].Value.ToString()) == 0)
                {
                    //Delete items whit zero exists
                    NewConObj.ExecuteQuery("DELETE FROM zapateria.zapatos WHERE idZapato = "
                                           + int.Parse(MainGrid.Rows[i].Cells["idZapato"].Value.ToString()));
                }
            }
            for (int i = 0; i < this.MainGrid.Rows.Count - 1; i++)
            {
                if (int.Parse(MainGrid.Rows[i].Cells["Existencia"].Value.ToString()) == 0)
                {
                    //Delete items whit zero exists
                    NewConObj.ExecuteQuery("DELETE FROM zapateria.zapatos WHERE idZapato = "
                                           + int.Parse(MainGrid.Rows[i].Cells["idZapato"].Value.ToString()));
                }
            }
            this.StartRowsView();
            NoExistsButton.Enabled = true;
        }
Exemplo n.º 2
0
        private void DeleteShoe_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectionCol = (DataGridViewSelectedRowCollection)MainGrid.SelectedRows;
            MainConn NewConObj = new MainConn();

            string code     = string.Empty;
            int    numshoes = selectionCol.Count;

            if (selectionCol.Count == 1)
            {
                code = GetIDSelectedOneRowTableView().ToString();

                //get one items for delete one row

                DialogResult dr = AlertGenericYesNo("Desea eliminar el el zapato " +
                                                    "con el codigo: " + code + " ?", "Confirmar");
                if (dr == DialogResult.Yes)
                {
                    //delete one shoe
                    NewConObj.ExecuteQuery("DELETE FROM zapateria.zapatos WHERE idZapato = "
                                           + int.Parse(GetIDZapatoSelectedOneRowTableView().ToString()));
                    this.GenericMainGridReload();
                }
            }
            else if (selectionCol.Count > 1)
            {
                //get all items in this par for all rows and columns  and for delete

                DialogResult dr = AlertGenericYesNo("Desea eliminar los " + numshoes + " zapatos ?", "Confirmar");

                if (dr == DialogResult.Yes)
                {
                    // delete multiple shoes
                    for (int i = 0; i < selectionCol.Count; i++)
                    {
                        NewConObj.ExecuteQuery("DELETE FROM zapateria.zapatos WHERE idZapato = "
                                               + int.Parse(selectionCol[i].Cells[0].Value.ToString()));
                    }
                    this.GenericMainGridReload();
                }
            }
            else
            {
                AlertGenericOK("Ningun zapato seleccionado ", "Alerta");
            }
        }
Exemplo n.º 3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string code   = this.codeInput.Text;
            string mark   = this.markSelect.Text; // select  marca check if exists or new
            string model  = this.modelInput.Text;
            string tacon  = this.taconInput.Text;
            int    exists = int.Parse(this.numericUpDown1.Value.ToString());
            // future prevent double queryes
            string query =
                "UPDATE zapatos  " +
                "set codigo ='" + code + "', " +
                "idMarca = " + this.getIdMark(mark) + ", " +
                "Modelo = '" + model + "'," +
                "tacon ='" + tacon + "' " +
                " WHERE idZapato = " + IdShoe;  // id marca select new
            string queryExists =
                "UPDATE tallas set Existencia =" + exists +
                " WHERE idZapato= " + IdShoe + " AND " +
                "Talla = 8";

            NewConObj.ExecuteQuery(query);
            NewConObj.ExecuteQuery(queryExists);
        }