public void registrar() { if (validar()) { sucursal[] arraySucursales = new sucursal[1]; arraySucursales[0] = new sucursal(radDropDownList2.SelectedItem.Value.ToString(), radDropDownList2.SelectedItem.DisplayValue.ToString()); ventas vent = new ventas(); precio pre = new precio(); inventario inven = new inventario(); producto[] pro = new producto[radGridView3.Rows.Count]; vent.asignarCantidad(radGridView3.Rows.Count); for (int t = 0; t < radGridView3.Rows.Count; t++) { // MessageBox.Show("valor de t = "+t); pro[t] = new producto(radGridView3.Rows[t].Cells[0].Value.ToString(), radGridView3.Rows[t].Cells[2].Value.ToString()); inven.Correlativo = System.Convert.ToInt32(radGridView3.Rows[t].Cells[5].Value.ToString()); pre.Monto = System.Convert.ToDouble(radGridView3.Rows[t].Cells[3].Value.ToString()); inven.Precios = pre; inven.Costo = System.Convert.ToDouble(radGridView3.Rows[t].Cells[4].Value); inven.Producto = pro; vent.agregarProducto(inven, System.Convert.ToDouble(radGridView3.Rows[t].Cells[2].Value.ToString())); // MessageBox.Show("Precios: " + inven.Precios.Monto.ToString()); } vent.Sucursales = arraySucursales; String fech = Convert.ToString(radDateTimePicker1.Value); vent.Fecha = radDateTimePicker1.Value; //vent.Comentario = txtComentario.Text; vent.TipoVenta = radDropDownList1.SelectedItem.DisplayValue.ToString(); vent.calcularTotal(); vent.registrarVenta(); this.radGridView2.MasterTemplate.Rows.Clear(); this.radGridView1.MasterTemplate.Rows.Clear(); this.radGridView3.MasterTemplate.Rows.Clear(); // labelMsjExito.Text = "Venta registrada exitosamente."; //Limpiar los texbox. txtPrecio.Text = ""; radTextBox3.Text = ""; txtCorrelativo.Text = ""; radTextBox1.Text = ""; txtTotal.Text = ""; radTextBox1.Focus(); // MessageBox.Show(inven.Precios.Monto.ToString()); // MessageBox.Show(inven.Producto[1].Nombre); // MessageBox.Show(inven.Producto[2].Nombre); // inven. } else { MessageBox.Show("Verifique que todos los campos obligatorios esten llenados."); } }
public void agregarProducto(inventario i, double precio) { //MessageBox.Show("Nuevamente Tamaño del vector detalleVenta: " + producto.Length); producto[contador] = new detalleVenta(); producto[contador].Pro = i.Producto; producto[contador].PrecioVenta = i.Precios.Monto; producto[contador].Costo = i.Costo; producto[contador].Correlativo = i.Correlativo; producto[contador].PrecioMenorVenta = precio; contador = contador + 1; }
public void registrarCompra() { // opcione.iniciarTransaccion(); inventario[] invet = Productos; String NomTabla = "Compras"; Hashtable crit = new Hashtable(); //Lineas con detalles especificos por metodo. crit.Add("CodigoProveedor", Proveedor[0].CodigoProveedor.ToString()); crit.Add("TipoCompra", "2"); crit.Add("CodigoSucursal", sucursal[0].Codigosucursal.ToString()); crit.Add("Gravado", Total); double iva = total * 0.13; crit.Add("IVA", Decimal.Round(System.Convert.ToDecimal(iva), 2)); crit.Add("Percepcion", 0); String fech = Convert.ToString(Fecha); crit.Add("Fecha", fech.Substring(0, 10)); crit.Add("NDocumento", NDoc1); opcione.InsertarRegistro(NomTabla, crit); DataTable tabla = opcione.obtenerIdCompra(); DataRow row; row = tabla.Rows[0]; // opcione.CommitTransaccion(); // int contadorArrayVistaPrevia=0; VistaCompra = new Hashtable[invet.Length]; for (int f = 0; f < invet.Length; f++) { inventario inv = new inventario(); inv = invet[f]; inv.registrarInventario(System.Convert.ToInt32(row["idComp"])); VistaCompra[f] = inv.ViCompra; //for(int h=0;h<inv.ContardorArray;h++){ // contadorArrayVistaPrevia = contadorArrayVistaPrevia+1; // VCompra[contadorArrayVistaPrevia].CodigoBarra = inv.VCompra[h].CodigoBarra; // VCompra[contadorArrayVistaPrevia].Correlativo = inv.VCompra[h].Correlativo; //} } }
//Sumatoria de los precios de todos los productos en GridView. public void calcularTotal() { inventario[] invet = Productos; inventario inv = new inventario(); int num = 0; double subtotal = 0.0; double total = 0.0; for (int i = 0; i < invet.Length; i++) { num = invet[i].Producto.Length; subtotal = num * invet[i].Costo; total = total + subtotal; } Total = total; //MessageBox.Show("Total de la compra: "+total); }
public void cargarPrecios() { radGridView2.Rows.Clear(); inventario inv = new inventario(); double cos = System.Convert.ToDouble(txtCosto.Text); inv.obtenerPrecio(cos); pr = inv.Filasprecios1; cantidadTiposPrecios = pr.Length; // MessageBox.Show("pr.Length -> "+pr.Length+ " uno dato: "+pr[0].Cells0); for (int i = 0; i < pr.Length; i++) { radGridView2.Rows.AddNew(); int f = radGridView2.Rows.Count; // pr[i] = new rowGridView(); this.radGridView2.Rows[f - 1].Cells[0].Value = pr[i].Cells0; this.radGridView2.Rows[f - 1].Cells[1].Value = pr[i].Cells1; } }
private void btnRegistrar_Click(object sender, EventArgs e) { Hashtable[] vistaCompra = new Hashtable[1]; if (validar()) { compra compr = new compra(); // proveedor prov = new proveedor(radDropDownList1.SelectedItem.Value.ToString(), radDropDownList1.SelectedItem.DisplayValue.ToString()); sucursal[] arraySucursales = new sucursal[1]; arraySucursales[0] = new sucursal(radDropDownList2.SelectedItem.Value.ToString(), radDropDownList2.SelectedItem.DisplayValue.ToString()); // arraySucursales[0].Codigosucursal = radDropDownList2.SelectedItem.Value.ToString(); // arraySucursales[0].Nombre = radDropDownList2.SelectedItem.DisplayValue.ToString(); proveedor[] arrayProveedores = new proveedor[1]; arrayProveedores[0] = new proveedor(radDropDownList1.SelectedItem.Value.ToString(), radDropDownList1.SelectedItem.DisplayValue.ToString()); // arrayProveedores[0].CodigoProveedor = radDropDownList1.SelectedItem.Value.ToString(); // arrayProveedores[0].Nombre = radDropDownList1.SelectedItem.DisplayValue.ToString(); compr.Sucursal = arraySucursales; compr.Proveedor = arrayProveedores; compr.NDoc1 = txtNumDoc.Text; int f = 0; for (int t = 0; t < radGridView1.Rows.Count; t++) { f = f + System.Convert.ToInt32(this.radGridView1.Rows[t].Cells[3].Value); } inventario[] inventar = new inventario[radGridView1.Rows.Count]; int cantidad = 0; // MessageBox.Show("variable radGridView1.Rows.Count = " + radGridView1.Rows.Count); for (int t = 0; t < radGridView1.Rows.Count; t++) { cantidad = System.Convert.ToInt32(this.radGridView1.Rows[t].Cells[3].Value); producto[] arrayProduc = new producto[cantidad]; // MessageBox.Show("variable cantidad = " + cantidad); for (int i = 0; i < cantidad; i++) { // MessageBox.Show("variable i = " + i + " variable t = " + t); arrayProduc[i] = new producto(this.radGridView1.Rows[t].Cells[0].Value + "", this.radGridView1.Rows[t].Cells[1].Value + ""); arrayProduc[i].CodigoBarra = this.radGridView1.Rows[t].Cells[0].Value + ""; arrayProduc[i].Nombre = this.radGridView1.Rows[t].Cells[1].Value + ""; } //inventario invet = new inventario(); //invet.Producto = arrayProduc inventar[t] = new inventario(); inventar[t].Producto = arrayProduc; // precio preci = new precio(); // preci.Monto = System.Convert.ToDouble(this.radGridView1.Rows[t].Cells[2].Value); // invet.Costo = System.Convert.ToDouble(this.radGridView1.Rows[t].Cells[2].Value); inventar[t].Costo = System.Convert.ToDouble(this.radGridView1.Rows[t].Cells[2].Value); fila = new rowGridView[cantidadTiposPrecios]; for (int i = 0; i < cantidadTiposPrecios; i++) { fila[i] = new rowGridView(); fila[i].Cells0 = radGridView2.Rows[i].Cells[0].Value + ""; } int numColumnas = this.radGridView1.Columns.Count; for (int tr = 0; tr < numColumnas - 4; tr++) { fila[tr].Cells1 = radGridView1.Rows[t].Cells[4 + tr].Value + ""; // f = f + System.Convert.ToInt32(this.radGridView1.Rows[t].Cells[4+tr].Value); } inventar[t].Filasprecios1 = fila; } compr.Productos = inventar; String fech = Convert.ToString(radDateTimePicker1.Value); compr.Fecha = radDateTimePicker1.Value; // compr.Fecha = fech.Substring(0, 10); compr.calcularTotal(); compr.registrarCompra(); this.radGridView1.MasterTemplate.Rows.Clear(); labelMsjExito.Text = "Venta registrada exitosamente."; //Limpiar los texbox. txtCosto.Text = ""; radTextBox3.Text = ""; //txtCantidad.Text = ""; radTextBox1.Text = ""; txtTotal.Text = ""; radTextBox1.Focus(); vistaCompra = compr.VistaCompra; vistaPreviaCompras vista = new vistaPreviaCompras(vistaCompra); vista.Show(); } else { MessageBox.Show("Verifique que todos los campos obligatorios esten llenados."); } }
private void radButton3_Click(object sender, EventArgs e) { int tipoVen = System.Convert.ToInt32(radDropDownList1.SelectedItem.Value.ToString()); if (tipoVen == 1) { // MessageBox.Show("Borrador"); radPanel1.Visible = false; radPanel2.Visible = true; this.radGridView4.MasterTemplate.Rows.Clear(); for (int i = 0; i < radGridView3.Rows.Count; i++) { radGridView4.Rows.AddNew(); int f = radGridView4.Rows.Count; this.radGridView4.Rows[f - 1].Cells[0].Value = this.radGridView3.Rows[f - 1].Cells[0].Value; this.radGridView4.Rows[f - 1].Cells[1].Value = this.radGridView3.Rows[f - 1].Cells[1].Value; //Subtotal this.radGridView4.Rows[f - 1].Cells[2].Value = this.radGridView3.Rows[f - 1].Cells[4].Value; // this.radGridView4.Rows[f - 1].Cells[3].Value = this.radGridView3.Rows[f - 1].Cells[2].Value; this.radGridView4.Rows[f - 1].Cells[4].Value = this.radGridView3.Rows[f - 1].Cells[3].Value; this.radGridView4.Rows[f - 1].Cells[5].Value = this.radGridView3.Rows[f - 1].Cells[5].Value; radTextBox4.Text = radTextBox2.Text; } } else if (tipoVen == 2) { atrasPanel2(); llenarRadGridView3(); String total = radTextBox2.Text; //** sucursal[] arraySucursales = new sucursal[1]; arraySucursales[0] = new sucursal(radDropDownList2.SelectedItem.Value.ToString(), radDropDownList2.SelectedItem.DisplayValue.ToString()); ventas vent = new ventas(); precio pre = new precio(); inventario inven = new inventario(); producto[] pro = new producto[radGridView3.Rows.Count]; vent.asignarCantidad(radGridView3.Rows.Count); for (int t = 0; t < radGridView3.Rows.Count; t++) { // MessageBox.Show("valor de t = "+t); pro[t] = new producto(radGridView3.Rows[t].Cells[0].Value.ToString(), radGridView3.Rows[t].Cells[2].Value.ToString()); inven.Correlativo = System.Convert.ToInt32(radGridView3.Rows[t].Cells[5].Value.ToString()); pre.Monto = System.Convert.ToDouble(radGridView3.Rows[t].Cells[3].Value.ToString()); inven.Precios = pre; inven.Costo = System.Convert.ToDouble(radGridView3.Rows[t].Cells[4].Value); inven.Producto = pro; vent.agregarProducto(inven, System.Convert.ToDouble(radGridView3.Rows[t].Cells[3].Value.ToString())); // MessageBox.Show("Precios: " + inven.Precios.Monto.ToString()); } vent.Sucursales = arraySucursales; String fech = Convert.ToString(radDateTimePicker1.Value); vent.Fecha = radDateTimePicker1.Value; //vent.Comentario = txtComentario.Text; vent.TipoVenta = radDropDownList1.SelectedItem.DisplayValue.ToString(); vent.calcularTotal(); //** facturarVenta fac = new facturarVenta(GridView, total, vent); fac.Show(); // MessageBox.Show("Facturacion"); // registrar(); } else { // MessageBox.Show("Credito Fiscal"); } }