How to validate the fields in the database?

0

I want to know how to validate when a number that is inserted from the application is greater than the value I have in the database so that it is not less than zero or when the value is equal to zero, I am programming in three layers, this It's my code;

** business

public DataTable Comcantidad(String SKU)
     {
        DataTable dt = new DataTable();
        String query = "SELECT Cantidad FROM almacen WHERE SKU = '" + SKU + "'";
        dt = daccess.select(query);
        return dt;
     }

** view

DataTable num = biss.Comcantidad(txt_sku.Text);
        Double cant = Double.Parse(num.Rows[0]["Cantidad"].ToString());
        if (cant == 0)
        {
            MessageBox.Show("No se pueden hacer salidas porque la cantidad del prodeucto es 0");
            this.txt_sku.Clear();
            this.txt_status.Clear();
            this.txt_descripcion.Clear();
            this.txt_unidad.Clear();
            this.txt_costo.Clear();
            this.txt_cantidad.Clear();
            this.txt_proveedor.Clear();
            this.txt_familia.Clear();
        }
        else
        {
            DataTable Obtenerid = biss.MllenartxtDesc(txt_descripcion.Text);
            int ids = Int32.Parse(Obtenerid.Rows[0]["Status"].ToString());
            int idu = Int32.Parse(Obtenerid.Rows[0]["Unidad"].ToString());
            int idp = Int32.Parse(Obtenerid.Rows[0]["Proveedor"].ToString());
            int idf = Int32.Parse(Obtenerid.Rows[0]["Familia"].ToString());

            biss.Gsalidas(txt_sku.Text, ids, txt_descripcion.Text, idu, Convert.ToDouble(txt_cantidad.Text), idp, idf, Convert.ToDouble(txt_costo.Text));

            biss.Aalmacenmenos(txt_sku.Text, Convert.ToDouble(txt_cantidad.Text));

            Close();
        }
    
asked by Macx 22.06.2018 в 16:32
source

0 answers