private void EditCliente_Load(object sender, EventArgs e) { string query = "SELECT * FROM Departamento; "; SqlCommand sqlQ = new SqlCommand(query, cs.GetCONN()); cs.OpenCnn(); SqlDataReader read2; try { read2 = sqlQ.ExecuteReader(); while (read2.Read()) { string Scad = read2.GetString(1); depaed.Items.Add(Scad); } cs.CerrarCnn(); } catch (Exception ex) { MessageBox.Show("Existe un Error con el Comando Ingresado. " + ex.Message + "\n Verificar el Comando.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cs.CerrarCnn(); } }
private void DeleteDevo() { try { if (compidDevo() == 1) { // Objetos de conexión y comando System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); // Estableciento propiedades cmd.Connection = fu.GetCONN(); cmd.CommandText = "DELETE FROM Devolucion_Ventas WHERE IDV_dev = '" + idSell + "' ;"; fu.OpenCnn(); cmd.ExecuteNonQuery(); fu.CerrarCnn(); } else { } } catch (Exception ex) { MessageBox.Show("ERROR. Al Eliminar Los Datos. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buscarboton_Click(object sender, EventArgs e) { if (textcod.Text != "" && textcod.Font.Italic == true) { if (textcod.Text == "") { MessageBox.Show("Ingrese el Codigo de Registro de la Categoría a Buscar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Codigo de Registro de la Categoría a Buscar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (textcod.Text == "") { MessageBox.Show("Ingrese el Codigo de Registro de la Categoría a Buscar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de buscar Categoria. string query = "SELECT * FROM Categorias WHERE codCat ='" + int.Parse(textcod.Text) + "' ; "; SqlCommand sqlQ = new SqlCommand(query, cs.GetCONN()); SqlDataReader read; if (comprobar() == 1) { textnom.Text = ""; textnom.ForeColor = SystemColors.WindowText; textnom.Font = new Font(textnom.Font, FontStyle.Regular); textDet.Text = ""; textDet.ForeColor = SystemColors.WindowText; textDet.Font = new Font(textDet.Font, FontStyle.Regular); textcod.Enabled = false; try { cs.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { textnom.Text = read.GetString(1); textDet.Text = read.GetString(2); } } catch (Exception ex) { MessageBox.Show("Existe Datos Nulos con el Codigo de la Categoría Ingresada. \n" + ex.Message + "\nCompruebe Que No Exista Datos Nulos o Vacios con la Categoría a Modificar.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cs.CerrarCnn(); } } } }
private void button1_Click(object sender, EventArgs e) { if (cic.Text != "" && cic.Font.Italic == true) { if (cic.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Cliente a Eliminar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Carnet de Identidad del Cliente a Eliminar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (cic.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Cliente a Eliminar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de eliminar Cliente. if (comprobar() == 1) { try { // Objetos de conexión y comando System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); // Estableciento propiedades cmd.Connection = cs.GetCONN(); cmd.CommandText = "DELETE FROM SolClientes WHERE ciSolC = '" + Convert.ToInt32(cic.Text) + "' ;"; cs.OpenCnn(); cmd.ExecuteNonQuery(); cs.CerrarCnn(); Messengers mr = new Messengers(); mr.textolb.Text = "Cliente Eliminado"; mr.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("ERROR. Al Eliminar Los Datos. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Error, No Existen Registros del Cliente.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void deparec_SelectedIndexChanged(object sender, EventArgs e) { Conexion r = new Conexion(); string query = "SELECT nombrePro, CodDep FROM Provincia, Departamento WHERE CodDep=codigoDep AND nombreDep= '" + deparec.Text + "' ; "; SqlCommand sqlQ = new SqlCommand(query, r.GetCONN()); r.OpenCnn(); SqlDataReader read; try { read = sqlQ.ExecuteReader(); prorec.Items.Clear(); while (read.Read()) { String cade = read.GetString(0); prorec.Items.Add(cade); id = read.GetString(1); } r.CerrarCnn(); } catch (Exception ex) { MessageBox.Show("Existe un Error con el Comando Ingresado. " + ex.ToString() + "\n Verificar el Comando.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); r.CerrarCnn(); } }
public void UpdateTC() { Conexion r = new Conexion(); string query = "SELECT SUM(CP_dev), SUM(ImpT_dev) FROM Devolucion_Ventas WHERE IDV_dev = '" + coddet + "' ; "; SqlCommand sqlQ = new SqlCommand(query, r.GetCONN()); r.OpenCnn(); SqlDataReader read; try { read = sqlQ.ExecuteReader(); while (read.Read()) { totalp = read.GetDouble(1).ToString(); cant = read.GetInt32(0).ToString(); txtTotalV.Text = "" + totalp + " Bs."; cantlabel.Text = "" + cant + " Und."; } r.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private int comprobarCodBar() { int cnt = 0; int num = 0; Conexion d = new Conexion(); Boolean conv = int.TryParse(citext.Text, out num); if (conv == true) { string buscar = "SELECT * FROM Proveedores WHERE codProve = '" + Convert.ToInt32(citext.Text) + "' ; "; d.OpenCnn(); SqlCommand find = new SqlCommand(buscar, d.GetCONN()); try { SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { cnt = cnt + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador 1. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { cnt = 0; } d.CerrarCnn(); return(cnt); }
public int CodigoAdmin() { int res = 0; Conexion d = new Conexion(); string query = "SELECT ciUser, nuUsuario FROM Usuario WHERE idUser='******'; "; SqlCommand sqlQ = new SqlCommand(query, d.GetCONN()); d.OpenCnn(); SqlDataReader read2; try { read2 = sqlQ.ExecuteReader(); while (read2.Read()) { if (codUser == 0) { res = read2.GetInt32(0); } else { res = codUser; } } } catch (Exception ex) { MessageBox.Show("Error Con el Codigo del Administrador.\n" + ex.Message + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } d.CerrarCnn(); return(res); }
public int GetIDCliente(String gus) { int res = 0; Conexion r = new Conexion(); string buscar = "SELECT * FROM Clientes WHERE nitCliente = '" + gus + "' ; "; try { r.OpenCnn(); SqlCommand find = new SqlCommand(buscar, r.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { res = fb.GetInt32(0); } } catch (Exception ex) { MessageBox.Show("ERROR. En el Obtenedor. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); r.CerrarCnn(); } r.CerrarCnn(); return(res); }
void Conectar() { if (cs.GetCONN().State == ConnectionState.Closed) { cs.OpenCnn(); } }
public int CompIdDet() { int res = 0; Conexion r = new Conexion(); string buscar = "SELECT * FROM Detalle_Venta WHERE cod_Venta= '" + idSell + "' ; "; try { r.OpenCnn(); SqlCommand find = new SqlCommand(buscar, r.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { res = res + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); r.CerrarCnn(); } r.CerrarCnn(); return(res); }
private void catebox_SelectedIndexChanged(object sender, EventArgs e) { string query = "SELECT nameSubC, codCat FROM SubCategorias, Categorias WHERE catCod=codCat AND DescCat= '" + catebox.Text + "' ; "; Conexion cd = new Conexion(); SqlCommand sqlQ = new SqlCommand(query, cd.GetCONN()); SqlDataReader read; try { cd.OpenCnn(); read = sqlQ.ExecuteReader(); subcatebox.Items.Clear(); while (read.Read()) { String cade = read.GetString(0); subcatebox.Items.Add(cade); codCate = read.GetInt32(1); } } catch (Exception ex) { MessageBox.Show("Existe un Error con el Comando Ingresado. " + ex.Message + "\n Verificar el Comando.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cd.CerrarCnn(); } }
private int comprobar() { int cnt = 0; Conexion r = new Conexion(); string buscar = "SELECT * FROM Clientes WHERE idCliente= '" + Convert.ToInt32(cirec.Text) + "' ; "; r.OpenCnn(); SqlCommand find = new SqlCommand(buscar, r.GetCONN()); try { SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { cnt = cnt + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } r.CerrarCnn(); return(cnt); }
public void UpdateTCA() { Conexion r = new Conexion(); string query = "SELECT SUM(num_Prod), SUM(pago_Cliente) FROM REV_Ventas ; "; SqlCommand sqlQ = new SqlCommand(query, r.GetCONN()); r.OpenCnn(); SqlDataReader read; try { read = sqlQ.ExecuteReader(); while (read.Read()) { totalp = read.GetDouble(1).ToString(); cant = read.GetInt32(0).ToString(); txtTotalV.Text = "" + totalp + " Bs."; cantlabel.Text = "" + cant + " Und."; } r.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SumarTotal() { Conexion r = new Conexion(); string query = "SELECT SUM(CantProd * PVUProd) FROM Productos ; "; SqlCommand sqlQ = new SqlCommand(query, r.GetCONN()); SqlDataReader read; try { r.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { total = read.GetDouble(0); totallabel.Text = "" + total + " Bs."; } r.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); r.CerrarCnn(); } }
public int GetIDUsuario(int idu) { int res = 0; Conexion r = new Conexion(); string buscar = "SELECT * FROM Usuario WHERE ciUser= '******' ; "; try { r.OpenCnn(); SqlCommand find = new SqlCommand(buscar, r.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { res = fb.GetInt32(15); } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); r.CerrarCnn(); } r.CerrarCnn(); return(res); }
private void iniboton_Click(object sender, EventArgs e) { c = new Conexion(); c.Comando("SELECT * FROM Usuario WHERE nuUsuario = '" + usertext.Text + "' AND contraUser = '******' ; "); SqlDataReader lee; c.OpenCnn(); lee = c.LeerDatos(); int cont = 0; String id = ""; while (lee.Read()) { cont = cont + 1; id = lee.GetInt32(15).ToString(); codci = lee.GetInt32(0); nom = lee.GetString(1); nameUser = lee.GetString(3); } if (cont == 1) { if (id == "1") { Principal e1 = new Principal(); e1.Cod = codci; e1.Nom = nom; e1.NameUser = nameUser; e1.Show(); this.Hide(); c.CerrarCnn(); } else { Principal_UserCajero e2 = new Principal_UserCajero(); e2.Cod = codci; e2.Nom = nom; e2.NameUser = nameUser; e2.Show(); this.Hide(); c.CerrarCnn(); } } else if (cont > 1) { MessageBox.Show("ERROR. El Usuario A sido Duplicado, Contacte Con el Administrador.", " ", MessageBoxButtons.OK, MessageBoxIcon.Error); passtext.Text = ""; //c.CerrarCnn(); } else { MessageBox.Show("ERROR. El Usuario No Existe, Intente Nuevamente.", " ", MessageBoxButtons.OK, MessageBoxIcon.Error); passtext.Text = ""; //c.CerrarCnn(); } }
private void searchprod_Click(object sender, EventArgs e) { Conexion s = new Conexion(); if (nitciclient.Text != "" && nitciclient.Font.Italic == true) { if (nitciclient.Text == "") { MessageBox.Show("Ingrese el NIT o C.I. del Cliente que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el NIT o C.I. del Cliente que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (nitciclient.Text == "") { MessageBox.Show("Ingrese el NIT o C.I. del Cliente que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de modificacion del cliente. string query = "SELECT * FROM Clientes WHERE nitCliente ='" + nitciclient.Text + "' ; "; SqlCommand sqlQ = new SqlCommand(query, s.GetCONN()); s.OpenCnn(); SqlDataReader read; if (comprobarCliente() == 1) { nameClient.Text = ""; nameClient.ForeColor = SystemColors.WindowText; nameClient.Font = new Font(nameClient.Font, FontStyle.Regular); try { read = sqlQ.ExecuteReader(); while (read.Read()) { nameClient.Text = read.GetString(1); } s.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("ERROR, El Cliente Solicitado no Existe.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void deleteboton_Click(object sender, EventArgs e) { if (textcod.Text != "" && textcod.Font.Italic == true) { if (textcod.Text == "") { MessageBox.Show("Ingrese el Codigo de Registro del Proveedor Como Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Codigo de Registro del Proveedor Como Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (textcod.Text == "") { MessageBox.Show("Ingrese el Codigo de Registro del Proveedor Como Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de Eliminar Proveedor. if (comprobar() == 1) { try { // Objetos de conexión y comando System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); // Estableciento propiedades cmd.Connection = cs.GetCONN(); cmd.CommandText = "DELETE FROM Proveedores WHERE codProve = '" + Convert.ToInt32(textcod.Text) + "' ;"; cs.OpenCnn(); cmd.ExecuteNonQuery(); cs.CerrarCnn(); Messengers mr = new Messengers(); mr.textolb.Text = "Proveedor Eliminado"; mr.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("ERROR. Al Eliminar Los Datos. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Error, No Existen Registros del Proveedor.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void MostrarProducto(Int64 valor) { string query = "SELECT * FROM Productos WHERE CodBarP ='" + valor + "' ; "; SqlCommand sqlQ = new SqlCommand(query, cs.GetCONN()); SqlDataReader read; precio.Text = ""; costolb.Text = ""; statelb.Text = ""; stock.Text = ""; stockmaxlb.Text = ""; stockminlb.Text = ""; nameprod.Text = ""; codprod.Text = ""; categoriaprod.Text = ""; ubicacionprod.Text = ""; try { cs.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { Double val = read.GetDouble(11); Double val2 = read.GetDouble(10); DateTime dtprod = DateTime.Today; dtprod = read.GetDateTime(6); precio.Text = (Math.Round(val, 2)).ToString(); costolb.Text = (Math.Round(val2, 2)).ToString(); statelb.Text = read.GetString(5); stock.Text = read.GetInt32(13).ToString(); stockmaxlb.Text = read.GetInt32(15).ToString(); stockminlb.Text = read.GetInt32(14).ToString(); nameprod.Text = read.GetString(1); codprod.Text = read.GetInt64(0).ToString(); categoriaprod.Text = GetCategory(read.GetInt32(16)); ubicacionprod.Text = GetSubCategory(read.GetString(19)); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[8]); System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); imagenprod.Image = Image.FromStream(ms); datevencimiento.Value = dtprod; } cs.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cs.CerrarCnn(); } }
private void saveboton_Click(object sender, EventArgs e) { try { // Objetos de conexión y comando System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); // Estableciento propiedades cmd.Connection = cs.GetCONN(); cmd.CommandText = "UPDATE Empresa SET CodeQr=@codeq, numAutoEmp=@numa, codControlEmp = @codc ;"; // Creando los parámetros necesarios cmd.Parameters.Add("@codeq", System.Data.SqlDbType.Image); cmd.Parameters.Add("@numa", System.Data.SqlDbType.VarChar); cmd.Parameters.Add("@codc", System.Data.SqlDbType.VarChar); // Asignando el valor de la imagen // Stream usado como buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se guarda la imagen en el buffer logoview.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // Asignando los valores a los atributos cmd.Parameters["@codeq"].Value = ms.GetBuffer(); cmd.Parameters["@numa"].Value = ndatxt.Text; cmd.Parameters["@codc"].Value = cdctxt.Text; cs.OpenCnn(); cmd.ExecuteNonQuery(); cs.CerrarCnn(); Messengers mr = new Messengers(); mr.textolb.Text = "Datos Guardado"; mr.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("ERROR. Al Insertar Los Datos. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private int comprobar() { int cnt = 0; string buscar = "SELECT * FROM Medidas WHERE codMed = '" + textcod.Text + "' ; "; try { cs.OpenCnn(); SqlCommand find = new SqlCommand(buscar, cs.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { cnt = cnt + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } cs.CerrarCnn(); return(cnt); }
public void GetCodeUsr(String nvl) { Conexion f = new Conexion(); string query = "SELECT ciUser, nombreUser, apeUser, fotoUser FROM Usuario WHERE nombreUser ='******' ; "; SqlCommand sqlQ = new SqlCommand(query, f.GetCONN()); SqlDataReader read; txtname.Text = ""; txtname.ForeColor = SystemColors.WindowText; txtname.Font = new Font(txtname.Font, FontStyle.Regular); txtci.Text = ""; txtci.ForeColor = SystemColors.WindowText; txtci.Font = new Font(txtci.Font, FontStyle.Regular); try { f.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { txtci.Text = read.GetInt32(0).ToString(); txtname.Text = read.GetString(1) + " " + read.GetString(2); byte[] imageBuffer = (byte[])(read[3]); if (imageBuffer == null || read[3] == null) { PBFoto.Image = null; } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); PBFoto.Image = Image.FromStream(ms); } } f.CerrarCnn(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); f.CerrarCnn(); } }
public void CargarEmpresa() { Conexion a = new Conexion(); string query = "SELECT * FROM Empresa; "; SqlCommand sqlQ = new SqlCommand(query, a.GetCONN()); a.OpenCnn(); SqlDataReader read2; try { read2 = sqlQ.ExecuteReader(); while (read2.Read()) { TSSemp.Text = read2.GetString(1); lbName.Text = read2.GetString(1); DirEmp = read2.GetString(2); lbtel.Text = read2.GetInt32(3).ToString(); lbcel.Text = read2.GetInt32(4).ToString(); lbfaxs.Text = read2.GetInt32(5).ToString() + " " + read2.GetInt32(6).ToString(); lbcorreo.Text = read2.GetString(7); lbweb.Text = read2.GetString(8); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read2[9]); byte[] img2 = (byte[])(read2[10]); byte[] img3 = (byte[])(read2[11]); // Se crea un MemoryStream a partir de ese buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); System.IO.MemoryStream ms2 = new System.IO.MemoryStream(img2); System.IO.MemoryStream ms3 = new System.IO.MemoryStream(img3); logoEmp.BackgroundImage = Image.FromStream(ms); PBanun1.BackgroundImage = Image.FromStream(ms2); PBanun2.BackgroundImage = Image.FromStream(ms3); } a.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void eliminar_Click(object sender, EventArgs e) { Conexion w = new Conexion(); if (codUser == "0") { MessageBox.Show("Debe Seleccionar una Medida de la Tabla de Registros para Proceder la Eliminación", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de Eliminar Marca. if (comprobar() == 1) { try { // Objetos de conexión y comando System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); // Estableciento propiedades cmd.Connection = w.GetCONN(); cmd.CommandText = "DELETE FROM Medidas WHERE codMed = '" + codUser + "' ;"; w.OpenCnn(); cmd.ExecuteNonQuery(); w.CerrarCnn(); Messengers mr = new Messengers(); mr.textolb.Text = "Marca Eliminada"; mr.ShowDialog(); } catch (Exception ex) { MessageBox.Show("ERROR. Al Eliminar Los Datos. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Error, No Existen Registros de la Medida.\nActualizar el Registro.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private int comprobar() { int cnt = 0; string buscar = "SELECT * FROM Usuario WHERE ciUser= '******' ; "; Conexion f = new Conexion(); try { f.OpenCnn(); SqlCommand find = new SqlCommand(buscar, f.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { cnt = cnt + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } f.CerrarCnn(); return(cnt); }
private String ReconocerDepa(String cod) { String res = ""; Conexion d = new Conexion(); string query = "SELECT nombreDep FROM Departamento WHERE codigoDep ='" + cod + "' ; "; SqlCommand sqlQ = new SqlCommand(query, d.GetCONN()); d.OpenCnn(); SqlDataReader read; try { read = sqlQ.ExecuteReader(); while (read.Read()) { res = read.GetString(0); } } catch (Exception) { } d.CerrarCnn(); return(res); }
private String GetCategory(int value) { String res = ""; Conexion d = new Conexion(); string query = "SELECT * FROM Categorias WHERE codCat = '" + value + "' ; "; SqlCommand sqlQ = new SqlCommand(query, d.GetCONN()); d.OpenCnn(); SqlDataReader read2; try { read2 = sqlQ.ExecuteReader(); while (read2.Read()) { res = read2.GetString(1); } } catch (Exception) { d.CerrarCnn(); } return(res); }
private int comprobar() { int cnt = 0; string buscar = "SELECT * FROM Categorias WHERE codCat = '" + int.Parse(textcod.Text) + "' ; "; Conexion fg = new Conexion(); try { fg.OpenCnn(); SqlCommand find = new SqlCommand(buscar, fg.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { cnt = cnt + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } fg.CerrarCnn(); return(cnt); }
private int comprobar() { int cnt = 0; Conexion cd = new Conexion(); string buscar = "SELECT * FROM Productos WHERE CodBarP = '" + Convert.ToInt64(codprod.Text) + "' ; "; try { cd.OpenCnn(); SqlCommand find = new SqlCommand(buscar, cd.GetCONN()); SqlDataReader fb; fb = find.ExecuteReader(); while (fb.Read()) { cnt = cnt + 1; } } catch (Exception ex) { MessageBox.Show("ERROR. En el Comparador. " + ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } cd.CerrarCnn(); return(cnt); }