Beruflich Dokumente
Kultur Dokumente
NET
Presentado a:
2018
USUARIO: Admin
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;
this.cnn.Open();
SqlDataReader reg = null;
reg = this.comandosql.ExecuteReader();
if (reg.Read())
resultado = true;
else
t
rh
eits
u.rc
nnr
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 Form2()
InitializeComponent();
int a;
int b;
int c;
a.Show();
b.Show();
p
{rivate void inventarioToolStripMenuItem_Click(
object sender, EventArgs e)
Form5 c = new Form5();
c.Show();
}
c.Show();
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;
using System.Data;
namespace WindowsFormsApplication1
{
combobox combo = new combobox();
agregarproducto c = new agregarproducto();
public Form3()
InitializeComponent();
combo.Seleccionar(cob:comboBox2);
combo cb = new combo();
cb.llenaritems(comboBox1);
MessageBox.Show("datos insertados");
this.Refresh();
proCodigo.Clear();
proDescripcion.Clear();
proValor.Clear();
proCantidad.Clear();
this.Hide();
}
else
MessageBox.Show("datos no insertados");
cb.llenaritems(ComboProductoEliminar);
if (comboBox2.SelectedIndex > 0)
textBox7.Text = valores[0];
textBox6.Text = valores[1];
textBox5.Text = valores[2];
Catalog=facturacion;Integrated Security=True)
";
conexen.Open();
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
if (ComboProductoEliminar.SelectedIndex > 0)
codProductoSeleccionado.Text = valores[0];
MessageBox.Show("Datos Actualizado");
this.Hide();
if (sql.eliminar(codProductoSeleccionado.Text))
MessageBox.Show("Datos Eliminados");
this.Hide();
}
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
InitializeComponent();
combo.Seleccionar(cob: listaCli);
combo.SeleccionarProducto(cob: listaPro);
combo cb = new combo();
cb.Users(username);
Catalog=facturacion;Integrated Security=True)
";
if (listaPro.SelectedIndex > 0)
Valor.Text = valores[1];
val = Convert.ToDouble(Valor.Text);
cant = Convert.ToDouble(cantidad.Text);
suma.Text = resultado.ToString();
fila.CreateCells(dgv);
fila.Cells[0].Value = fecha.Text;
fila.Cells[1].Value = documento.Text;
fila.Cells[2].Value = suma.Text;
fila.Cells[3].Value = username.Text;
fila.Cells[4
5].Value =
f
Ca
octu
dP rr
oa..
TTee
xx
tt
;;
fila.Cells[6].Value = cantidad.Text;
dgv.Rows.Add(fila);
fecha.Text = "";
cantidad.Text = "";
listaPro.Text = "";
CodPro.Text = "";
listaPro.ResetText();
decimal total = 0;
total += Convert.ToDecimal(Row.Cells["colum4"].Value);
valortotal.Text = Convert.ToString(total);
dgv.AllowUserToAddRows = false;
if (listaCli.SelectedIndex > 0)
documento.Text = valores[0];
direccion.Text = valores[1];
telefono.Text = valores[2];
correo.Text = valores[3];
}
factura.Text + "'");
if(string.IsNullOrWhiteSpace(factura.Text))
MessageBox.Show("error");
else
if (consultar == factura.Text)
else
try
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
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.aCg
erle
lgsa
["rC
Porl
ou.m
Pna8
r"a]m.eVtaelruse.)
A)d;dWithValue("@facCantidad",
agregarPro.ExecuteNonQuery();
MessageBox.Show("Datos agregados");
MessageBox.Show("Error al guardar"+ex);
finally
conex.Close();
dgv.Rows.Remove(dgv.CurrentRow);
{
}
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
{
combobox combo = new combobox();
agregarproducto sql = new agregarproducto();
public Form5()
InitializeComponent();
combo cb = new combo();
cb.llenaritems(comboBox2);
Catalog=facturacion;Integrated Security=True)
";
conex.Open();
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 Clientes()
InitializeComponent();
{
MessageBox.Show("datos insertados");
this.Refresh();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
this.Hide();
else
MessageBox.Show("datos no insertados");
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
class conexion
public conexion()
integrated security=true");
this.cnn = new SqlConnection(this.cadenaconexion);
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
teht
iu rc
s. not
nhti
rsa.
sceo
nnatr=av
sael
nuae
;;}}
}
reg = this.comandosql.ExecuteReader();
if (reg.Read())
r
mes
nusl
atja
ed
s =
"Bt
ireu
nev;
enido datos correctos";
else
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
Catalog=facturacion;Integrated Security=True)
";
conexion.Open();
ds = new DataSet();
a
cdo.
nFei
xlil
o(nd
.sC,
lo"
stea
(b)l
;a");
return ds.Tables["tabla"];
conexion.Open();
conexion.Close();
conexion.Open();
conexion.Close();
conexion.Open();
ds = new DataSet();
ad.Fill(ds, "tabla");
conexion.Close();
return ds.Tables["tabla"];
conexion.Open();
conexion.Close();
}
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
Catalog=facturacion;Integrated Security=True)
";
conexion.Open();
conexion.Close();
AGREGAR FACTURA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data;
class agregarfactura
Catalog=facturacion;Integrated Security=True)
";
p
{ublic DataTable mostrardatos()
conexion.Open();
ds = new DataSet();
ad.Fill(ds, "tabla");
conexion.Close();
return ds.Tables["tabla"];
conexion.Open();
SqlCommand cmd = new SqlCommand(string.Format("insert into facturas
values ({0}, '{1}', '{2}', '{3}','{4}')", new string[] { facNumero, facFecha,
facCliente, facValortotal, facVendedor }), conexion);
conexion.Close();
FacCantidad)
conexion.Open();
conexion.Close();
DEMAS CODIGO
UTILIZADO
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
Catalog=facturacion;Integrated Security=True)
";
cnn.Open();
try
{
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
cb.Items.Add(dr["proDescripcion"].ToString());
}
p
{ublic void Users(ComboBox cb)
try
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
cb.Items.Add(dr["venUsuario"].ToString());
} }
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
Catalog=facturacion;Integrated Security=True)
";
cob.Items.Clear();
con.Open();
SqlCommand cmd = new SqlCommand("select * from productosT", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
cob.Items.Add(dr[1].ToString());
con.Close();
cob.SelectedIndex = 0;
con.Open();
proDescripciSoqnl
=C'o"mm
+an
pdroc
Dmed
sc=
rinpecwioSnql+C"
o'm"
m,ancdo
("ns
);elect * from productosT where
SqlDataReader dr = cmd.ExecuteReader();
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
Catalog=facturacion;Integrated Security=True)
";
cob.Items.Clear();
con.Open();
while (dr.Read())
cob.Items.Add(dr[1].ToString());
con.Close();
cob.SelectedIndex = 0;
c
So
qnl.
COop
memn
a(n)
d;cmd = new SqlCommand("select * from clientes where
cliNombre='" + proDescripcion + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string[] valores =
dr[0].ToString(),
dr[2].ToString(),
dr[3].ToString(),
dr[4].ToString(),
};
resultado = valores;
}
con.Close();
return resultado;
cob.Items.Clear();
con.Open();
while (dr.Read())
cob.Items.Add(dr[1].ToString());
con.Close();
cob.Items.Insert(0, "---Seleccione un producto---");
cob.SelectedIndex = 0;
con.Open();
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.Windows.Forms;
namespace WindowsFormsApplication1
{ /// <summary>
/// </summary>
[STAThread]
static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());