示例#1
0
 private void BtnSeleccionar_Click(object sender, EventArgs e)
 {
     if (DgvCliente.SelectedRows.Count > 0)
     {
         int rowindex = DgvCliente.CurrentRow.Index;
         if (rowindex != -1)
         {
             try
             {
                 FrmVenta frm = Owner as FrmVenta;
                 frm.LblIDCliente.Text       = DgvCliente.CurrentRow.Cells[0].Value.ToString();
                 frm.TxtNumeroDocumento.Text = DgvCliente.CurrentRow.Cells[2].Value.ToString();
                 frm.TxtNombres.Text         = DgvCliente.CurrentRow.Cells[3].Value.ToString() + " " + DgvCliente.CurrentRow.Cells[4].Value.ToString();
                 string direccion = DgvCliente.CurrentRow.Cells[8].Value.ToString() + ", " + DgvCliente.CurrentRow.Cells[7].Value.ToString();
                 frm.TxtDireccion.Text = direccion;
                 Close();
             }
             catch
             {
                 //
             }
         }
     }
     else
     {
         MessageBox.Show("Seleccione un registro");
     }
 }
示例#2
0
 private void BtnSeleccionar_Click(object sender, EventArgs e)
 {
     if (DgvProducto.SelectedRows.Count > 0)
     {
         int rowindex = DgvProducto.CurrentRow.Index;
         if (rowindex != -1)
         {
             try
             {
                 FrmVenta frm            = Owner as FrmVenta;
                 string   codigoproducto = DgvProducto.CurrentRow.Cells[3].Value.ToString();
                 frm.TxtProducto.Text = codigoproducto;
                 DProducto boProducto = new DProducto();
                 Producto  producto   = boProducto.Seleccionar(codigoproducto);
                 if (string.IsNullOrEmpty(producto.Codigo))
                 {
                     MessageBox.Show("No Existe Producto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
                 else
                 {
                     DInventario boInventario = new DInventario();
                     Inventario  inventario   = boInventario.Seleccionar(producto.Codigo);
                     if (!string.IsNullOrEmpty(inventario.Producto))
                     {
                         if (inventario.Existencias > 0)
                         {
                             double utilidad    = FrmPrincipal.ValorUtilidad;
                             double precioventa = Math.Round((inventario.ValorUnitario * utilidad), 2);
                             frm.AddItems(producto, 1, precioventa);
                             //Mostrar imagen
                             if (!string.IsNullOrEmpty(producto.Imagen))
                             {
                                 frm.PbxImgProducto.Image = Image.FromFile(CarpetaImagen + "/" + producto.Imagen);
                             }
                         }
                         else
                         {
                             MessageBox.Show("No hay Cantidad Suficiente");
                         }
                     }
                 }
                 Close();
             }
             catch
             {
                 //
             }
         }
     }
     else
     {
         MessageBox.Show("Seleccione un registro");
     }
 }