private void btnquitar_Click(object sender, EventArgs e) { try { if (dtGDetalle != null) { int fil = dtGDetalle.CurrentRow.Index; dtGDetalle.Rows.RemoveAt(fil); Producto p = (Producto)productoBindingSource.Current; int c = int.Parse(numCantidad.Value.ToString()); //c -= Convert.ToInt32(this.txtStock.Text); DetalleEntrega ept = new DetalleEntrega(p, c); ((EntregaProductoTerminado)entregaProductoTerminadoBindingSource.Current).DE.Remove(ept); detalleEntregaBindingSource.Remove(ept); //esto es para sumar el total de cajas a enviar double sum = 0; int i = this.dtGDetalle.RowCount; for (int x = 0; x < i; x++) { sum = sum + double.Parse(dtGDetalle[1, x].Value.ToString()); } this.txtTotalCajas.Text = sum.ToString(); } } catch { MessageBox.Show("La grilla esta Vacia", "Advertencia", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); } }
private void btnagregar_Click(object sender, EventArgs e) { //if (numCantidad.Value != 0) if (!Validaciones()) { return; } //if (numCantidad.Value != 0) //{ try { if (cbProducto != null) // hay que verificar que el producto no este seleccionado siempre { Producto p = (Producto)productoBindingSource.Current; int c = int.Parse(numCantidad.Value.ToString()); //c -= Convert.ToInt32(this.txtStock.Text); DetalleEntrega ept = new DetalleEntrega(p, c); ((EntregaProductoTerminado)entregaProductoTerminadoBindingSource.Current).DE.Add(ept); detalleEntregaBindingSource.Add(ept); //this.txtTotalCantidad += subTotal; //this.StockActual = subTotal; //this.txtTotalCantidad.Text += numCantidad.Value; //this.txtTotalCantidad.Text = "" + StockActual.ToString("#0.00#"); } } catch { MessageBox.Show("No seleciono ningun Producto", "Informacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } //} /*else * { * DialogResult result = MessageBox.Show("El campo de cantidad no puede ser vacio", "Informacion", MessageBoxButtons.RetryCancel); * * if (result == DialogResult.Cancel) * { * this.Close(); * } * * else if (result == DialogResult.Retry) * { * //MessageBox.Show("Vuelva a Intentarlo"); * return; * * } * }*/ }
public static void Eliminar(DetalleEntrega de) { //creo la conexion SqlConnection cnn = new SqlConnection(Conexion.Connection); //abro la conexion cnn.Open(); //Creo el comando sql a utlizar SqlCommand cmd = new SqlCommand("delete from DetalleEntrega Where idDetalle = @idDetalle"); //Cargo el valor del parametro cmd.Parameters.Add(new SqlParameter("@idDetalle", de.IdEntrega)); //asigno la conexion al comando cmd.Connection = cnn; cmd.ExecuteNonQuery(); cnn.Close(); }
// GET: EntregaMedicamento/Detalles/5 public ActionResult Detalles(int codSalida) { DetalleEntrega modelo = new DetalleEntrega(); modelo.entrega = (from t in db.tbSalida where t.codSalida == codSalida select t).SingleOrDefault(); modelo.paciente = (from t in db.tbPaciente where t.codPaciente == modelo.entrega.codPaciente select t).SingleOrDefault(); modelo.detalle = (from det in db.tbDetalleSalida join pro in db.tbProducto on det.codProducto equals pro.codProducto where det.codSalida == codSalida select new RegistroProducto { codProducto = det.codProducto, nombre = pro.producto, categoria = pro.tbCategoria.categoria, presentacion = pro.tbPresentacion.presentacion, dosis = RegistroProducto.Dosis(pro.dosis.ToString(), pro.codVolumen.Value, pro.dosis2.ToString(), pro.codVolumen2.Value), cantidad = det.cantidad.Value }).ToList(); return(View(modelo)); }
public static void Crear(DetalleEntrega de, int idEntrega) { //creo la conexion SqlConnection cnn = new SqlConnection(Conexion.Connection); //abro la conexion cnn.Open(); //Creo el comando sql a utlizar SqlCommand cmd = new SqlCommand("INSERT INTO DetalleEntrega(idEntrega, idProducto, cantidad) VALUES (@idEntrega, @idProducto, @cantidad)"); //Cargo el valor del parametro cmd.Parameters.Add(new SqlParameter("@idEntrega", idEntrega)); cmd.Parameters.Add(new SqlParameter("@idProducto", de.Product.Producto.IdProducto)); cmd.Parameters.Add(new SqlParameter("@cantidad", de.Cantidad)); //asigno la conexion al comando cmd.Connection = cnn; cmd.ExecuteNonQuery(); cnn.Close(); }