コード例 #1
0
        public async Task <ItemDetalle> Create(ItemDetalle itemDetalle)
        {
            using (SqlConnection sqlConn = new SqlConnection(conn))
            {
                using (SqlCommand cmd = new SqlCommand("Usp_ItemDetalle_Create", sqlConn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@pProducto", itemDetalle.Producto));
                    cmd.Parameters.Add(new SqlParameter("@pPrecio", itemDetalle.Precio));
                    cmd.Parameters.Add(new SqlParameter
                    {
                        ParameterName = "@pItemDetalleID",
                        Value         = itemDetalle.ItemDetalleID,
                        Direction     = System.Data.ParameterDirection.Output
                    });
                    await sqlConn.OpenAsync();

                    await cmd.ExecuteNonQueryAsync();

                    int id = (int)cmd.Parameters["@pItemDetalleID"].Value;

                    await sqlConn.CloseAsync();

                    itemDetalle.ItemDetalleID = id;
                    return(itemDetalle);
                }
            }
        }
コード例 #2
0
        private void BtnAgregarSueldo_Click(object sender, RoutedEventArgs e)
        {
            var id = new ItemDetalle()
            {
                ValorInicial = Convert.ToInt32(txtValorInicialSueldo.Text), CostoFinal = Convert.ToInt32(txtCostoFinalSueldo.Text), Desgloce = (cbSueldos.SelectedItem as tipo_costo).nombre
            };

            id.btnQuitarDetalle.Click += (se, a) => spDetalle.Children.Remove(id);
            spDetalle.Children.Add(id);
        }
コード例 #3
0
        private void CbCostos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch ((cbCostos.SelectedItem as tipo_costo).nombre.ToLower())
            {
            case "metro lineal sistema":
                txtCostoFinalCosto.IsEnabled = false;
                if (txtValorInicialCosto.Text == "")
                {
                    return;
                }
                int valorInicial = Convert.ToInt32(txtValorInicialCosto.Text);
                btnAgregarCosto.Click += (se, a) =>
                {
                    var id = new ItemDetalle()
                    {
                        ValorInicial = Convert.ToInt32(txtValorInicialCosto.Text), CostoFinal = (int)(valorInicial * VanosTotalAncho), Desgloce = (cbCostos.SelectedItem as tipo_costo).nombre
                    };
                    id.btnQuitarDetalle.Click += (se2, a2) => spDetalle.Children.Remove(id);
                    spDetalle.Children.Add(id);
                };
                break;

            case "area vano":
                txtValorInicialCosto.Text = $"{TipoVidrioPrecio}";
                txtCostoFinalCosto.Text   = $"{VanosTotalArea * TipoVidrioPrecio}";
                btnAgregarCosto.Click    += (se, a) =>
                {
                    var id = new ItemDetalle()
                    {
                        ValorInicial = TipoVidrioPrecio, CostoFinal = (int)(VanosTotalArea * TipoVidrioPrecio), Desgloce = (cbCostos.SelectedItem as tipo_costo).nombre
                    };
                    id.btnQuitarDetalle.Click += (se2, a2) => spDetalle.Children.Remove(id);
                    spDetalle.Children.Add(id);
                };
                break;

            case "tasa imprevisto":
                txtValorInicialCosto.Text = $"{TasaImprevisto}";
                txtCostoFinalCosto.Text   = $"{TasaImprevisto}";
                btnAgregarCosto.Click    += (se, a) =>
                {
                    var id = new ItemDetalle()
                    {
                        ValorInicial = TasaImprevisto, CostoFinal = TasaImprevisto, Desgloce = (cbCostos.SelectedItem as tipo_costo).nombre
                    };
                    id.btnQuitarDetalle.Click += (se2, a2) => spDetalle.Children.Remove(id);
                    spDetalle.Children.Add(id);
                };
                break;

            default:
                txtCostoFinalCosto.IsEnabled = true;
                break;
            }
        }
コード例 #4
0
 public void Update(ItemDetalle itemDetalle)
 {
     using (SqlConnection sqlConn = new SqlConnection(conn))
     {
         using (SqlCommand cmd = new SqlCommand("Usp_ItemDetalle_Update", sqlConn))
         {
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@pItemDetalleID", itemDetalle.ItemDetalleID));
             cmd.Parameters.Add(new SqlParameter("@pProducto", itemDetalle.Producto));
             cmd.Parameters.Add(new SqlParameter("@pPrecio", itemDetalle.Precio));
             sqlConn.Open();
             cmd.ExecuteNonQuery();
             sqlConn.Close();
         }
     }
 }
コード例 #5
0
        public void InsertItemDetalle(ItemDetalle Obj)
        {
            using (DB_AUTOMATIZACIONEntities db = new DB_AUTOMATIZACIONEntities())
            {
                try
                {
                    if (db.Database.Connection.State == ConnectionState.Closed)
                    {
                        db.Database.Connection.Open();
                    }

                    db.ItemDetalle.Add(Obj);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    EntityExceptionError.CatchError(ex);
                }
            }
        }
コード例 #6
0
        public async Task <ItemDetalle> GetById(int itemDetalleID)
        {
            using (SqlConnection sqlConn = new SqlConnection(conn))
            {
                using (SqlCommand cmd = new SqlCommand("Usp_ItemDetalle_GetById", sqlConn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@pItemDetalleID", itemDetalleID));
                    var itemDetalle = new ItemDetalle();
                    await sqlConn.OpenAsync();

                    using (var reader = await cmd.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            itemDetalle = itemDetalleReader(reader);
                        }
                    }
                    return(itemDetalle);
                }
            }
        }
コード例 #7
0
        public void DeleteItemDetalle(ItemDetalle Obj)
        {
            using (DB_AUTOMATIZACIONEntities db = new DB_AUTOMATIZACIONEntities())
            {
                try
                {
                    if (db.Database.Connection.State == ConnectionState.Closed)
                    {
                        db.Database.Connection.Open();
                    }

                    ItemDetalle Entidad = (from n in db.ItemDetalle
                                           where n.Id == Obj.Id
                                           select n).FirstOrDefault();
                    db.ItemDetalle.Remove(Entidad);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    EntityExceptionError.CatchError(ex);
                }
            }
        }