private void BtnGuardar_Click(object sender, EventArgs e) { try { if (controlarguardado() == true) { DataTable dt = new DataTable(); dt.Columns.Add("Codigo", typeof(string)); dt.Columns.Add("Cantidadtotal", typeof(decimal)); dt.Columns.Add("Detalle", typeof(string)); dt.Columns.Add("Cantidadparcial", typeof(string)); foreach (DataGridViewRow fila in DGDetalleitems.Rows) { dt.Rows.Add(fila.Cells["CCodigo"].Value, fila.Cells["CCantidad"].Value, fila.Cells["CDetalle"].Value, 0); } NegocioRetirodeMercaderia.insertar(DateTime.Now, idcliente, NegocioConfigEmpresa.idusuario, CbTipopedido.Text, "PENDIENTE", "", dt, idclientebeneficiaria, Convert.ToInt32(CbTipopedido.SelectedValue)); UtilityFrm.mensajeConfirm("Se guardo correctamente"); limpiarformulario(); } else { UtilityFrm.mensajeError("Tiene algunos campos en blanco, no puede continuar"); } } catch (Exception err) { UtilityFrm.mensajeError(err.Message); } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { DataTable midatatable = new DataTable(); if (e.KeyCode == Keys.Enter) { if (CBBuscarportipo.Text == "ADJUDICACION") { midatatable = NegocioRetirodeMercaderia.buscarconcatenacion(0, "", "", DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("dd/MM/yyyy"), false, false, false, false, 0, true, Convert.ToInt32(textBox1.Text)); } if (CBBuscarportipo.Text == "VENTA") { midatatable = NegocioRetirodeMercaderia.buscarconcatenacion(0, "", "", DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("dd/MM/yyyy"), false, false, false, false, 0, false, 0, true, Convert.ToInt32(textBox1.Text)); } if (midatatable.Rows.Count != 0) { DataRow row = midatatable.Rows[0]; LblNorden.Text = row["Orden"].ToString(); LblRazonsocial.Text = row["NombreBeneficiado"].ToString(); LblCuit.Text = row["cuit"].ToString(); LblEstado.Text = row["estado"].ToString(); LblTipo.Text = row["Tipo"].ToString(); LblCodcliente.Text = row["CodEmpresaB"].ToString(); LblEmpresa.Text = row["Tipo"].ToString() == "VENTA" ? NegocioConfigEmpresa.emrazonsocial : row["razon_social"].ToString(); idempresa = row["Tipo"].ToString() == "VENTA" ? 1 : Convert.ToInt32(row["codcliente"].ToString()); cargardetalleretiro(Convert.ToInt32(row["Orden"].ToString())); Txtitems.Focus(); } else { UtilityFrm.mensajeError("La orden que ingreso es inexistente"); textBox1.SelectAll(); } } }
private void FrmStockRetirodeMercaderia_Load(object sender, EventArgs e) { CBBuscarportipo.Text = "VENTA"; CBEstado.Text = "PENDIENTE"; UtilityFrm.completarcombobox(CbTipopedido, "NroTipo", "Nombre", NegocioRetirodeMercaderia.buscartiporetiro(), true); //textBox1.Text = "Introdusca el numero de registro a buscar"; //textBox1.ForeColor = Color.Gray; }
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { if (tabControl1.SelectedTab == tabPage1) { Txtitems.Focus(); } if (tabControl1.SelectedTab == tabPage2) { DGListado.DataSource = NegocioRetirodeMercaderia.buscarconcatenacion(idcliente, CBEstado.Text, "", dtpFechaIni.Value.ToString("dd/MM/yyyy"), dtpFechaFin.Value.ToString("dd/MM/yyyy"), CHKCliente.Checked, CHKEstado.Checked, CHKTipo.Checked, CHKFecha.Checked, Convert.ToInt32(CbTipopedido.SelectedValue)); } }
private void guardar() { string varestado = "PENDIENTE"; string mensaje = ""; DataTable dt = new DataTable(); dt.Columns.Add("Codigo", typeof(string)); dt.Columns.Add("Cantidadtotal", typeof(decimal)); dt.Columns.Add("Detalle", typeof(string)); dt.Columns.Add("Cantidadparcial", typeof(string)); dt.Columns.Add("cantidadactual", typeof(string)); if (recorreritemsparacambioestado() == true) { varestado = "FINALIZADO"; } mensaje = validacionformulario(); //primero agrego el remito y despues modifico if (mensaje == "ok") { foreach (DataGridViewRow fila in GDDetalleretiro.Rows) { dt.Rows.Add(fila.Cells["Codigo"].Value, fila.Cells["cantotal"].Value, fila.Cells["Detalle"].Value, fila.Cells["canparcial"].Value, fila.Cells["canactual"].Value); } string nroremito = ""; mensaje = NegocioRetirodeMercaderia.modificarcantidad(Convert.ToInt32(LblNorden.Text), varestado, dt, Convert.ToInt32(LblCodcliente.Text), LblTipo.Text, ref nroremito, idempresa); if (mensaje == "ok") { FrmTicketRemito objremito = new Formreportes.FrmTicketRemito(nroremito); objremito.ShowDialog(); UtilityFrm.mensajeConfirm("Se genero el remito con exito"); limpiarformulario(); } else { UtilityFrm.mensajeError(mensaje); } } else { UtilityFrm.mensajeError(mensaje); } }
private void cargardetalleretiro(int norden) { if (GDDetalleretiro.Rows.Count != 0) { GDDetalleretiro.Rows.Clear(); } DataTable midata = new DataTable(); midata = NegocioRetirodeMercaderia.buscarlistadodetalle(norden); if (midata.Rows.Count != 0) { foreach (DataRow mirow in midata.Rows) { GDDetalleretiro.Rows.Add(mirow["idproducto"], mirow["Detalle"], 0, mirow["cantidadparcial"], mirow["cantidadtotal"], mirow["codigo"]); } } else { UtilityFrm.mensajeError("El numero de orden no corresponde"); } }
private void FrmOrdenAdjudicacion_Load(object sender, EventArgs e) { UtilityFrm.completarcombobox(CbTipopedido, "NroTipo", "Nombre", NegocioRetirodeMercaderia.buscartiporetiro(), true); }
private void DGListado_SelectionChanged(object sender, EventArgs e) { DGDetalle.DataSource = NegocioRetirodeMercaderia.buscarlistadodetalle(Convert.ToInt32(DGListado.CurrentRow.Cells["orden"].Value)); }
private void BtnBuscar_Click(object sender, EventArgs e) { DGListado.DataSource = NegocioRetirodeMercaderia.buscarconcatenacion(idcliente, CBEstado.Text, "", dtpFechaIni.Value.ToString("dd/MM/yyyy"), dtpFechaFin.Value.ToString("dd/MM/yyyy"), CHKCliente.Checked, CHKEstado.Checked, CHKTipo.Checked, CHKFecha.Checked, Convert.ToInt32(CbTipopedido.SelectedValue)); DGDetalle.DataSource = null; }
private void DGListado_CellClick(object sender, DataGridViewCellEventArgs e) { DGDetalle.DataSource = NegocioRetirodeMercaderia.buscarlistadodetalle(Convert.ToInt32(DGListado.CurrentRow.Cells["orden"].Value)); }
public void guardarventa() { int nroterminal = 0; int codtarjeta = 0; string cupon = ""; string lote = ""; decimal importe = 0; int cuota = 0; int codformapago = 1; string msg = "ok"; string precioneto = ""; string cantidad = ""; decimal var = 0; Char estadofactura = 'P'; //P : pendiente de factura F : facturado string nrocomprobante = ""; totales(); NegocioVenta objventa = new NegocioVenta(); DataTable dt = new DataTable(); dt.Columns.Add("Codigo", typeof(string)); dt.Columns.Add("Precio", typeof(decimal)); dt.Columns.Add("Cantidad", typeof(string)); dt.Columns.Add("Descuento", typeof(decimal)); dt.Columns.Add("Importe", typeof(decimal)); dt.Columns.Add("Producto", typeof(string)); dt.Columns.Add("Precioneto", typeof(string)); dt.Columns.Add("Pesable", typeof(int)); DataTable DTOrdenpedido = new DataTable(); DTOrdenpedido.Columns.Add("Codigo", typeof(string)); DTOrdenpedido.Columns.Add("cantidadparcial", typeof(string)); DTOrdenpedido.Columns.Add("cantidadtotal", typeof(string)); DTOrdenpedido.Columns.Add("detalle", typeof(string)); decimal IVA = 21; if (formapago == "tarjeta") { codtarjeta = this.codtarjeta; cupon = txtCupon.Text == "" ? "0":txtCupon.Text; lote = txtLote.Text == "" ? "0" : txtLote.Text; cuota = Convert.ToInt32(lblCuota.Text); importe = Convert.ToDecimal(lblImportecuota.Text); codformapago = 2; } if (formapago == "ctacte") { codformapago = 3; } /*IMPORTANTE HACER NOTA DE VENTA PARA IMPRIMIR*/ //if (MessageBox.Show("Desea Imprimir Venta?", "Imprimir" // , MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes) //{ // FrmImpVenta venta = new FrmImpVenta(totalAPagar); // venta.Show(); //} //else { // this.Close(); //} try { //LISTA DE PRODUCTOS SE LE ASIGNA EN EL MOMENTO QUE SE MUESTRA EL FORMULARIO // NumberFormatInfo asociado con la cultura en-US. NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat; foreach (DataGridViewRow fila in listadoDeProducto.Rows) { if (responsableiva != "EX") { var = Decimal.Round(Convert.ToDecimal(fila.Cells["CPrecio"].Value) / Convert.ToDecimal(1.21), 2); } else { var = Decimal.Round(Convert.ToDecimal(fila.Cells["CPrecio"].Value), 2); } //Math.Round(decValue, 2, MidpointRounding.AwayFromZero) // var = Math.Round(var, 2, MidpointRounding.AwayFromZero); precioneto = var.ToString("0.0000", nfi); //var = Convert.ToDecimal(fila.Cells["Cantidad"].Value); //cantidad = var.ToString("0.00", nfi); //recorro la lista pasado por paramentro y asigno al datatable para generar la transaccion //dt.Rows.Add(fila.Cells["Codigo"].Value, fila.Cells["Precio"].Value, fila.Cells["Cantidad"].Value, fila.Cells["Descuento"].Value, fila.Cells["Importe"].Value); dt.Rows.Add(fila.Cells["Codigo"].Value, fila.Cells["CPrecio"].Value, fila.Cells["Cantidad"].Value, fila.Cells["Descuento"].Value, fila.Cells["Importe"].Value, fila.Cells["Producto"].Value, precioneto, fila.Cells["Dpesable"].Value); DTOrdenpedido.Rows.Add(fila.Cells["Codigo"].Value, "0", fila.Cells["Cantidad"].Value, fila.Cells["Producto"].Value); } try { if (NegocioConfigEmpresa.confsistema("facturar").ToString() == "True" && tipo_comprobante == "NOTA DE VENTA" && tipofactura != "X") { if (NegocioConfigEmpresa.marcafiscal != "") { msg = objcomprobante.factura(NegocioConfigEmpresa.marcafiscal, dt, Convert.ToDouble(txtTotalAPagar.Text), NegocioConfigEmpresa.modelofiscal, NegocioConfigEmpresa.puertofiscal, 1, razonsocial, razonsocial == "CONSUMIDOR FINAL" ? "99999999999" : cuit, domicilio, tipofactura, responsableiva, tipofactura, tipofactura, Convert.ToDouble(neto), Convert.ToDouble(iva), Convert.ToDouble(this.neto105), Convert.ToDouble(this.iva105)); } else { UtilityFrm.mensajeError("La marca de la fiscal no se encuentra definido, la factura quedara pendiente"); } if (msg.Substring(0, 2) != "ok") { UtilityFrm.mensajeError(msg); UtilityFrm.mensajeConfirm("Se guardara la venta como pendiente de factura la puede encontrar en lista de ventas"); estadofactura = 'P'; } else { estadofactura = 'F'; //corregir para que no genere errores int nrocaracteres = Convert.ToInt32(msg.Length.ToString()); nrocomprobante = msg.Substring(2, nrocaracteres - 2); } } else { estadofactura = 'P'; } } catch (Exception e) { UtilityFrm.mensajeError(e.Message); } string Rta = objventa.Insertar(this.idCliente, DateTime.Now, Tipo_comprobante, objcomprobante.Puntoventa.PadLeft(5, '0'), msg.Substring(0, 2) == "ok" ? nrocomprobante.PadLeft(8, '0') : "0", IVA, this.concaja, this.constock, NegocioConfigEmpresa.usuarioconectado, dt, Convert.ToDecimal(txtBonificacion.Text == "" ? txtBonificacion.Text = "0" : txtBonificacion.Text), Convert.ToDecimal(txtTotalAPagar.Text), Convert.ToDecimal(lblsubtotal.Text), estadofactura, NegocioConfigEmpresa.confsistema("stock").ToString() == this.Name && pendientedestock == false ? true : false, nroterminal, codtarjeta, cupon, lote, importe, cuota, codformapago, neto, iva, objcomprobante.Cae, objcomprobante.Fechavto, objcomprobante.Numerotipofactura.PadLeft(3, '0'), objcomprobante.Puntoventa.PadLeft(5, '0'), this.iva105, this.neto105); int objnum = objventa.Idventa; if (Rta == "OK" || Rta == "ok") { if (pendientedestock == true) { NegocioRetirodeMercaderia.insertar(DateTime.Now, this.idCliente, NegocioConfigEmpresa.idusuario, "VENTA", "PENDIENTE", "", DTOrdenpedido, this.idCliente, 1, objnum); } if (this.concaja == true) { Rta = Negociocaja.insertarmovcaja(4110107, Convert.ToSingle(txtTotalAPagar.Text), 0, Convert.ToString(DateTime.Now), NegocioConfigEmpresa.usuarioconectado, NegocioConfigEmpresa.idusuario, NegocioConfigEmpresa.turno, "Venta nro : " + objventa.Idventa.ToString(), objventa.Idventa, true); } else { Rta = "ok"; } if (Rta == "ok") { trans = Rta; Reporteventa mireporteventa = new Reporteventa(); // Frmimpnotaventa miformnotaventa = new Frmimpnotaventa(); // Frmimpventicket miformticket = new Frmimpventicket(); if (NegocioConfigEmpresa.confsistema("imprimirventa").ToString() == "True") { if (NegocioConfigEmpresa.confsistema("tipoimpresion").ToString() == "tipocarro") { //con crystal report // miformnotaventa.Tipoimp = Convert.ToString(NegocioConfigEmpresa.confsistema("modoimpventa")); // miformnotaventa.Codventa = objventa.Idventa; // miformnotaventa.Show(); // con reportviewer mireporteventa.Idventa = objventa.Idventa; mireporteventa.ShowDialog(); } else { if (NegocioConfigEmpresa.marcafiscal == "elec" && tipofactura != "X") { Ticketventa miticket = new Formreportes.Ticketventa(objventa.Idventa); miticket.ShowDialog(); } else if (tipofactura == "X") { TicketProforma miticketproforma = new Formreportes.TicketProforma(objventa.Idventa); miticketproforma.ShowDialog(); } //miformticket.Tipoimp = Convert.ToString(NegocioConfigEmpresa.confsistema("modoimpventa")); //miformticket.Codventa = objventa.Idventa; //miformticket.Show(); } } if (facturar == true) { // NegocioFHasar objhasar = new NegocioFHasar(); //objhasar.Comprobantefiscal(1, 1, "CONSUMIDOR FINAL", "9999999", 1, "", dt,Convert.ToDouble (lblPrecioTotal.Text )); } // crystalReportViewer1.ReportSource = ventasTicket1; this.Close(); } else { UtilityFrm.mensajeError("Error en la base de Datos 1"); } } else { UtilityFrm.mensajeError("Error en la base de Datos 2"); } } catch (Exception ex) { UtilityFrm.mensajeError(ex.Message); } }