Академический Документы
Профессиональный Документы
Культура Документы
NET
Bogotá D.C
2017
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;
}
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();
}
}
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[4].Value =
fila.Cells[5].Value factura.Text;
= CodPro.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);
}
}
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
('" + comboBox2.Text = "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;
get {this.contrasena
set {return this.contrasena;}
= value;}
resultado =
mensajes= true;
"Bienvenido 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;
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;
public
{ 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)
{
}
}
}
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");
SqlCommand
proDescripcion='" cmd = new SqlCommand("select
+ proDescripcion + "'", con); * 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");
con.Open();
SqlCommand 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());
}
}
}