Академический Документы
Профессиональный Документы
Культура Документы
STUDIO .NET
namespace WindowsFormsApplication1
{
class usuarios:conexion
{
public usuarios() {
usuario = string.Empty;
contrasena = string.Empty;
this.sql = string.Empty;
}
else
{
mensajes = "Datos incorrectos";
}
this.cnn.Close();
return resultado;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
int a;
int b;
int c;
{
}
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
combobox combo = new combobox();
agregarproducto c = new agregarproducto();
public Form3()
{
InitializeComponent();
combo.Seleccionar(cob:comboBox2);
combo cb = new combo();
cb.llenaritems(comboBox1);
}
private void tabPage2_Click(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
{
MessageBox.Show("datos insertados");
this.Refresh();
proCodigo.Clear();
proDescripcion.Clear();
proValor.Clear();
proCantidad.Clear();
this.Hide();
}
else
{
MessageBox.Show("datos no insertados");
}
}
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from productosT where proDescripcion like ('" +
comboBox1.Text + "%')";
cmd.ExecuteNonQuery();
da.Fill(dt);
dgv.DataSource = dt;
conexen.Close();
}
{
MessageBox.Show("Datos Actualizado");
this.Hide();
}
else MessageBox.Show("Datos No Actualizados");
}
else MessageBox.Show("Datos No Eliminados");
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
double val;
double cant;
decimal resultado;
public Form4()
{
InitializeComponent();
combo.Seleccionar(cob: listaCli);
combo.SeleccionarProducto(cob: listaPro);
combo cb = new combo();
cb.Users(username);
val = Convert.ToDouble(Valor.Text);
cant = Convert.ToDouble(cantidad.Text);
resultado = Convert.ToDecimal(val * cant);
suma.Text = resultado.ToString();
fila.Cells[5].Valuefila.Cells[4].Value == CodPro.Text;factura.Text;
fila.Cells[6].Value = cantidad.Text;
dgv.Rows.Add(fila);
fecha.Text = "";
cantidad.Text = "";
listaPro.Text = "";
CodPro.Text = "";
listaPro.ResetText();
decimal total = 0;
foreach (DataGridViewRow Row in dgv.Rows)
{
total += Convert.ToDecimal(Row.Cells["colum4"].Value);
}
valortotal.Text = Convert.ToString(total);
telefono.Text = valores[2];
correo.Text = valores[3];
}
}
if(string.IsNullOrWhiteSpace(factura.Text))
{
MessageBox.Show("error");
}
else
{
if (consultar == factura.Text)
{
MessageBox.Show("Esta factura ya existe");
}
else
{
try
{
foreach(DataGridViewRow Row in dgv.Rows)
{
SqlCommand agregar = new SqlCommand("insert into facturas values
(@facNumero, @facFecha, @facCliente, @facValortotal, @facVendedor)", conex);
conex.Open();
agregar.Parameters.Clear();
agregar.Parameters.AddWithValue("@facNumero",
Convert.ToString(factura.Text));
agregar.Parameters.AddWithValue("@facFecha",
Convert.ToString(Row.Cells["colum2"].Value));
agregar.Parameters.AddWithValue("@facCliente",
Convert.ToString(Row.Cells["colum3"].Value));
agregar.Parameters.AddWithValue("@facValortotal",
Convert.ToString(valortotal.Text)); agregar.Parameters.AddWithValue("@facVendedor",
Convert.ToString(Row.Cells["colum5"].Value));
agregar.ExecuteNonQuery();
}
}
catch
{
}
finally
{
}
}
try
{
SqlCommand agregarPro = new SqlCommand("insert into facturadetalleT values
(@facNumero, @facProducto, @facCantidad)", conex);
agregarPro.Parameters.Clear();
agregarPro.Parameters.AddWithValue("@facNumero",
Convert.ToString(Row.Cells["Column6"].Value));
agregarPro.Parameters.AddWithValue("@facProducto",
Convert.ToInt32(Row.Cells["Column7"].Value));
agregarPro.Parameters.AddWithValue("@facCantidad",
Convert.ToInt32(Row.Cells["Column8"].Value));
agregarPro.ExecuteNonQuery();
}
MessageBox.Show("Datos agregados");
}
catch (Exception ex)
{
MessageBox.Show("Error al guardar"+ex);
}
finally
{
conex.Close();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
}
private void Form5_Load(object sender, EventArgs e)
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from productosT where proDescripcion like ('" + comboBox2.Text + "%')";
cmd.ExecuteNonQuery();
da.Fill(dt);
dgv.DataSource = dt;
conex.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Clientes : Form
{
agregarcliente c = new agregarcliente();
public Clientes()
{
InitializeComponent();
}
}
agregarcliente sql = new agregarcliente();
private void button1_Click(object sender, EventArgs e)
{
if (sql.Insertar(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text,
textBox5.Text) == true)
{
MessageBox.Show("datos insertados");
this.Refresh();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
this.Hide();
}
else
{
MessageBox.Show("datos no insertados");
}
} }
namespace WindowsFormsApplication1
{
class conexion
{
public string cadenaconexion;
protected string sql;
protected int resultado;
protected SqlConnection cnn;
protected SqlCommand comandosql;
protected string mensajes;
public conexion()
{
this.cadenaconexion = (@"Data Source=.;Initial Catalog =facturacion; integrated
security=true");
}
}
USUARIOS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class usuarios:conexion
{
public usuarios() {
usuario = string.Empty;
contrasena = string.Empty;
this.sql = string.Empty;
}
else
{
mensajes = "Datos incorrectos";
}
this.cnn.Close();
return resultado;
}
}
}
AGREGAR PRODUCTO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class agregarproducto
{
private SqlConnection conexion = new SqlConnection("Data Source=.;Initial
Catalog=facturacion;Integrated Security=True");
private DataSet ds;
ad.Fill(ds, "tabla");
conexion.Close();
return ds.Tables["tabla"];
}
}
AGREGAR CLIENTE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class agregarcliente
{
private SqlConnection conexion = new SqlConnection("Data Source=.;Initial
Catalog=facturacion;Integrated Security=True");
private DataSet ds;
public bool Insertar(string cliDocumento, string cliNombre, string cliDireccion, string cliTelefono,string
cliCorreo)
{
conexion.Open();
SqlCommand cmd = new SqlCommand(string.Format("insert into clientes values ({0}, '{1}',
'{2}', '{3}', '{4}')", new string[] { cliDocumento, cliNombre, cliDireccion, cliTelefono, cliCorreo }), conexion);
}
}
AGREGAR FACTURA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class agregarfactura
{
private SqlConnection conexion = new SqlConnection("Data Source=.;Initial
Catalog=facturacion;Integrated Security=True");
private DataSet ds;
ad.Fill(ds, "tabla");
conexion.Close();
return ds.Tables["tabla"];
}
public bool FacturaDetalle(string facNumero, string facProducto, string FacCantidad)
{
conexion.Open();
SqlCommand cmd = new SqlCommand(string.Format("insert into productosT values ({0},
'{1}', '{2}')", new string[] { facNumero, facProducto, FacCantidad}), conexion);
}
}
namespace WindowsFormsApplication1
{
class combo
{
SqlCommand cmd;
SqlConnection cnn;
SqlDataReader dr;
public combo()
{
try
{
cnn = new SqlConnection("Data Source=.;Initial
Catalog=facturacion;Integrated Security=True");
cnn.Open();
}
catch (Exception ex)
{
}
}
}
catch (Exception ex)
{
}
}
}
catch (Exception ex)
{
} }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
class combobox
{
SqlConnection con = new SqlConnection("Data Source=.;Initial
Catalog=facturacion;Integrated Security=True");
};
resultado = valores;
}
con.Close();
return resultado;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class facturacombo
{
SqlConnection con = new SqlConnection("Data Source=.;Initial
Catalog=facturacion;Integrated Security=True");
};
resultado = valores;
}
con.Close();
return resultado;
};
resultado = valores;
}
con.Close();
return resultado;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/ The main entry point for the application.
/ </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}