private void CargarListado() { DataTable dt = new DataTable(); dt = P.Listar(); try { dataGridView1.Rows.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { dataGridView1.Rows.Add(dt.Rows[i][0]); dataGridView1.Rows[i].Cells[0].Value = dt.Rows[i][0].ToString(); dataGridView1.Rows[i].Cells[1].Value = dt.Rows[i][1].ToString(); dataGridView1.Rows[i].Cells[2].Value = dt.Rows[i][2].ToString(); dataGridView1.Rows[i].Cells[3].Value = dt.Rows[i][3].ToString(); dataGridView1.Rows[i].Cells[4].Value = dt.Rows[i][4].ToString(); dataGridView1.Rows[i].Cells[5].Value = dt.Rows[i][5].ToString(); dataGridView1.Rows[i].Cells[6].Value = dt.Rows[i][6].ToString(); dataGridView1.Rows[i].Cells[7].Value = Convert.ToDateTime(dt.Rows[i][7].ToString()).ToShortDateString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dataGridView1.ClearSelection(); }
private void CargarListado() { List <clsProducto> listProductos = new List <clsProducto>(); listProductos = P.Listar(); dataGridView1.DataSource = listProductos; dataGridView1.ClearSelection(); }
private void CargarListado() { List <clsProducto> listProductos = new List <clsProducto>(); listProductos = P.Listar(); gridProductos.ItemsSource = listProductos; gridProductos.Items[0].GetType(); }
private void CargarListado() { DataTable dt = new DataTable(); dt = P.Listar(); dataGridView1.Rows.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { dataGridView1.Rows.Add(dt.Rows[i][0]); dataGridView1.Rows[i].Cells[0].Value = dt.Rows[i][0].ToString(); dataGridView1.Rows[i].Cells[1].Value = dt.Rows[i][1].ToString(); dataGridView1.Rows[i].Cells[2].Value = dt.Rows[i][2].ToString(); dataGridView1.Rows[i].Cells[3].Value = dt.Rows[i][3].ToString(); dataGridView1.Rows[i].Cells[4].Value = dt.Rows[i][4].ToString(); } dataGridView1.ClearSelection(); }
public void GetAllProduct() { if (clsGenericList.listProducto.Count > 0) { CargarListado(clsGenericList.listProducto.OrderBy(x => x.m_IdP).ToList()); } else { DataTable dt = new DataTable(); dt = P.Listar(); try { foreach (DataRow reader in dt.Rows) { Producto product = new Producto(); product.m_IdP = reader["IdProducto"] == DBNull.Value ? 0 : Convert.ToInt32(reader["IdProducto"]); product.m_IdCategoria = reader["IdCategoria"] == DBNull.Value ? 0 : Convert.ToInt32(reader["IdCategoria"]); product.m_Producto = reader["Nombre"] == DBNull.Value ? string.Empty : reader["Nombre"].ToString(); product.m_tipoGoma = reader["tipoGOma"] == DBNull.Value ? string.Empty : reader["tipoGOma"].ToString(); product.m_itbis = reader["itbis"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["itbis"]); product.m_PrecioVenta = reader["PrecioVenta"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["PrecioVenta"]); product.m_PrecioCompra = reader["PrecioCompra"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["PrecioCompra"]); product.m_Preciomax = reader["Pmax"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["Pmax"]); product.m_Preciomin = reader["Pmin"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["Pmin"]); product.m_FechaVencimiento = Convert.ToDateTime(reader["FechaVencimiento"]); product.m_Stock = reader["Stock"] == DBNull.Value ? 0 : Convert.ToInt32(reader["Stock"]); product.m_FechaModificacion = Convert.ToDateTime(reader["FechaModificacion"]); product.m_Marca = reader["Marca"] == DBNull.Value ? string.Empty : reader["Marca"].ToString(); clsGenericList.listProducto.Add(product); } CargarListado(clsGenericList.listProducto.OrderBy(x => x.m_IdP).ToList()); } catch (Exception ex) { DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message); } } }
private void LlenarGridProducto() { DataTable dt = new DataTable(); if (rbActivo.Checked) { P.Estado = true; } else if (rbInactivo.Checked) { P.Estado = false; } dt = P.Listar(); try { dtgProducto.Rows.Clear(); for (int x = 0; x < dt.Rows.Count; x++) { dtgProducto.Rows.Add(dt.Rows[x][0]); dtgProducto.Rows[x].Cells[1].Value = dt.Rows[x][0].ToString(); dtgProducto.Rows[x].Cells[2].Value = dt.Rows[x][1].ToString(); dtgProducto.Rows[x].Cells[3].Value = dt.Rows[x][2].ToString(); dtgProducto.Rows[x].Cells[4].Value = dt.Rows[x][3].ToString(); dtgProducto.Rows[x].Cells[5].Value = dt.Rows[x][4].ToString(); dtgProducto.Rows[x].Cells[6].Value = dt.Rows[x][5].ToString(); dtgProducto.Rows[x].Cells[7].Value = dt.Rows[x][6].ToString(); dtgProducto.Rows[x].Cells[8].Value = dt.Rows[x][7].ToString(); dtgProducto.Rows[x].Cells[9].Value = dt.Rows[x][8].ToString(); dtgProducto.Rows[x].Cells[10].Value = dt.Rows[x][9].ToString(); dtgProducto.Rows[x].Cells[11].Value = dt.Rows[x][10].ToString(); } dtgProducto.ClearSelection(); } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnGuardar_Click(object sender, EventArgs e) { M.Desconectar(); if (M.conexion != null && M.conexion.State == ConnectionState.Open) { M.Desconectar(); } clsProducto P = new clsProducto(); if (txtProducto.Text.Trim() != "") { if (txtMarca.Text.Trim() != "") { if (txtPCompra.Text.Trim() != "") { if (txtPVenta.Text.Trim() != "") { if (txtStock.Text.Trim() != "") { using (SqlCommand cmd = new SqlCommand("RegistrarProducto", M.conexion)) { var exist = clsGenericList.listProducto.FirstOrDefault(x => x.m_Producto == txtProducto.Text.ToUpper() && x.m_Marca == txtMarca.Text.ToUpper()); if (exist != null) { DevComponents.DotNetBar.MessageBoxEx.Show("El producto ya existe", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error); M.Desconectar(); } else { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IdCategoria", SqlDbType.Int).Value = cbxCategoria.SelectedValue; cmd.Parameters.Add("@Nombre", SqlDbType.NVarChar).Value = txtProducto.Text.ToUpper(); cmd.Parameters.Add("@Marca", SqlDbType.NVarChar).Value = txtMarca.Text.ToUpper(); cmd.Parameters.Add("@Stock", SqlDbType.Int).Value = txtStock.Text; cmd.Parameters.Add("@PrecioCompra", SqlDbType.Decimal).Value = txtPCompra.Text; cmd.Parameters.Add("@PrecioVenta", SqlDbType.Decimal).Value = txtPVenta.Text; cmd.Parameters.Add("@itbis", SqlDbType.Decimal).Value = txtitbis.Text; cmd.Parameters.Add("@TipoGoma", SqlDbType.NVarChar).Value = cbtipo.Text; cmd.Parameters.Add("@FechaVencimiento", SqlDbType.Date).Value = dateTimePicker1.Text; cmd.Parameters.Add("@FechaModificacion", SqlDbType.Date).Value = dateTimePicker1.Text; cmd.Parameters.Add("@Pmax", SqlDbType.Decimal).Value = 0; cmd.Parameters.Add("@Pmin", SqlDbType.Decimal).Value = 0; M.Conectar(); cmd.ExecuteNonQuery(); M.Desconectar(); Producto product = new Producto(); int idP = clsGenericList.listProducto.Count + 1; product.m_IdP = idP; product.m_IdCategoria = Convert.ToInt32(cbxCategoria.SelectedValue); product.m_Producto = txtProducto.Text; product.m_tipoGoma = cbtipo.Text; product.m_itbis = Convert.ToDecimal(txtitbis.Text); product.m_PrecioVenta = Convert.ToDecimal(txtPVenta.Text); product.m_PrecioCompra = Convert.ToDecimal(txtPCompra.Text); product.m_Preciomax = 0; product.m_Preciomin = 0; product.m_Stock = Convert.ToInt32(txtStock.Text); product.m_Marca = txtMarca.Text; product.m_FechaModificacion = dateTimePicker1.Value; product.m_FechaVencimiento = dateTimePicker1.Value; clsGenericList.listProducto.Add(product); P.Listar(); ListarElementos(); Limpiar(); } } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Stock del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtStock.Focus(); } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Precio de Venta del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPVenta.Focus(); } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Precio de Compra del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPCompra.Focus(); } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Marca del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMarca.Focus(); } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Nombre del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtProducto.Focus(); } }
public void CargarListados() { #region Listado Ventas if (clsGenericList.listVentas is null) { clsGenericList.listVentas = new List <Venta>(); clsGenericList.idsVentas = new List <int>(); clsVentas V = new clsVentas(); DataTable dtV = new DataTable(); dtV = V.Listado(); try { foreach (DataRow reader in dtV.Rows) { Venta venta = new Venta(); venta.IdVenta = reader["IdVenta"] == DBNull.Value ? 0 : Convert.ToInt32(reader["IdVenta"]); venta.IdEmpleado = reader["IdEmpleado"] == DBNull.Value ? 0 : Convert.ToInt32(reader["IdEmpleado"]); venta.TipoDocumento = reader["TipoDocumento"] == DBNull.Value ? string.Empty : reader["TipoDocumento"].ToString(); venta.NroComprobante = reader["NroDocumento"] == DBNull.Value ? string.Empty : reader["NroDocumento"].ToString(); venta.Total = reader["Total"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["Total"]); venta.Tipofactura = reader["Tipofactura"] == DBNull.Value ? string.Empty : reader["Tipofactura"].ToString(); venta.Restante = reader["Restante"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["Restante"]); venta.FechaVenta = Convert.ToDateTime(reader["FechaVenta"]); venta.NombreCliente = reader["NombreCliente"] == DBNull.Value ? string.Empty : reader["NombreCliente"].ToString(); venta.UltimaFechaPago = Convert.ToDateTime(reader["UltimaFechaPago"]); venta.borrador = reader["borrado"] == DBNull.Value ? 0 : Convert.ToInt32(reader["borrado"]); clsGenericList.listVentas.Add(venta); } clsGenericList.listVentas.ForEach(x => clsGenericList.idsVentas.Add(x.IdVenta)); } catch (Exception ex) { DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message); } } #endregion #region Listado Productos if (clsGenericList.listProducto is null) { clsGenericList.listProducto = new List <Producto>(); clsProducto P = new clsProducto(); DataTable dtP = new DataTable(); dtP = P.Listar(); try { foreach (DataRow reader in dtP.Rows) { Producto product = new Producto(); product.m_IdP = reader["IdProducto"] == DBNull.Value ? 0 : Convert.ToInt32(reader["IdProducto"]); product.m_IdCategoria = reader["IdCategoria"] == DBNull.Value ? 0 : Convert.ToInt32(reader["IdCategoria"]); product.m_Producto = reader["Nombre"] == DBNull.Value ? string.Empty : reader["Nombre"].ToString(); product.m_tipoGoma = reader["tipoGOma"] == DBNull.Value ? string.Empty : reader["tipoGOma"].ToString(); product.m_itbis = reader["itbis"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["itbis"]); product.m_PrecioVenta = reader["PrecioVenta"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["PrecioVenta"]); product.m_PrecioCompra = reader["PrecioCompra"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["PrecioCompra"]); product.m_Preciomax = reader["Pmax"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["Pmax"]); product.m_Preciomin = reader["Pmin"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["Pmin"]); product.m_FechaVencimiento = Convert.ToDateTime(reader["FechaVencimiento"]); product.m_Stock = reader["Stock"] == DBNull.Value ? 0 : Convert.ToInt32(reader["Stock"]); product.m_FechaModificacion = Convert.ToDateTime(reader["FechaModificacion"]); product.m_Marca = reader["Marca"] == DBNull.Value ? string.Empty : reader["Marca"].ToString(); clsGenericList.listProducto.Add(product); } } catch (Exception ex) { DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message); } } #endregion }