Академический Документы
Профессиональный Документы
Культура Документы
CONTRASEÑA: Admin
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;
{
get {return this.contrasena;}
set {this.contrasena = value;}
}
else
{
mensajes = "Datos incorrectos";
}
thi
re ts
u.
rcnnr
ne.s
Cull
otsa
ed(o
);
}
}
}
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;
{
}
p
{rivate void inventarioToolStripMenuItem_Click(
object sender, EventArgs e)
Form5 c = new Form5();
c.Show();
}
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();
}
}
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();
4
fila.Cells[5].Value = f
Ca
ocdt
Pu
rroa
..TT
ee
xxtt
;;
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);
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
}
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));
Convert.ToInt32(Row.a
Cger
lelg
sa rC
[" Po
rlou
.mPn
a8r"
a]m.
eVtaelru
se.)
A)d;
dWithValue("@facCantidad",
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;
('" + comboBcomxd2..CToemxmtan+dT
"e
%x't
)"=
; "select * from productosT where proDescripcion like
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;
g
set {r
te
htiu
s.rc
not
nhti
rsa.
sceo
nnatr=av
sael
nuae
;;}}
r su
men sl
at
ja
edso
= =
"Bt
ir
eu
nev;
enido datos correctos";
}
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;
a
cod.
nF
ei
xlil
o(
nd
.sC,
lo"
stea
(b)l
;a");
return ds.Tables["tabla"];
ds = new DataSet();
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);
int filasafectadas = cmd.ExecuteNonQuery();
conexion.Close();
if (filasafectadas > 0) return true;
else return false;
}
}
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;
p
{ublic DataTable mostrardatos()
conexion.Open();
SqlCommand cmd = new SqlCommand("select * from facturas", conexion);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ds = new DataSet();
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);
int filasafectadas = cmd.ExecuteNonQuery();
conexion.Close();
if (filasafectadas > 0) return true;
else return false;
}
}
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 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)
{
}
}
{
SqlDataReader dr;
cmd = new SqlCommand("select proDescripcion from productosT"
, cnn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
cb.Items.Add(dr["proDescripcion"].ToString());
}
}
catch (Exception ex)
{
}
}
p
{ublic void Users(ComboBox cb)
try
{
SqlDataReader dr;
cmd = new SqlCommand("select venUsuario from vendedores"
, cnn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
cb.Items.Add(dr["venUsuario"].ToString());
}
}
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)";
proDescripciS
oqnl=C'o
"mm
+an
pdroc
Dmed
sc=
rinpecwioSnql+C"
o'm"
m,ancdo
(n")
s;
elect * from productosT where
SqlDataReader dr = cmd.ExecuteReader();
string[] resultado = null;
while (dr.Read())
{
string[] valores =
{
dr[0].ToString(),
dr[2].ToString(),
dr[3].ToString(),
};
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)";
cob.Items.Clear();
con.Open();
SqlCommand cmd = new SqlCommand("select * from clientes", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
cob.Items.Add(dr[1].ToString());
}
con.Close();
cob.Items.Insert(0, "---Seleccione a el Cliente---");
cob.SelectedIndex = 0;
c
So
qnl.
CO
opme
mna(
n)
d;cmd = new SqlCommand("select * from clientes where
cliNombre='" + proDescripcion + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
string[] resultado = null;
while (dr.Read())
{
string[] valores =
{
dr[0].ToString(),
dr[2].ToString(),
dr[3].ToString(),
dr[4].ToString(),
};
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());
}
}
}