private void btnFiltroProd_Click(object sender, EventArgs e) { using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { if (cbProd.Text != "") { SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("select v.Codigo_Venta as 'Codigo Venta'," + "c.NIT_CI as 'Cliente'," + "p.Paterno + ' ' + p.Nombre as 'Persona'," + "pr.Nombre_Producto as 'Producto'," + "v.Codigo_Detalle_Venta as 'Detalle Venta'," + "v.Cantidad as 'Cantidad'," + "v.Fecha_Venta as 'Fecha'," + "v.Tipo_Venta as 'Tipo' " + "from Venta v " + "inner join Cliente c " + "on v.Codigo_Cliente = c.Codigo_Cliente " + "inner join Persona p " + "on v.Id_Personas = p.Id_Personas " + "inner join Producto pr " + "on v.Codigo_Producto = pr.Codigo_Producto " + "where pr.Nombre_Producto = '" + cbProd.Text + "'", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosV.DataSource = dt; cn.Close(); } else { MessageBox.Show("Debe seleccionar un filtro correspondiente"); } } }
private void DGVdatosP_Click(object sender, EventArgs e) { txtCategoria.Visible = false; CBprov.Visible = false; txtCat2.Visible = true; txtProv.Visible = true; ClaseCompartida.tipoProd = 1; Producto prod2 = new Producto(); string codigo; codigo = DGVdatosP.Rows[DGVdatosP.CurrentRow.Index].Cells[0].Value.ToString(); txtCodigo.Text = codigo; using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { prod2 = DB.Producto.Find(Convert.ToInt32(codigo)); txtNombre.Text = prod2.Nombre_Producto; txtFecha.Text = Convert.ToString(prod2.Fecha_Vencimiento); txtStock.Text = Convert.ToString(prod2.Stock); txtPrecio.Text = Convert.ToString(prod2.Precio_Unitario); txtCat2.Text = Convert.ToString(prod2.Codigo_Categoria); txtProv.Text = Convert.ToString(prod2.Codigo_Proveedor); txtDesc.Text = prod2.Descripcion; //Producto produ = new Producto(); //DataTable tb = new DataTable(); //produ = DB.Producto.Find(txtCodigo.Text); //byte[] img = (byte[])tb.Rows[0]["foto"]; System.IO.MemoryStream ms = new System.IO.MemoryStream(prod2.Imagen); imgPro.Image = Image.FromStream(ms); } Deshabilitar2(); }
private void btnIngresar_Click(object sender, EventArgs e) { Producto prod = new Producto(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { for (int i = 0; i < ClaseCompartida.carrito; i++) { prod = DB.Producto.Find(ClaseCompartida.productos[i, 0]); Venta emp1 = new Venta(); emp1.Codigo_Venta = Convert.ToInt32(txtCodigo.Text) + i; emp1.Codigo_Cliente = Convert.ToInt32(txtCodigoC.Text); emp1.Id_Personas = Convert.ToInt32(txtID.Text); emp1.Codigo_Producto = prod.Codigo_Producto; emp1.Codigo_Detalle_Venta = Convert.ToInt32(txtCodigoD.Text); emp1.Cantidad = ClaseCompartida.productos[i, 1]; emp1.Fecha_Venta = Convert.ToDateTime(txtFecha.Text); emp1.Tipo_Venta = txtTipo.Text; DB.Venta.Add(emp1); DB.SaveChanges(); } } Pantalla_Menu menu = new Pantalla_Menu(); menu.Show(); this.Close(); }
public void HabilitaBTN() { btnInsertar.Visible = false; btnEditar.Visible = false; btnEliminar.Visible = false; btnGuardar.Visible = true; txtCodigo.Enabled = false; txtNombre.Enabled = true; txtPaterno.Enabled = true; txtCi.Enabled = true; txtDireccion.Enabled = true; txtTelefono.Enabled = true; if (tipoA == 0) { using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var max = (from g in bd.Cliente select g.Codigo_Cliente).Max(); int maxi = Convert.ToInt32(max); txtCodigo.Text = Convert.ToString(maxi + 1); } } else { using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var max = (from g in bd.Cliente select g.Codigo_Cliente).Max(); int maxi = Convert.ToInt32(max); //txtCodigo.Text = Convert.ToString(maxi + 1); } } }
private void btnEliminar_Click(object sender, EventArgs e) { DialogResult Respuesta; if (txtCodigo.Text != "") { Respuesta = MessageBox.Show("Esta seguro de eliminar el Dato", "Eliminar", MessageBoxButtons.YesNo); if (Respuesta == DialogResult.Yes) { using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { Persona EliminarPersona = DB.Persona.Find(Convert.ToInt32(txtCodigo.Text)); DB.Persona.Remove(EliminarPersona); DB.SaveChanges(); MessageBox.Show("Dato eliminado"); Blanco(); } CargaDatos(); } } else { MessageBox.Show("Debe Seleccionar item"); } }
private void Pantalla_Productos_Load(object sender, EventArgs e) { txtAyuda.Text = ClaseCompartida.nombreProducto; txtAyuda2.Text = ClaseCompartida.paterno; txtAyuda3.Text = ClaseCompartida.cantidadVenta; DGVayuda.Visible = false; DGVayuda2.Visible = false; txtAyuda.Visible = false; txtAyuda2.Visible = false; txtAyuda3.Visible = false; Producto pp = new Producto(); Cliente cc = new Cliente(); Detalle_Venta dv = new Detalle_Venta(); using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { /*var lstcod = from d in bd.Producto * where d.Nombre_Producto.Contains(txtAyuda.Text) * select d; * DGVayuda.DataSource = lstcod.ToList(); * txtCodigo.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[0].Value.ToString(); * txtNombreP.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[1].Value.ToString(); * txtFecha.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[2].Value.ToString(); * txtStock.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[3].Value.ToString(); * txtPrecio.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[4].Value.ToString(); * txtCategoria.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[5].Value.ToString(); * txtProveedor.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[6].Value.ToString(); * txtDesc.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[7].Value.ToString(); * txt.Text = txtAyuda3.Text; */ var lstcod2 = from f in bd.Cliente where f.Paterno.Contains(txtAyuda2.Text) select f; DGVayuda2.DataSource = lstcod2.ToList(); txtCodigoC.Text = DGVayuda2.Rows[DGVayuda2.CurrentRow.Index].Cells[0].Value.ToString(); txtNombre.Text = DGVayuda2.Rows[DGVayuda2.CurrentRow.Index].Cells[1].Value.ToString(); txtPaterno.Text = DGVayuda2.Rows[DGVayuda2.CurrentRow.Index].Cells[2].Value.ToString(); txtCi.Text = DGVayuda2.Rows[DGVayuda2.CurrentRow.Index].Cells[3].Value.ToString(); txtDireccion.Text = DGVayuda2.Rows[DGVayuda2.CurrentRow.Index].Cells[4].Value.ToString(); txtTelefono.Text = DGVayuda2.Rows[DGVayuda2.CurrentRow.Index].Cells[5].Value.ToString(); var max = (from g in bd.Detalle_Venta select g.Codigo_Detalle).Max(); int maxi = Convert.ToInt32(max); txtAyuda4.Text = Convert.ToString(maxi + 1); int total = 0, total2 = 0; for (int i = 0; i < ClaseCompartida.carrito; i++) { pp = bd.Producto.Find(ClaseCompartida.productos[i, 0]); total2 = (ClaseCompartida.productos[i, 1]) * Convert.ToInt32(pp.Precio_Unitario); total = total + total2; } txtAyuda5.Text = Convert.ToString(total); CargaDatos(); } }
private void txtCategoria_TextChanged(object sender, EventArgs e) { Categoria pp = new Categoria(); using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var lstcod = from d in bd.Categoria where d.Nombre_Categoria.Contains(txtCategoria.Text) select d; DGVayuda.DataSource = lstcod.ToList(); a1 = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[0].Value.ToString(); } }
public void CargaDatos() { Producto prod = new Producto(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { prod = DB.Producto.Find(ClaseCompartida.productos[cont, 0]); txtNombreP.Text = prod.Nombre_Producto; txtCodigo.Text = Convert.ToString(prod.Codigo_Producto); txtPrecio.Text = Convert.ToString(prod.Precio_Unitario); txt.Text = Convert.ToString(ClaseCompartida.productos[cont, 1]); } }
private void btnIngresar_Click(object sender, EventArgs e) { if (txtUsuario.Text != "" && txtContra.Text != "" && txtContra2.Text != "") { if (txtContra.Text == txtContra2.Text) { if (ClaseCompartida.formaUser == 0) { Usuarios user = new Usuarios(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { user.Nombre_Usuario = txtUsuario.Text; user.Contrasenia = txtContra.Text; user.Codigo_Tipo_Usuario = Convert.ToInt32(txtTipoUser.Text); DB.Entry(user).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); MessageBox.Show("Contraseña actualizada!!!"); Pantalla_Login menu = new Pantalla_Login(); menu.Show(); this.Close(); } } else { Usuarios user = new Usuarios(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { user.Nombre_Usuario = txtUsuario.Text; user.Contrasenia = txtContra.Text; user.Codigo_Tipo_Usuario = Convert.ToInt32(txtTipoUser.Text); DB.Usuarios.Add(user); DB.SaveChanges(); MessageBox.Show("Usuario Creado!!!"); Pantalla_Menu menu = new Pantalla_Menu(); menu.Show(); this.Close(); } } } else { MessageBox.Show("Ambas contraseñas no coinciden"); } } else { MessageBox.Show("Debe llenar todos los campos existentes"); } }
private void DGVdatosC_Click(object sender, EventArgs e) { if (ClaseCompartida.tipoCliente == 0) { Proveedor cli2 = new Proveedor(); string codigo; codigo = DGVdatosA.Rows[DGVdatosA.CurrentRow.Index].Cells[0].Value.ToString(); txtCodigo.Text = codigo; using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { cli2 = DB.Proveedor.Find(Convert.ToInt32(codigo)); txtNombre.Text = cli2.Nombre_Proveedor; txtDireccion.Text = cli2.Direccion; txtTelefono.Text = Convert.ToString(cli2.Telefono); } } }
public void CargaDatos() { using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("select * from Cliente ", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosC.DataSource = dt; cn.Close(); var lst = from d in BD.Cliente select d.Paterno; CBclie.DataSource = lst.ToList(); } }
private void CBprod_TextChanged(object sender, EventArgs e) { Producto pp = new Producto(); using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var lstcod = from d in bd.Producto where d.Nombre_Producto.Contains(CBprod.Text) select d; DGVayuda.DataSource = lstcod.ToList(); txtCodigo.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[0].Value.ToString(); txtFecha.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[2].Value.ToString(); txtStock.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[3].Value.ToString(); txtPrecio.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[4].Value.ToString(); txtCategoria.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[5].Value.ToString(); txtProveedor.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[6].Value.ToString(); txtDesc.Text = DGVayuda.Rows[DGVayuda.CurrentRow.Index].Cells[7].Value.ToString(); } }
private void DGVdatosC_Click(object sender, EventArgs e) { if (ClaseCompartida.tipoCliente == 0) { Cliente cli2 = new Cliente(); string codigo; codigo = DGVdatosC.Rows[DGVdatosC.CurrentRow.Index].Cells[0].Value.ToString(); txtCodigo.Text = codigo; using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { cli2 = DB.Cliente.Find(Convert.ToInt32(codigo)); txtNombre.Text = cli2.Nombre; CBclie.Text = cli2.Paterno; txtCi.Text = Convert.ToString(cli2.NIT_CI); txtDireccion.Text = cli2.Direccion; txtTelefono.Text = Convert.ToString(cli2.Telefono); } Deshabilitar2(); } }
private void Pantalla_Login_Load(object sender, EventArgs e) { Producto prod = new Producto(); using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var max = (from g in bd.Venta select g.Codigo_Venta).Max(); int maxi = Convert.ToInt32(max); txtCodigo.Text = Convert.ToString(maxi + 1); txtCodigoC.Text = ClaseCompartida.paterno; txtID.Text = Convert.ToString(ClaseCompartida.ID); txtProd.Text = Convert.ToString(ClaseCompartida.nombreProducto); txtCodigoD.Text = Convert.ToString(ClaseCompartida.codigoDetalle); txtCantidad.Text = Convert.ToString(ClaseCompartida.cantidadVenta); txtFecha.Text = Convert.ToString(DateTime.Now); txtTipo.Text = "Local"; } }
public void CargaDatos() { SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("select * from Persona " + "where Codigo_Tipo_Usuario = 3 ", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosA.DataSource = dt; cn.Close(); if (ClaseCompartida.tipoCliente == 1) { using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { var lst2 = from d in BD.Cliente select d; //DGVdatosA.DataSource = lst2.ToList(); var max = (from d in BD.Persona select d.Id_Personas).Max(); int maxi = Convert.ToInt32(max); txtCodigo.Text = Convert.ToString(maxi + 1); } HabilitaBTN(); } else { using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { var lst2 = from d in BD.Cliente select d; //DGVdatosA.DataSource = lst2.ToList(); var max = (from d in BD.Persona select d.Id_Personas).Max(); int maxi = Convert.ToInt32(max); txtCodigo.Text = Convert.ToString(maxi + 1); } DeshabilitaBTN(); } }
private void Pantalla_Login_Load(object sender, EventArgs e) { if (ClaseCompartida.formaUser == 0) { txtUsuario.Enabled = false; using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { txtUsuario.Text = ClaseCompartida.nomUser; txtTipoUser.Text = Convert.ToString(ClaseCompartida.tipoUser); } } else { txtUsuario.Enabled = true; using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { txtUsuario.Text = ""; txtTipoUser.Text = Convert.ToString(ClaseCompartida.tipoUser); } } }
public void CargaDatos() { using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { var lst = from d in BD.Producto select d.Nombre_Producto; CBprod.DataSource = lst.ToList(); var lst2 = from d in BD.Producto select d; DGVdatosP.DataSource = lst2.ToList(); SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("select * from Producto ", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosP.DataSource = dt; cn.Close(); } //txtNventa.Text = cont.ToString(); }
public void Habilitar() { txtNombre.Enabled = true; txtFecha.Enabled = true; txtStock.Enabled = true; txtPrecio.Enabled = true; txtCategoria.Enabled = true; CBprov.Enabled = true; txtDesc.Enabled = true; btnExaminar.Enabled = true; btnGuardar.Visible = true; if (tipoA == 0) { txtCat2.Visible = false; txtProv.Visible = false; txtCategoria.Visible = true; CBprov.Visible = true; Producto pp = new Producto(); using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var max = (from g in bd.Producto select g.Codigo_Producto).Max(); int maxi = Convert.ToInt32(max); txtCodigo.Text = Convert.ToString(maxi + 1); } } else { Producto pp = new Producto(); using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { var max = (from g in bd.Producto select g.Codigo_Producto).Max(); int maxi = Convert.ToInt32(max); //txtCodigo.Text = Convert.ToString(maxi + 1); } } }
private void DGVdatosC_Click(object sender, EventArgs e) { if (ClaseCompartida.tipoCliente == 0) { Persona cli2 = new Persona(); string codigo; codigo = DGVdatosA.Rows[DGVdatosA.CurrentRow.Index].Cells[0].Value.ToString(); txtCodigo.Text = codigo; using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { cli2 = DB.Persona.Find(Convert.ToInt32(codigo)); txtTipo.Text = Convert.ToString(cli2.Codigo_Tipo_Usuario); txtNombre.Text = cli2.Nombre; txtPaterno.Text = cli2.Paterno; txtMaterno.Text = cli2.Materno; txtDireccion.Text = cli2.Direccion; dtpFecha.Text = Convert.ToString(cli2.Fecha_Nacimiento); txtCorreo.Text = cli2.Correo_Electronico; txtTelefono.Text = Convert.ToString(cli2.Telefono); } } }
private void btnIngresar_Click(object sender, EventArgs e) { if (txtUsuario.Text != "") { Usuarios user = new Usuarios(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { if (DB.Usuarios.Find(txtUsuario.Text) != null) { user = DB.Usuarios.Find(txtUsuario.Text); ClaseCompartida.tipoUser = Convert.ToInt32(user.Codigo_Tipo_Usuario); ClaseCompartida.nomUser = txtUsuario.Text; ClaseCompartida.formaUser = 0; contador = 0; Pantalla_Usuarios formProd = new Pantalla_Usuarios(); formProd.Show(); this.Close(); } else { MessageBox.Show("Usuario Inexistente"); if (contador < 2) { contador++; } else { Pantalla_Login formProd = new Pantalla_Login(); formProd.Show(); this.Close(); } } } } else { MessageBox.Show("Debe llenar todos los campos existentes"); } }
public void CargaDatos() { using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { var lst = from d in BD.Proveedor select d.Nombre_Proveedor; CBprov.DataSource = lst.ToList(); SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("select * from Producto ", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosP.DataSource = dt; cn.Close(); var lst3 = from g in BD.Categoria select g.Nombre_Categoria; txtCategoria.DataSource = lst3.ToList(); } ClaseCompartida.tipoProd = 0; }
private void btnFiltroFecha_Click(object sender, EventArgs e) { using (ProyectoFarmaciaEntities1 bd = new ProyectoFarmaciaEntities1()) { if (cbDia.Text != "" && cbMes.Text != "" && txtAnio.Text != "" && cbDia2.Text != "" && cbMes2.Text != "" && txtAnio2.Text != "") { SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("set dateformat dmy " + "select v.Codigo_Venta as 'Codigo Venta'," + "c.NIT_CI as 'Cliente'," + "p.Paterno + ' ' + p.Nombre as 'Persona'," + "pr.Nombre_Producto as 'Producto'," + "v.Codigo_Detalle_Venta as 'Detalle Venta'," + "v.Cantidad as 'Cantidad'," + "v.Fecha_Venta as 'Fecha'," + "v.Tipo_Venta as 'Tipo' " + "from Venta v " + "inner join Cliente c " + "on v.Codigo_Cliente = c.Codigo_Cliente " + "inner join Persona p " + "on v.Id_Personas = p.Id_Personas " + "inner join Producto pr " + "on v.Codigo_Producto = pr.Codigo_Producto " + "where v.Fecha_Venta Between CAST(Concat(" + cbDia.Text + ",'-'," + cbMes.Text + ",'-'," + txtAnio.Text + ") AS datetime) " + "and CAST(Concat(" + cbDia2.Text + ",'-'," + cbMes2.Text + ",'-'," + txtAnio2.Text + ") AS datetime) ", cn); //"where v.Fecha_Venta = '" + Convert.ToDateTime(dtpFecha.Text) + "'", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosV.DataSource = dt; cn.Close(); } else { MessageBox.Show("Debe llenar todos los campos necesarios"); } } }
private void btnProceder_Click(object sender, EventArgs e) { if (txtAyuda6.Text == "") { MessageBox.Show("Debe escribir una descripcion para el Detalle"); } else { Producto emp = new Producto(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { for (int i = 0; i < ClaseCompartida.carrito; i++) { emp = DB.Producto.Find(ClaseCompartida.productos[i, 0]); emp.Stock = emp.Stock - ClaseCompartida.productos[i, 1]; DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); } Detalle_Venta emp1 = new Detalle_Venta(); emp1.Codigo_Detalle = Convert.ToInt32(txtAyuda4.Text); emp1.Monto_Total = Convert.ToInt32(txtAyuda5.Text); emp1.Descripcion = txtAyuda6.Text; DB.Detalle_Venta.Add(emp1); DB.SaveChanges(); } ClaseCompartida.nombreProducto = txtCodigo.Text; ClaseCompartida.paterno = txtCodigoC.Text; ClaseCompartida.codigoDetalle = Convert.ToInt32(txtAyuda4.Text); MessageBox.Show("Venta realizada satisfactoriamente"); Pantalla_Recibo formMenu = new Pantalla_Recibo(); formMenu.Show(); this.Close(); } }
private void btnGuardar_Click(object sender, EventArgs e) { int m = 0; if (tipoC == 0) { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtDireccion.Text != "" && txtTelefono.Text != "") { Persona cli1 = new Persona(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { Proveedor emp = new Proveedor(); emp.Codigo_Proveedor = Convert.ToInt32(txtCodigo.Text); emp.Nombre_Proveedor = txtNombre.Text; emp.Direccion = txtDireccion.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Proveedor.Add(emp); DB.SaveChanges(); //DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; //DB.SaveChanges(); MessageBox.Show("Registro Realizado!!!"); //emp1.Show(); CargaDatos(); GBdatos.Enabled = false; DeshabilitaBTN(); Blanco(); } } else { MessageBox.Show("Faltan datos!!!"); } } else { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtDireccion.Text != "" && txtTelefono.Text != "") { Persona cli1 = new Persona(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { Proveedor emp = new Proveedor(); emp.Codigo_Proveedor = Convert.ToInt32(txtCodigo.Text); emp.Nombre_Proveedor = txtNombre.Text; emp.Direccion = txtDireccion.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); MessageBox.Show("Registro Modificado!!!"); CargaDatos(); //emp1.Show(); GBdatos.Enabled = false; DeshabilitaBTN(); Blanco(); } } else { MessageBox.Show("Faltan datos!!!"); } } }
private void btnGuardar_Click(object sender, EventArgs e) { int m = 0; if (ClaseCompartida.tipoCliente == 0) { if (tipoA == 0) { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtPaterno.Text != "" && txtCi.Text != "" && txtDireccion.Text != "" && txtTelefono.Text != "") { Cliente cli1 = new Cliente(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { var max = (from d in DB.Cliente select d.Codigo_Cliente).Max(); int maxi = Convert.ToInt32(max); for (int n = 1; n <= maxi; n++) { cli1 = DB.Cliente.Find(n); if (txtCi.Text == Convert.ToString(cli1.NIT_CI)) { //MessageBox.Show("Existe ya uno"); m = 1; n = maxi + 1; } else { //MessageBox.Show("Es Nuevo"); m = 0; } } if (m == 0) { Cliente emp = new Cliente(); emp.Codigo_Cliente = Convert.ToInt32(txtCodigo.Text); emp.Nombre = txtNombre.Text; emp.Paterno = txtPaterno.Text; emp.NIT_CI = Convert.ToInt32(txtCi.Text); emp.Direccion = txtDireccion.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Cliente.Add(emp); DB.SaveChanges(); //DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; //DB.SaveChanges(); MessageBox.Show("Registro Realizado!!!"); Cliente emp1 = new Cliente(); CargaDatos(); DeshabilitaBTN(); GBdatos.Enabled = false; DialogResult Respuesta; Respuesta = MessageBox.Show("Desea crear un Usuario para la plataforma online?", "Usuario Online", MessageBoxButtons.YesNo); if (Respuesta == DialogResult.Yes) { ClaseCompartida.tipoUser = 5; ClaseCompartida.formaUser = 1; Pantalla_Usuarios formProd = new Pantalla_Usuarios(); formProd.Show(); this.Close(); } //emp1.Show(); } else { MessageBox.Show("El carnet introducido ya fue registrado"); } } } else { MessageBox.Show("Faltan datos!!!"); } } else { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtPaterno.Text != "" && txtCi.Text != "" && txtDireccion.Text != "" && txtTelefono.Text != "") { Cliente cli1 = new Cliente(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { /* * var max = (from d in DB.Cliente * select d.Codigo_Cliente).Max(); * int maxi = Convert.ToInt32(max); * * for (int n = 1; n <= maxi; n++) * { * cli1 = DB.Cliente.Find(n); * * if (txtCi.Text == Convert.ToString(cli1.NIT_CI)) * { * //MessageBox.Show("Existe ya uno"); * m = 1; * n = maxi + 1; * } * else * { * //MessageBox.Show("Es Nuevo"); * m = 0; * } * }*/ Cliente emp = new Cliente(); emp.Codigo_Cliente = Convert.ToInt32(txtCodigo.Text); emp.Nombre = txtNombre.Text; emp.Paterno = txtPaterno.Text; emp.NIT_CI = Convert.ToInt32(txtCi.Text); emp.Direccion = txtDireccion.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); MessageBox.Show("Registro Modificado!!!"); Cliente emp1 = new Cliente(); CargaDatos(); DeshabilitaBTN(); GBdatos.Enabled = false; //emp1.Show(); /* * if (m == 0) * { * * } * else * { * MessageBox.Show("El carnet introducido ya fue registrado"); * }*/ } } else { MessageBox.Show("Faltan datos!!!"); } } } else { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtPaterno.Text != "" && txtCi.Text != "" && txtDireccion.Text != "" && txtTelefono.Text != "") { Cliente cli1 = new Cliente(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { var max = (from d in DB.Cliente select d.Codigo_Cliente).Max(); int maxi = Convert.ToInt32(max); for (int n = 1; n <= maxi; n++) { cli1 = DB.Cliente.Find(n); if (txtCi.Text == Convert.ToString(cli1.NIT_CI)) { //MessageBox.Show("Existe ya uno"); m = 1; n = maxi + 1; } else { //MessageBox.Show("Es Nuevo"); m = 0; } } if (m == 0) { Cliente emp = new Cliente(); emp.Codigo_Cliente = Convert.ToInt32(txtCodigo.Text); emp.Nombre = txtNombre.Text; emp.Paterno = txtPaterno.Text; emp.NIT_CI = Convert.ToInt32(txtCi.Text); emp.Direccion = txtDireccion.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Cliente.Add(emp); DB.SaveChanges(); //DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; //DB.SaveChanges(); MessageBox.Show("Registro Realizado!!!"); //emp1.Show(); Pantalla_ClienteVenta form = new Pantalla_ClienteVenta(); form.Show(); this.Close(); } else { MessageBox.Show("El carnet introducido ya fue registrado"); } } } else { MessageBox.Show("Faltan datos!!!"); } } }
private void btnGuardar_Click(object sender, EventArgs e) { int m = 0; if (tipoC == 0) { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtPaterno.Text != "" && txtMaterno.Text != "" && txtDireccion.Text != "" && txtCorreo.Text != "" && txtTelefono.Text != "") { Persona cli1 = new Persona(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { Persona emp = new Persona(); emp.Id_Personas = Convert.ToInt32(txtCodigo.Text); emp.Codigo_Tipo_Usuario = Convert.ToInt32(txtTipo.Text); emp.Nombre = txtNombre.Text; emp.Paterno = txtPaterno.Text; emp.Materno = txtMaterno.Text; emp.Direccion = txtDireccion.Text; emp.Fecha_Nacimiento = Convert.ToDateTime(dtpFecha.Text); emp.Correo_Electronico = txtCorreo.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Persona.Add(emp); DB.SaveChanges(); //DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; //DB.SaveChanges(); MessageBox.Show("Registro Realizado!!!"); //emp1.Show(); CargaDatos(); GBdatos.Enabled = false; DeshabilitaBTN(); Blanco(); ClaseCompartida.tipoUser = 3; ClaseCompartida.formaUser = 1; Pantalla_Usuarios formProd = new Pantalla_Usuarios(); formProd.Show(); this.Close(); } } else { MessageBox.Show("Faltan datos!!!"); } } else { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtPaterno.Text != "" && txtMaterno.Text != "" && txtDireccion.Text != "" && txtCorreo.Text != "" && txtTelefono.Text != "") { Persona cli1 = new Persona(); using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { Persona emp = new Persona(); emp.Id_Personas = Convert.ToInt32(txtCodigo.Text); emp.Codigo_Tipo_Usuario = Convert.ToInt32(txtTipo.Text); emp.Nombre = txtNombre.Text; emp.Paterno = txtPaterno.Text; emp.Materno = txtMaterno.Text; emp.Direccion = txtDireccion.Text; emp.Fecha_Nacimiento = Convert.ToDateTime(dtpFecha.Text); emp.Correo_Electronico = txtCorreo.Text; emp.Telefono = Convert.ToInt32(txtTelefono.Text); DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); MessageBox.Show("Registro Modificado!!!"); CargaDatos(); //emp1.Show(); GBdatos.Enabled = false; DeshabilitaBTN(); Blanco(); } } else { MessageBox.Show("Faltan datos!!!"); } } }
private void btnIngresar_Click(object sender, EventArgs e) { try { Usuarios autentificar = new Usuarios(); using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { if (BD.Usuarios.Find(txtUser.Text) != null) { autentificar = BD.Usuarios.Find(txtUser.Text); if (txtPassword.Text == autentificar.Contrasenia) { if (autentificar.Codigo_Tipo_Usuario == 1) { ClaseCompartida.ID = Convert.ToInt32(autentificar.Codigo_Tipo_Usuario); MessageBox.Show("Bienvenido Administrador " + txtUser.Text); Pantalla_Menu formMenu = new Pantalla_Menu(); formMenu.Show(); this.Hide(); } else if (autentificar.Codigo_Tipo_Usuario == 2) { ClaseCompartida.ID = Convert.ToInt32(autentificar.Codigo_Tipo_Usuario); MessageBox.Show("Bienvenido PF " + txtUser.Text); Pantalla_Menu formMenu = new Pantalla_Menu(); formMenu.btnReporte.Enabled = false; this.Hide(); formMenu.Show(); } else if (autentificar.Codigo_Tipo_Usuario == 3) { ClaseCompartida.ID = Convert.ToInt32(autentificar.Codigo_Tipo_Usuario); MessageBox.Show("Bienvenido PNF " + txtUser.Text); Pantalla_Menu formMenu = new Pantalla_Menu(); formMenu.btnPersonal.Enabled = false; formMenu.btnProveedores.Enabled = false; formMenu.btnReporte.Enabled = false; this.Hide(); formMenu.Show(); } else if (autentificar.Codigo_Tipo_Usuario == 5) { MessageBox.Show("Este usuario no tiene permitido el Acceso"); } else { MessageBox.Show("Usuario Incorrecto"); } } else { MessageBox.Show("Contraseña Incorrecta"); } } else { MessageBox.Show("Usuario Inexistente"); } } } catch (Exception) { MessageBox.Show("Error vuelva a intentarlo"); } }
public void CargaDatos() { SqlConnection cn = new SqlConnection("Data Source=DESKTOP-9B5R179; Initial Catalog=ProyectoFarmacia;Integrated Security=true;"); SqlCommand cmd = new SqlCommand("select v.Codigo_Venta as 'Codigo Venta'," + "c.NIT_CI as 'Cliente'," + "p.Paterno + ' ' + p.Nombre as 'Persona'," + "pr.Nombre_Producto as 'Producto'," + "v.Codigo_Detalle_Venta as 'Detalle Venta'," + "v.Cantidad as 'Cantidad'," + "v.Fecha_Venta as 'Fecha'," + "v.Tipo_Venta as 'Tipo' " + "from Venta v " + "inner join Cliente c " + "on v.Codigo_Cliente = c.Codigo_Cliente " + "inner join Persona p " + "on v.Id_Personas = p.Id_Personas " + "inner join Producto pr " + "on v.Codigo_Producto = pr.Codigo_Producto ", cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DGVdatosV.DataSource = dt; cn.Close(); using (ProyectoFarmaciaEntities1 BD = new ProyectoFarmaciaEntities1()) { var lst = from d in BD.Producto select d.Nombre_Producto; cbProd.DataSource = lst.ToList(); var lst2 = from d in BD.Cliente select d.NIT_CI; cbClie.DataSource = lst2.ToList(); cbTipo.Items.Add("Local"); cbTipo.Items.Add("Domicilio"); } cbDia.Items.Add('1'); cbDia.Items.Add('2'); cbDia.Items.Add('3'); cbDia.Items.Add('4'); cbDia.Items.Add('5'); cbDia.Items.Add('6'); cbDia.Items.Add('7'); cbDia.Items.Add('8'); cbDia.Items.Add('9'); cbDia.Items.Add("10"); cbDia.Items.Add("11"); cbDia.Items.Add("12"); cbDia.Items.Add("13"); cbDia.Items.Add("14"); cbDia.Items.Add("15"); cbDia.Items.Add("16"); cbDia.Items.Add("17"); cbDia.Items.Add("18"); cbDia.Items.Add("19"); cbDia.Items.Add("20"); cbDia.Items.Add("21"); cbDia.Items.Add("22"); cbDia.Items.Add("23"); cbDia.Items.Add("24"); cbDia.Items.Add("25"); cbDia.Items.Add("26"); cbDia.Items.Add("27"); cbDia.Items.Add("28"); cbDia.Items.Add("29"); cbDia.Items.Add("30"); cbDia.Items.Add("31"); cbMes.Items.Add('1'); cbMes.Items.Add('2'); cbMes.Items.Add('3'); cbMes.Items.Add('4'); cbMes.Items.Add('5'); cbMes.Items.Add('6'); cbMes.Items.Add('7'); cbMes.Items.Add('8'); cbMes.Items.Add('9'); cbMes.Items.Add("10"); cbMes.Items.Add("11"); cbMes.Items.Add("12"); cbDia2.Items.Add('1'); cbDia2.Items.Add('2'); cbDia2.Items.Add('3'); cbDia2.Items.Add('4'); cbDia2.Items.Add('5'); cbDia2.Items.Add('6'); cbDia2.Items.Add('7'); cbDia2.Items.Add('8'); cbDia2.Items.Add('9'); cbDia2.Items.Add("10"); cbDia2.Items.Add("11"); cbDia2.Items.Add("12"); cbDia2.Items.Add("13"); cbDia2.Items.Add("14"); cbDia2.Items.Add("15"); cbDia2.Items.Add("16"); cbDia2.Items.Add("17"); cbDia2.Items.Add("18"); cbDia2.Items.Add("19"); cbDia2.Items.Add("20"); cbDia2.Items.Add("21"); cbDia2.Items.Add("22"); cbDia2.Items.Add("23"); cbDia2.Items.Add("24"); cbDia2.Items.Add("25"); cbDia2.Items.Add("26"); cbDia2.Items.Add("27"); cbDia2.Items.Add("28"); cbDia2.Items.Add("29"); cbDia2.Items.Add("30"); cbDia2.Items.Add("31"); cbMes2.Items.Add('1'); cbMes2.Items.Add('2'); cbMes2.Items.Add('3'); cbMes2.Items.Add('4'); cbMes2.Items.Add('5'); cbMes2.Items.Add('6'); cbMes2.Items.Add('7'); cbMes2.Items.Add('8'); cbMes2.Items.Add('9'); cbMes2.Items.Add("10"); cbMes2.Items.Add("11"); cbMes2.Items.Add("12"); }
private void btnGuardar_Click(object sender, EventArgs e) { txtCat2.Visible = true; txtProv.Visible = true; txtCategoria.Visible = false; CBprov.Visible = false; cont = 0; if (tipoA == 0) { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtFecha.Text != "" && txtStock.Text != "" && txtPrecio.Text != "" && txtDesc.Text != "" && CBprov.Text != "" && txtCategoria.Text != "") { using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); imgPro.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Producto emp = new Producto(); emp.Codigo_Producto = Convert.ToInt32(txtCodigo.Text); emp.Nombre_Producto = txtNombre.Text; emp.Fecha_Vencimiento = Convert.ToDateTime(txtFecha.Text); emp.Stock = Convert.ToInt32(txtStock.Text); emp.Precio_Unitario = Convert.ToInt32(txtPrecio.Text); emp.Codigo_Categoria = Convert.ToInt32(a1); emp.Codigo_Proveedor = Convert.ToInt32(a2); emp.Descripcion = txtDesc.Text; emp.Imagen = ms.GetBuffer(); DB.Producto.Add(emp); DB.SaveChanges(); } MessageBox.Show("Registro Realizado!!!"); CargaDatos(); Deshabilitar(); } else { MessageBox.Show("Faltan datos!!!"); } } else { if (txtCodigo.Text != "" && txtNombre.Text != "" && txtFecha.Text != "" && txtStock.Text != "" && txtPrecio.Text != "" && txtDesc.Text != "" && txtProv.Text != "" && txtCat2.Text != "") { using (ProyectoFarmaciaEntities1 DB = new ProyectoFarmaciaEntities1()) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); imgPro.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Producto emp = new Producto(); emp.Codigo_Producto = Convert.ToInt32(txtCodigo.Text); emp.Nombre_Producto = txtNombre.Text; emp.Fecha_Vencimiento = Convert.ToDateTime(txtFecha.Text); emp.Stock = Convert.ToInt32(txtStock.Text); emp.Precio_Unitario = Convert.ToInt32(txtPrecio.Text); emp.Codigo_Categoria = Convert.ToInt32(a1); emp.Codigo_Proveedor = Convert.ToInt32(a2); emp.Descripcion = txtDesc.Text; emp.Imagen = ms.GetBuffer(); DB.Entry(emp).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); } MessageBox.Show("Registro Actualizado!!!"); CargaDatos(); Deshabilitar(); } else { MessageBox.Show("Faltan datos!!!"); } } }