private void buscar_db() { sqlCommands sql = new sqlCommands(); helperFunctions help = new helperFunctions(); //Orden de las operaciones al momento de buscar la base de datos. El orden es el siguiente: ID, codSap, catalogo, descripcion if (!(string.IsNullOrWhiteSpace(this.txt_ID.Text))) { this.dg_Buscado.DataSource = null; this.dg_Buscado.Rows.Clear(); clsMaterial material = new clsMaterial(); if (!help.mensajeAdvInt(this.txt_ID.Text, "el ID del material. Solo se aceptan numeros enteros.").boolean) { return; } ; long id = Int64.Parse(this.txt_ID.Text); material = sql.buscarID(id); this.dg_Buscado.Rows.Add("1", id, material.catalogo, material.codsap, material.descripcion, material.marca, material.familia); this.resizeGrid(); dg_Buscado.Focus(); } else if (!(string.IsNullOrWhiteSpace(this.txt_SAP.Text))) { this.dg_Buscado.DataSource = null; this.dg_Buscado.Rows.Clear(); clsMaterial material = new clsMaterial(); if (!help.mensajeAdvInt(this.txt_SAP.Text, "el codigo SAP del material. Solo se aceptan numeros enteros.").boolean) { return; } ; long codsap = Int64.Parse(this.txt_SAP.Text); material = sql.buscarPorCodigoSAP(codsap); this.dg_Buscado.Rows.Add("1", material.id, material.catalogo, material.codsap, material.descripcion, material.marca, material.familia); this.resizeGrid(); dg_Buscado.Focus(); } else if (!(string.IsNullOrWhiteSpace(this.txt_Catalogo.Text))) { this.dg_Buscado.DataSource = null; this.dg_Buscado.Rows.Clear(); string catalogo = this.txt_Catalogo.Text; sql.buscarDB(this.txt_Catalogo.Text, this.dg_Buscado); this.resizeGrid(); dg_Buscado.Focus(); } else { List <long> marcas = this.listSelectedMarcas(); List <long> familias = this.listSelectedFamilias(); sql.buscarDBFiltrado(this.txt_Descripcion.Text, familias, marcas, this.dg_Buscado); this.resizeGrid(); dg_Buscado.Focus(); } }
private void Dg_Buscado_MouseDoubleClick(object sender, MouseEventArgs e) { helperFunctions help = new helperFunctions(); if (!help.isDataGridEmpty(this.dg_Buscado)) { clsMaterial material = new clsMaterial(); material.id = int.Parse(dg_Buscado.SelectedCells[1].Value.ToString()); frmVerMaterial frmVer = new frmVerMaterial(material); frmVer.ShowDialog(); } }
private void Dg_Resumen_MouseDoubleClick(object sender, MouseEventArgs e) { //Determina si el DataGridView esta vacio. Si esta vacio no corre las funciones. helperFunctions help = new helperFunctions(); if (!help.isDataGridEmpty(this.dg_Resumen)) { clsMaterial material = new clsMaterial(); material.id = int.Parse(this.dg_Resumen.SelectedCells[0].Value.ToString()); frmVerMaterial frmVer = new frmVerMaterial(material); frmVer.ShowDialog(); } }
private void FrmVerMaterial_Load(object sender, EventArgs e) { sqlCommands sql = new sqlCommands(); clsMaterial = sql.buscarID(clsMaterial.id); this.txt_Id.Text = clsMaterial.id.ToString(); this.txt_Familia.Text = clsMaterial.familia; this.txt_Marca.Text = clsMaterial.marca; this.txt_Catalogo.Text = clsMaterial.catalogo; this.txt_Comentarios.Text = clsMaterial.comentario; this.txt_Descripcion.Text = clsMaterial.descripcion; this.txt_SAP.Text = clsMaterial.codsap.ToString(); this.txt_specCatalogo.Text = clsMaterial.speccatalogo; this.txt_specEnercom.Text = clsMaterial.specenercom; this.txt_specTexto.Text = clsMaterial.spectexto; this.txt_specUl.Text = clsMaterial.specul; this.txt_specVarias.Text = clsMaterial.specvarias; }
/// <summary> /// Busca la base de datos por codigo SAP y guarda los datos en una clase que contiene todos los datos /// </summary> /// <param name="codsap">El codigo sap que esta siendo buscado</param> /// <returns></returns> public clsMaterial buscarPorCodigoSAP(long codsap) { clsMaterial material = new clsMaterial(); material.codsap = codsap; using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = globalVars.connectionString; SqlCommand cmd = new SqlCommand("stp_getBySAP", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramIn = new SqlParameter("@sap", codsap); cmd.Parameters.Add(paramIn); conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { material.id = safeBigInt(reader, "IDmaterial"); material.catalogo = safeString(reader, "catalogo"); material.familia = safeString(reader, "nombreFamilia"); material.descripcion = safeString(reader, "descripcion"); material.marca = safeString(reader, "nombreMarca"); material.comentario = safeString(reader, "comentarios"); material.specenercom = safeString(reader, "specenercom"); material.speccatalogo = safeString(reader, "speccatalogo"); material.specul = safeString(reader, "specul"); material.spectexto = safeString(reader, "spectexto"); material.specvarias = safeString(reader, "specvarias"); } } return(material); } } }
public frmVerMaterial(clsMaterial _clsMaterial) { InitializeComponent(); clsMaterial = _clsMaterial; }