protected void CargarGastos() { dataGridView1.Columns.Clear(); dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Cod", DataPropertyName = "Cod" }); dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Hora", DataPropertyName = "Hora" }); dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Total", DataPropertyName = "Total" }); dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Descripcion", DataPropertyName = "Descripcion" }); dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn { Name = "Estado", DataPropertyName = "Estado" }); dataGridView1.DataSource = ConexionSQL.consultaDataTable(string.Format("Select Cod,Convert(varchar(5),Fecha,108)[Hora],Total,Descripcion,Estado from Gasto where Convert(varchar,Fecha,103)='{0}'", dateTimePicker1.Value.ToString("dd/MM/yyyy")), "Gasto"); var provider = new System.Globalization.CultureInfo("es-CR"); dataGridView1.Columns["Total"].DefaultCellStyle.FormatProvider = provider; dataGridView1.Columns["Total"].DefaultCellStyle.Format = "C2"; dataGridView1.Columns["Total"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Show(); textBox3.Text = string.Format("{0:c}", ConexionSQL.ConsultaUnica(string.Format("Select isnull(sum(Total),0)[Total] from Gasto where Convert(varchar,Fecha,103)='{0}' and Estado=1", dateTimePicker1.Value.ToString("dd/MM/yyyy")))); decimal paga = Convert.ToDecimal(textBox3.Text); string formateado = string.Format("{0:C}", paga); textBox3.Text = formateado; }
protected void Prueba(String Cod) { string NoSeq = ConexionSQL.ConsultaUnica(string.Format("Select NoSeq from (Select Cod,ROW_NUMBER() over(partition by convert(varchar,Fecha,103)order by Cod asc)NoSeq from Venta)a where Cod='{0}'", Cod)); decimal Descuento = Convert.ToDecimal(dtVenta.Compute("SUM(Descuento)", string.Empty)); decimal IV = Convert.ToDecimal(dtVenta.Compute("SUM(IVA)", string.Empty)); decimal total = Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty)); decimal SubTotal = total - IV + Descuento; Tiquete tkt = new Tiquete(); tkt.TicketNo = int.Parse(NoSeq); tkt.Discount = float.Parse(Descuento.ToString()); tkt.Iva = float.Parse(IV.ToString()); tkt.Total = float.Parse(total.ToString()); tkt.ticketDate = DateTime.Now; tkt.Cancela = txtCancela.Text; tkt.Vuelto = txtVuelto.Text; tkt.Voucher = textBox2.Text; if (radioButton1.Checked) { tkt.TipoPago = radioButton1.Text; } else { tkt.TipoPago = radioButton2.Text; } tkt.Productos = dtVenta; tkt.amount = float.Parse(SubTotal.ToString()); tkt.Cliente1 = txtCliente.Text; tkt.print(); }
private Int32 DetalleVenta(string NoVenta) { Decimal TotalIVA = 0.0m; string str = ""; int cont = 0; for (int i = 0; i < grvVenta.Rows.Count; i++) { decimal IVA; if (Convert.ToBoolean(grvVenta.Rows[i].Cells["IVA"].Value)) { IVA = Convert.ToDecimal(grvVenta.Rows[i].Cells["IVA"].Value); } else { IVA = 0.0m; } TotalIVA += IVA; string cod = ConexionSQL.ConsultaUnica(string.Format("Select isnull(max(Cod),0)+1 from DetalleVenta where Venta={0}", NoVenta)); str = string.Format(@"Insert into DetalleVenta(Cod,Venta,Producto,Descripcion,Cantidad,Precio,IVA,Descuento,Fecha,Estado) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',default,1)", cod, NoVenta, grvVenta.Rows[i].Cells["NoSeq"].Value, grvVenta.Rows[i].Cells["Descripcion"].Value, grvVenta.Rows[i].Cells["Cantidad"].Value, grvVenta.Rows[i].Cells["Precio"].Value, grvVenta.Rows[i].Cells["IVA"].Value, grvVenta.Rows[i].Cells["Descuento"].Value); try { if (ConexionSQL.DML(str) > 0) { cont++; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(cont); }
private void btnLastProv_Click(object sender, EventArgs e) { int total = Convert.ToInt32(ConexionSQL.ConsultaUnica("Select Count(*) from Proveedor")); txtCodigoPro.Text = string.Format("{0}", total); Proveedor(); }
private void button1_Click(object sender, EventArgs e) { try { string NoSeq = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Compra"); string osql = string.Format("set dateformat dmy;insert into Compra values ({0},'{1}','{2}','{3}','{4}','{5}','{6}',{7});", NoSeq, dtpFecha.Value.ToString("dd/MM/yyyy"), dtpVencimiento.Value.ToString("dd/MM/yyyy"), txtNumFact.Text, txtSubTotal.Text, txtDesc.Text, txtIVA.Text, cboProveedor.SelectedValue); int i = ConexionSQL.DML(osql); int qty = dataGridView1.Rows.Count; int contador = 0; if (i > 0) { foreach (DataGridViewRow dr in dataGridView1.Rows) { string j = ConexionSQL.ConsultaUnica(string.Format("Select isnull(max(NoSeq),0)+1 from DetalleCompra where Compra={0}", NoSeq)); osql = string.Format("insert into DetalleCompra values ({0},{1},{2},{3},{4});", j, NoSeq, dr.Cells["NoSeq"].Value, dr.Cells["Cantidad"].Value, dr.Cells["Precio"].Value); i = ConexionSQL.DML(osql); if (i > 0) { contador++; } } if (contador == qty) { MessageBox.Show("Compra procesada satisfactoriamente", "Registro de Compra", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { string NoSeq = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Gasto"); if (ConexionSQL.DML(String.Format("insert into Gasto values ({0},default,'{1}','{2}','{3}','{4}',1,default)", NoSeq, textBox4.Text, textBox1.Text, textBox2.Text, textBox5.Text)) > 0) { CargarGastos(); } }
private void btnVenta_Click(object sender, EventArgs e) { try { if (grvVenta.Rows.Count > 0 && txtCancela.Text.Length > 0 && (txtCancela.Text.Length) > 0) { string osql = ""; decimal Descuento = Convert.ToDecimal(dtVenta.Compute("SUM(Descuento)", string.Empty)); decimal IV = Convert.ToDecimal(dtVenta.Compute("SUM(IVA)", string.Empty)); decimal total = Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty)); decimal SubTotal = total - IV + Descuento; string cod = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Venta"); bool flag = false; if (radioButton2.Checked && !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(txtCliente.Text)) { osql = string.Format("insert into Venta(Cod, Cliente, SubTotal,Descuento,IVA,TipoPago, Referencia) values({0}, '{1}', '{2}','{3}','{4}', '{5}', '{6}')", cod, txtCliente.Text, SubTotal, Descuento, IV, radioButton2.Text, textBox2.Text); flag = true; } if (radioButton1.Checked && !string.IsNullOrEmpty(txtCliente.Text)) { osql = string.Format("insert into Venta(Cod,Cliente,SubTotal,Descuento,IVA,TipoPago) values ({0}, '{1}', '{2}','{3}','{4}', '{5}')", cod, txtCliente.Text, SubTotal, Descuento, IV, radioButton1.Text); flag = true; } if (flag) { int i = ConexionSQL.DML(osql); if (i > 0) { if (DetalleVenta(cod) == grvVenta.Rows.Count) { MessageBox.Show("Venta realizada con exito", "Venta Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); // PrintTicket(cod,false); // PrintTicket(cod,true); Prueba(cod); Limpiar(); } } else { MessageBox.Show("Ha ocurrido un error", "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Por favor valide todos los campos", "Información de Venta Incompleta", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("No puede realizar una venta sin productos que facturar", "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripButton3_Click(object sender, EventArgs e) { int NoVenta = Convert.ToInt32(txtNumero.Text); int max = Convert.ToInt32(ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0) from Venta")); if (NoVenta < max) { NoVenta++; txtNumero.Text = NoVenta.ToString(); CargarVenta(txtNumero.Text); } }
private void Limpiar() { txtNoSeq.Text = ConexionSQL.ConsultaUnica("Select isnull(max(NoSeq),0)+1 from Producto"); txtBarCode.Focus(); txtCode.Text = ""; txtCosto.Text = ""; txtDescripcion.Text = ""; txtPrecio.Text = ""; rdbConIVA.Checked = false; rdbSinIVA.Checked = false; rdbHabilitado.Checked = false; rdbDeshabilitado.Checked = false; txtBarCode.Text = ""; }
private void detalleToolStripMenuItem_Click(object sender, EventArgs e) { string numero = ConexionSQL.ConsultaUnica("Select isnull(min(Cod),0) from Venta"); if (numero.Equals("0")) { MessageBox.Show("No se ha realizado ninguna venta", "Sin registro de ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { VentaDetalle vd = new VentaDetalle(); vd.MdiParent = this; vd.Show(); } }
private void Compra_Load(object sender, EventArgs e) { dtpFecha.Value = DateTime.Now; dtpVencimiento.Value = DateTime.Now; dtVenta = new DataTable(); dtVenta.Columns.Add("NoSeq", typeof(int)); dtVenta.Columns.Add("Descripcion", typeof(String)); dtVenta.Columns.Add("Cantidad", typeof(decimal)); dtVenta.Columns.Add("Precio", typeof(decimal)); dtVenta.Columns.Add("Total", typeof(decimal)); tabControl1.SelectedIndex = 1; lblTotalProv.Text = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor")); txtCodigoPro.Text = "1"; Proveedor(); }
private void toolStripButton1_Click(object sender, EventArgs e) { try { int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Producto where NoSeq='{0}'", txtNoSeq.Text))); int IVA = 0; int habilitado = 0; if (rdbConIVA.Checked) { IVA = 1; } if (rdbHabilitado.Checked) { habilitado = 1; } if (flag > 0) { int u = ConexionSQL.DML(string.Format("Update Producto set BarCode='{0}',Code='{1}',Descripcion='{2}',Categoria='{3}',Marca='{4}',IVA='{5}',Costo='{6}',PrecioVenta='{7}',Estado={9} where NoSeq='{8}'", txtBarCode.Text, txtCode.Text, txtDescripcion.Text, comboBox2.SelectedValue, comboBox1.SelectedValue, IVA, txtCosto.Text, txtPrecio.Text, txtNoSeq.Text, habilitado)); if (u > 0) { MessageBox.Show("Actualización efectuada correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } } else { if (ConexionSQL.ConsultaUnica(String.Format("Select count(*) from Producto where BarCode='{0}'", txtBarCode.Text)).Equals("0")) { int i = ConexionSQL.DML(string.Format("insert into Producto values ({0},'{1}','{2}','{3}',{4},{5},{6},'{7}','{8}',1)", txtNoSeq.Text, txtBarCode.Text, txtCode.Text, txtDescripcion.Text, comboBox1.SelectedValue, comboBox2.SelectedValue, IVA, txtCosto.Text, txtPrecio.Text)); if (i > 0) { MessageBox.Show("Registro efectuado correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } } else { MessageBox.Show("El Codigo de Barras ya existe", "Codigo de barras duplicado", MessageBoxButtons.OK, MessageBoxIcon.Error); txtBarCode.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtBarCode_TextChanged(object sender, EventArgs e) { try { string BarCode = txtBarCode.Text; string flag = ConexionSQL.ConsultaUnica(string.Format("Select count(*) from Producto where BarCode='{0}'", BarCode)); if (flag.Equals("1")) { //Buscar Producto Producto producto = new Producto(); Producto p1 = producto.GetList().Find(x => x.BarCode1 == BarCode); // Get all DataRows where the name is the name you want. IEnumerable <DataRow> rows = dtVenta.Rows.Cast <DataRow>().Where(r => r["Descripcion"].ToString() == p1.Descripcion1); // Loop through the rows and change the name. if (rows.Count() == 0) { dtVenta.Rows.Add(p1.NoSeq1, p1.Descripcion1, "0.0", "0.0", "0.0"); } dataGridView1.DataSource = dtVenta; dataGridView1.Show(); int n = Convert.ToInt32(dataGridView1.Rows.Count.ToString()); for (int i = 0; i < n; i++) { dataGridView1.Rows[i].Cells[0].ReadOnly = true; dataGridView1.Rows[i].Cells[1].ReadOnly = true; dataGridView1.Rows[i].Cells[4].ReadOnly = true; } txtBarCode.Text = ""; txtBarCode.Focus(); txtSubTotal.Text = String.Format(CultureInfo.CreateSpecificCulture("es-CR"), "{0}", Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty))); txtTotal.Text = string.Format("{0:c}", Convert.ToDecimal(txtSubTotal.Text) - Convert.ToDecimal(txtDesc.Text) + Convert.ToDecimal(txtIVA.Text)); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Escaneo Fallido", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { try { int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Marca where Descripcion='{0}'", textBox1.Text))); if (flag == 1) { int i = ConexionSQL.DML(string.Format("Update Marca set Estado=1 where Descripcion='{0}'", textBox1.Text)); if (i > 0) { CargarMarcas(); textBox1.Text = ""; textBox1.Focus(); } else { textBox1.Focus(); } } else if (flag == 0) { int i = ConexionSQL.DML(string.Format("Insert into Marca values ('{0}',1)", textBox1.Text)); if (i > 0) { CargarMarcas(); textBox1.Text = ""; textBox1.Focus(); } else { textBox1.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGuardarProv_Click(object sender, EventArgs e) { int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select count(*) from Proveedor where Cod='{0}'", txtCodigoPro.Text))); string osql = ""; string mensaje = "", Titulo = ""; if (flag == 0) { osql = string.Format("insert into Proveedor values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',1)", txtNombreProv.Text, txtContactoProv.Text, txtTelefonoProv.Text, txtCelProv.Text, txtDireccionProv.Text, txtEmailProv.Text, txtComentarioProv.Text); mensaje = "Registro insertado correctamente"; Titulo = "Inserción"; tabControl1.SelectedIndex = 1; lblTotalProv.Text = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor")); txtCodigoPro.Text = "1"; Proveedor(); } else { int est = 0; if (rdbHabPro.Checked) { est = 1; } osql = string.Format("Update Proveedor set Nombre='{0}',Contacto='{1}',Telefono='{2}',Celular='{3}',Direccion='{4}',Correo='{5}',Comentarios='{6}',Estado='{8}' where Cod={7}", txtNombreProv.Text, txtContactoProv.Text, txtTelefonoProv.Text, txtCelProv.Text, txtDireccionProv.Text, txtEmailProv.Text, txtComentarioProv.Text, txtCodigoPro.Tag, est); mensaje = "Registro actualizado correctamente"; Titulo = "Actualización"; } int i = ConexionSQL.DML(osql); if (i > 0) { tabControl1.SelectedIndex = 1; } MessageBox.Show(mensaje, Titulo, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); lblTotalProv.Text = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor")); txtCodigoPro.Text = "1"; Proveedor(); }
private void btnApertura_Click(object sender, EventArgs e) { try { string NoCa = ConexionSQL.ConsultaUnica("Select isnull(max(NoSeq),0)+1 NoSeq from Caja"); int i = ConexionSQL.DML(string.Format("insert into Caja values({1},default,default,default,'{0}',default,0)", txtApertura.Text, NoCa)); if (i > 0) { MessageBox.Show("Apertura realizada con éxito", "Apertura de Caja", MessageBoxButtons.OK, MessageBoxIcon.Information); decimal Apertura = decimal.Parse(txtApertura.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint); txtApertura.Text = String.Format("{0:c}", Apertura); txtApertura.Enabled = false; btnApertura.Visible = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error de Apertura", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripButton4_Click(object sender, EventArgs e) { try{ int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Producto where NoSeq='{0}'", txtNoSeq.Text))); if (flag > 0) { int habilitado = 0; if (rdbHabilitado.Checked) { habilitado = 1; } int u = ConexionSQL.DML(string.Format("Update Producto set Estado={1} where NoSeq='{0}'", txtNoSeq.Text, habilitado)); if (u > 0) { MessageBox.Show("Actualizaciön efectuada correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtCodigo_TextChanged(object sender, EventArgs e) { try { string BarCode = txtCodigo.Text; string flag = ConexionSQL.ConsultaUnica(string.Format("Select count(*) from Producto where BarCode='{0}'", BarCode)); if (flag.Equals("1")) { //Buscar Producto Producto producto = new Producto(); Producto p1 = producto.GetList().Find(x => x.BarCode1 == BarCode); // Get all DataRows where the name is the name you want. IEnumerable <DataRow> rows = dtVenta.Rows.Cast <DataRow>().Where(r => r["Descripcion"].ToString() == p1.Descripcion1); // Loop through the rows and change the name. if (rows.Count() > 0) { Producto p = new Producto(); Producto p2 = p.GetInventory().Find(x => x.NoSeq1 == p1.NoSeq1); DataRow[] dr = dtVenta.Select(string.Format("NoSeq = '{0}'", p1.NoSeq1)); decimal Cantidad = Convert.ToDecimal(dr[0]["Cantidad"].ToString()); if (Properties.Settings.Default.Inv) { if (Cantidad < p2.Saldo) { rows.ToList().ForEach(r => r.SetField("Cantidad", (r.Field <decimal>("Cantidad")) + 1)); rows.ToList().ForEach(r => r.SetField("Descuento", (r.Field <decimal>("Cantidad")) * ((p2.PrecioVenta1 * Convert.ToInt32(textBox1.Text)) / 100))); if (p2.IV1) { rows.ToList().ForEach(r => r.SetField("IVA", (((r.Field <decimal>("Cantidad") * p2.PrecioVenta1) - r.Field <decimal>("Descuento")) * Properties.Settings.Default.IV) / 100)); } else { rows.ToList().ForEach(r => r.SetField("IVA", 0)); } rows.ToList().ForEach(r => r.SetField("Total", (((r.Field <decimal>("Cantidad")) * (r.Field <decimal>("Precio"))) - r.Field <decimal>("Descuento")) + r.Field <decimal>("IVA"))); } else { MessageBox.Show("Inventario Insuficiente", "Inventario Insuficiente", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { rows.ToList().ForEach(r => r.SetField("Cantidad", (r.Field <decimal>("Cantidad")) + 1)); rows.ToList().ForEach(r => r.SetField("Descuento", (r.Field <decimal>("Cantidad")) * ((p1.PrecioVenta1 * Convert.ToInt32(textBox1.Text)) / 100))); if (p1.IV1) { rows.ToList().ForEach(r => r.SetField("IVA", (((r.Field <decimal>("Cantidad") * p1.PrecioVenta1) - r.Field <decimal>("Descuento")) * Properties.Settings.Default.IV) / 100)); } else { rows.ToList().ForEach(r => r.SetField("IVA", 0)); } rows.ToList().ForEach(r => r.SetField("Total", (((r.Field <decimal>("Cantidad")) * (r.Field <decimal>("Precio"))) - r.Field <decimal>("Descuento")) + r.Field <decimal>("IVA"))); } } else { Producto p = new Producto(); Producto p2 = p.GetInventory().Find(x => x.NoSeq1 == p1.NoSeq1); decimal Cantidad = 1m; if (Properties.Settings.Default.Inv) { if (Cantidad < p2.Saldo) { decimal Desc = (p1.PrecioVenta1 * Convert.ToInt32(textBox1.Text)) / 100; decimal IVA = ((p1.PrecioVenta1 - Desc) * Properties.Settings.Default.IV) / 100; if (!p1.IV1) { IVA = 0.0m; } decimal Total = p1.PrecioVenta1 - Desc + IVA; dtVenta.Rows.Add(p1.NoSeq1, p1.Code1, p1.Descripcion1, 1, p1.PrecioVenta1.ToString("0.##"), Desc, string.Format("{0}", IVA), (Total).ToString("0.##")); } else { MessageBox.Show("Inventario Insuficiente", "Inventario Insuficiente", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { decimal Desc = (p1.PrecioVenta1 * Convert.ToInt32(textBox1.Text)) / 100; decimal IVA = ((p1.PrecioVenta1 - Desc) * Properties.Settings.Default.IV) / 100; if (!p1.IV1) { IVA = 0.0m; } decimal Total = p1.PrecioVenta1 - Desc + IVA; dtVenta.Rows.Add(p1.NoSeq1, p1.Code1, p1.Descripcion1, 1, p1.PrecioVenta1.ToString("0.##"), Desc, string.Format("{0}", IVA), (Total).ToString("0.##")); } } grvVenta.DataSource = dtVenta; grvVenta.Show(); txtCodigo.Text = ""; txtCodigo.Focus(); if (dtVenta.Rows.Count > 0) { txtTotal.Text = String.Format(CultureInfo.CreateSpecificCulture("es-CR"), "{0:C2}", Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty))); var provider = new System.Globalization.CultureInfo("es-CR"); grvVenta.Columns["Precio"].DefaultCellStyle.FormatProvider = provider; grvVenta.Columns["Precio"].DefaultCellStyle.Format = "C2"; grvVenta.Columns["Precio"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; grvVenta.Columns["Descuento"].DefaultCellStyle.FormatProvider = provider; grvVenta.Columns["Descuento"].DefaultCellStyle.Format = "C2"; grvVenta.Columns["Descuento"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; grvVenta.Columns["IVA"].DefaultCellStyle.FormatProvider = provider; grvVenta.Columns["IVA"].DefaultCellStyle.Format = "C2"; grvVenta.Columns["IVA"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; grvVenta.Columns["Total"].DefaultCellStyle.FormatProvider = provider; grvVenta.Columns["Total"].DefaultCellStyle.Format = "C2"; grvVenta.Columns["Total"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; int n = Convert.ToInt32(grvVenta.Rows.Count.ToString()); for (int i = 0; i < n - 1; i++) { if (Convert.ToInt32(grvVenta.Rows[i].Cells[0].Value) == 166) { grvVenta.Rows[i].Cells[0].ReadOnly = true; grvVenta.Rows[i].Cells[1].ReadOnly = true; grvVenta.Rows[i].Cells["Descripcion"].ReadOnly = false; grvVenta.Rows[i].Cells["Precio"].ReadOnly = false; grvVenta.Rows[i].Cells["IVA"].ReadOnly = false; grvVenta.Rows[i].Cells["Descuento"].ReadOnly = false; grvVenta.Rows[i].Cells[7].ReadOnly = true; } else { grvVenta.Rows[i].Cells[0].ReadOnly = true; grvVenta.Rows[i].Cells[1].ReadOnly = true; grvVenta.Rows[i].Cells[2].ReadOnly = true; grvVenta.Rows[i].Cells[4].ReadOnly = true; grvVenta.Rows[i].Cells[5].ReadOnly = true; grvVenta.Rows[i].Cells[6].ReadOnly = true; grvVenta.Rows[i].Cells[7].ReadOnly = true; } } } } } catch (Exception ex) { lblResult.Text = ex.Message; } }
private void VentaDetalle_Load(object sender, EventArgs e) { txtNumero.Text = ConexionSQL.ConsultaUnica("Select isnull(min(Cod),0) from Venta"); CargarVenta(txtNumero.Text); toolStripLabel1.Text = string.Format(" de {0}", ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0) from Venta")); }
private void toolStripButton4_Click(object sender, EventArgs e) { txtNumero.Text = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0) from Venta"); CargarVenta(txtNumero.Text); }