public DetalleOrdenCompra(int pidDetOC, int pcant, OrdenCompra pidOCpra, Material pidMaterial, float ppcioU)
 {
     idDetOrdenCpra = pidDetOC;
     cantidad = pcant;
     idMaterial = pidMaterial;
     precioUnit = ppcioU;
 }
Beispiel #2
0
 private void ViewMaterial(Material material)
 {
     FormEditable = false;
     CargarFormulario(material);
     pnlCrear.Visible = true;
     divIdMaterial.Visible = true;
     btnCancelar.Visible = false;
     btnCerrar.Visible = true;
     btnEditar.Visible = true;
     btnEliminar.Visible = true;
     btnGuardar.Visible = false;
     btnCrear.Visible = false;
     btnNuevo.Visible = false;
 }
Beispiel #3
0
 private Material ExtractFormData()
 {
     int? idMaterial = (int?)ViewState["idMaterial"];
     Material material = new Material();
     material.IdMaterial = idMaterial;
     material.Denominacion = txtDenominacion.Text;
     material.Caracteristicas = txtCaracteristicas.Text;
     decimal stockMinimo;
     decimal.TryParse(txtStockMinimo.Text, out stockMinimo);
     material.StockMin = stockMinimo;
     decimal stockReal;
     decimal.TryParse(txtStockReal.Text, out stockReal);
     material.StockReal = stockReal;
     material.StockAsign = 0;
     UnidadMedida unidad = new UnidadMedida();
     int idMedida;
     int.TryParse(ddlUnidadMedida.SelectedValue, out idMedida);
     unidad.UdMedida = idMedida;
     material.UdMedida = unidad;
     return material;
 }
Beispiel #4
0
        protected void CargarFormulario(Material material)
        {
            showIdMaterial.Text = "" + material.IdMaterial;

            txtDenominacion.Text = material.Denominacion;
            showDenominacion.Text = material.Denominacion;

            txtCaracteristicas.Text = material.Caracteristicas;
            showCaracteristicas.Text = material.Caracteristicas;

            txtStockMinimo.Text =  (material.StockMin != null ? material.StockMin.ToString() : null);
            showStockMinimo.Text = (material.StockMin != null ? material.StockMin.ToString() : null);

            txtStockReal.Text = (material.StockReal != null ? material.StockReal.ToString() : null);
            showStockReal.Text = (material.StockReal != null ? material.StockReal.ToString() : null);

            ddlUnidadMedida.SelectedValue = (material.UdMedida == null ? null : material.UdMedida.UdMedida.ToString());
            showUnidadMedida.Text = (material.UdMedida == null ? null : material.UdMedida.Nombre);
        }
Beispiel #5
0
        public static List<MaterialMueble> GetByIdMueble(Mueble item)
        {
            SqlDataReader reader = null;
            SqlConnection connection = null;

            connection = new SqlConnection(MuebleDAO.CONNECTION_STRING);

            string query = "SELECT m.id_material "
                + ",m.denominacion "
                + ",m.caracteristicas "
                + ",m.stock_minimo "
                + ",m.stock_real "
                + ",m.stock_asignado "
                + ",m.id_ud_medida "
                + ",mm.cantidad "
                + "From Materiales m, Materiales_Muebles mm  "
                + "WHERE mm.idMueble = @idMueble ";

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = query;
            cmd.Connection = connection;
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@idMueble", item.IdMueble);

            connection.Open();
            reader = cmd.ExecuteReader();

            List<MaterialMueble> materialMueble = new List<MaterialMueble>();

            if (reader.Read())
            {
                MaterialDAO matDao = new MaterialDAO();
                Material material = new Material();
                material.IdMaterial = (int?)reader["id_material"];
                material.Denominacion = (string)reader["denominacion"];
                material.Caracteristicas = (string)reader["caracteristicas"];
                material.StockMin = (Decimal)reader["stock_minimo"];
                material.StockReal = (Decimal)reader["stock_real"];
                material.StockAsign = (Decimal)reader["stock_asignado"];
                int? idUnidadMedida = (int?)reader["id_ud_medida"];
                if (idUnidadMedida != null)
                {
                    material.UdMedida = UnidadMedidaDAO.GetById(idUnidadMedida.Value);
                }
                MaterialMueble mm = new MaterialMueble();
                mm.Cantidad = (Int32)reader["cantidad"];
                mm.Material = material;
                materialMueble.Add(mm);
            }

            return materialMueble;
        }
Beispiel #6
0
 public static Material GetById(int id)
 {
     Material material = new Material();
     material.IdMaterial = id;
     return GetById(material);
 }
Beispiel #7
0
 public static int Delete(int idMaterial)
 {
     Material material = new Material();
     material.IdMaterial = idMaterial;
     return Delete(material);
 }
Beispiel #8
0
 private static List<SqlParameter> LoadParameters(Material item)
 {
     List<SqlParameter> parameters = new List<SqlParameter>();
     parameters.Add(new SqlParameter("id_material", item.IdMaterial));
     parameters.Add(new SqlParameter("denominacion", item.Denominacion));
     parameters.Add(new SqlParameter("caracteristicas", item.Caracteristicas));
     parameters.Add(new SqlParameter("stockMinimo", item.StockMin));
     parameters.Add(new SqlParameter("stockReal", item.StockReal));
     parameters.Add(new SqlParameter("stockAsignado", item.StockAsign));
     parameters.Add(new SqlParameter("idUnidadMedida", (item.UdMedida == null ? null : item.UdMedida.UdMedida)));
     return parameters;
 }
Beispiel #9
0
        private static Material ExtractData(SqlDataReader reader)
        {
            Material material = new Material();

            material.IdMaterial = (int?)reader["id_material"];
            material.Denominacion = (string)reader["denominacion"];
            material.Caracteristicas = (string)reader["caracteristicas"];
            material.StockMin = (Decimal)reader["stock_minimo"];
            material.StockReal = (Decimal)reader["stock_real"];
            material.StockAsign = (Decimal)reader["stock_asignado"];
            int? idUnidadMedida = (int?)reader["id_ud_medida"];
            if (idUnidadMedida != null)
            {
                material.UdMedida = UnidadMedidaDAO.GetById(idUnidadMedida.Value);
            }

            return material;
        }
Beispiel #10
0
 public static int Delete(Material item)
 {
     string query = "DELETE FROM [Muebles].[dbo].[Materiales] "
     + "WHERE id_material = @id_material ";
     return Dal.ExecuteNonQuery(query, LoadParameters(item));
 }
Beispiel #11
0
 public static int Update(Material item)
 {
     string query = "UPDATE [Muebles].[dbo].[Materiales] "
         + "SET [denominacion] = @denominacion "
         + ",[caracteristicas] = @caracteristicas "
         + ",[stock_minimo] = @stockMinimo "
         + ",[stock_real] = @stockReal "
         + ",[stock_asignado] = @stockAsignado "
         + ",[id_ud_medida] =  @idUnidadMedida "
         + "WHERE id_material = @id_material ";
     return Dal.ExecuteNonQuery(query, LoadParameters(item));
 }
Beispiel #12
0
 public static int? Insert(Material item)
 {
     String query = "INSERT INTO [Muebles].[dbo].[Materiales] "
     + "([denominacion] ,[caracteristicas], [stock_minimo],[stock_real],[stock_asignado],[id_ud_medida]) "
     + "OUTPUT Inserted.id_material "
     + "VALUES "
     + "(@denominacion "
     + ",@caracteristicas "
     + ",@stockMinimo "
     + ",@stockReal "
     + ",@stockAsignado "
     + ",@idUnidadMedida) ";
     return (int?)Dal.ExecuteScalar(query, LoadParameters(item));
 }
Beispiel #13
0
 public static Material GetById(Material item)
 {
     string query = "SELECT [id_material] "
         + ",[denominacion] "
         + ",[caracteristicas] "
         + ",[stock_minimo] "
         + ",[stock_real] "
         + ",[stock_asignado] "
         + ",[id_ud_medida] "
         + "FROM [Muebles].[dbo].[Materiales] "
         + "WHERE id_material = @id_material ";
     Material material = null;
     Dal.ExecuteReader(query, LoadParameters(item), delegate(SqlDataReader reader)
     {
         if (reader.Read())
         {
             material = ExtractData(reader);
         }
     });
     return material;
 }