private void btnPagarEmpresa_Click(object sender, EventArgs e) { for (int fila = 0; fila < int.Parse(txtCantPags.Text.ToString()); fila++) { RendicionComision rendicion = new RendicionComision(); rendicion.idCompra = int.Parse(dtSource.Rows[fila]["idCompra"].ToString()); rendicion.idPublicacion = int.Parse(dtSource.Rows[fila]["idPublicacion"].ToString()); rendicion.descripcion = dtSource.Rows[fila]["descripcion"].ToString(); rendicion.porcentaje = decimal.Parse(dtSource.Rows[fila]["porcentaje"].ToString()); rendicion.fila = char.Parse(dtSource.Rows[fila]["fila"].ToString()); rendicion.asiento = int.Parse(dtSource.Rows[fila]["asiento"].ToString()); rendicion.cantidad = int.Parse(dtSource.Rows[fila]["compra_cantidad"].ToString()); rendicion.precio = decimal.Parse(dtSource.Rows[fila]["precio"].ToString()); rendicion.fechaCompra = DateTime.Parse(dtSource.Rows[fila]["compra_fecha"].ToString()); totalConComision += ((decimal.Parse(dtSource.Rows[fila]["precio"].ToString()) * decimal.Parse(dtSource.Rows[fila]["porcentaje"].ToString()) / 100)); total += decimal.Parse(dtSource.Rows[fila]["precio"].ToString()) - totalConComision; lblTotal.Text = total.ToString(); lblTotalConComision.Text = totalConComision.ToString(); rendicion.comisionTotalCobrada = totalConComision; rendicion.pagadoAEmpresa = total; rendicion.cuitEmpresa = userLog.empresa.Empresa_Cuit; rendicionesAPagar.Add(rendicion); } try { Factura f = new Factura(); ConfigGlobal cg = new ConfigGlobal(); f.empresaId = userLog.empresa.Empresa_Cuit; f.Fecha = cg.getFechaSistema(); f.TotalComisionCobrada = totalConComision; f.TotalEmpresaPagado = total; //retorna el id insertado. int idFactura = f.altaFactura(); ItemFactura item = new ItemFactura(); if (idFactura > 0) { foreach (RendicionComision unaRendicion in rendicionesAPagar) { item.Cantidad = unaRendicion.cantidad; item.Monto = unaRendicion.precio; item.descripcion = unaRendicion.descripcion; item.compraId = unaRendicion.idCompra; item.facturaId = idFactura; item.altaItem(); } } MessageBox.Show("Se han rendido correctamente las compras!.", "¡Correcto!", MessageBoxButtons.OK, MessageBoxIcon.None); this.Hide(); } catch (Exception ex) { throw ex; } //validar que cuando haya seleccionado todas no haya quedado ninguna sin seleccionar que tenga una fecha anterior. //validar que se hayan seleccionado la cantidad de compras a rendir que haya dicho el admin //PAGAR A LA EMPRESA significa crear una factura para ESA EMPRESA, //y agregar todos los items por esa facutra (EL MONTO DEL ITEM ES EL DE LA COMPRA MENOS LA COMISION) }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { //int Codigo = int.Parse(dataGridView1.CurrentRow.Cells["Codigo"].Value.ToString()); //Seleccionando if (this.dataGridView1.Columns[e.ColumnIndex].Name.Equals("seleccion")) { RendicionComision rendicion = new RendicionComision(); rendicion.idCompra = int.Parse(dataGridView1.CurrentRow.Cells["idCompra"].Value.ToString()); rendicion.idPublicacion = int.Parse(dataGridView1.CurrentRow.Cells["idPublicacion"].Value.ToString()); rendicion.descripcion = dataGridView1.CurrentRow.Cells["descripcion"].Value.ToString(); rendicion.porcentaje = decimal.Parse(dataGridView1.CurrentRow.Cells["porcentaje"].Value.ToString()); rendicion.fila = char.Parse(dataGridView1.CurrentRow.Cells["fila"].Value.ToString()); rendicion.asiento = int.Parse(dataGridView1.CurrentRow.Cells["asiento"].Value.ToString()); rendicion.precio = decimal.Parse(dataGridView1.CurrentRow.Cells["precio"].Value.ToString()); rendicion.fechaCompra = DateTime.Parse(dataGridView1.CurrentRow.Cells["compra_fecha"].Value.ToString()); totalConComision += ((decimal.Parse(dataGridView1.CurrentRow.Cells["precio"].Value.ToString()) * decimal.Parse(dataGridView1.CurrentRow.Cells["porcentaje"].Value.ToString()) / 100)); total += decimal.Parse(dataGridView1.CurrentRow.Cells["precio"].Value.ToString()) - totalConComision; lblTotal.Text = total.ToString(); lblTotalConComision.Text = totalConComision.ToString(); rendicion.comisionTotalCobrada = totalConComision; rendicion.pagadoAEmpresa = total; rendicion.cuitEmpresa = userLog.empresa.Empresa_Cuit; rendicionesAPagar.Add(rendicion); } } catch (Exception ex) { throw ex; } }