private void printDocx_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //Inicio del encabezado del Documento. Conexion cs = new Conexion(); string query = "SELECT * FROM Empresa ; "; SqlCommand sqlQ = new SqlCommand(query, cs.GetCONN()); SqlDataReader read; Image img = null; //Variables Guardar los Datos de la Empresa. String name = ""; String nit = ""; String tel = ""; String cel = ""; String dir = ""; String web = ""; int width = 0; int height = 0; int x = 0; int y = 0; int rowheight = 0; int columnwidth = 0; StringFormat str = new StringFormat(); str.Alignment = StringAlignment.Near; str.LineAlignment = StringAlignment.Center; str.Trimming = StringTrimming.EllipsisCharacter; Pen p = new Pen(Color.Black, 2.5f); try { cs.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[9]); name = read.GetString(1); nit = read.GetString(0); tel = read.GetInt32(3).ToString(); cel = read.GetInt32(4).ToString(); dir = read.GetString(2); web = read.GetString(8); if (imageBuffer == null || read[9] == null) { img = null; } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); img = Image.FromStream(ms); //Logotipo } } //Datos de la Empresa. e.Graphics.DrawImage(img, 20, 20, img.Width, img.Height); e.Graphics.DrawString(name, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 20); e.Graphics.DrawString(nit, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 50); e.Graphics.DrawString(tel, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 80); e.Graphics.DrawString(cel, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 130, 80); e.Graphics.DrawString(dir, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 100); e.Graphics.DrawString(web, new Font("Lucida Sans", 12), new SolidBrush(Color.Black), img.Width + 30, 130); e.Graphics.DrawString("Registro de Productos", new Font("Lucida Sans", 18), new SolidBrush(Color.DarkBlue), img.Width + 400, 60); //fin Encabezado Documento. //Insert DataGrid Print. #region Draw Column 1 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(10, 200, regprodtable.Columns[0].Width - 45, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 10, 200, regprodtable.Columns[0].Width - 45, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[0].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(10, 200, regprodtable.Columns[0].Width - 45, regprodtable.Rows[0].Height), str); #endregion #region Draw column 2 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(10 + regprodtable.Columns[0].Width - 45, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 10 + regprodtable.Columns[0].Width - 45, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[1].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(10 + regprodtable.Columns[0].Width - 45, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height), str); #endregion #region Draw column 3 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(65 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 65 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[10].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(65 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height), str); #endregion #region Draw column 4 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(165 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 165 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[11].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(165 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height), str); #endregion #region Draw column 5 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(265 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 265 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[13].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(265 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width, regprodtable.Rows[0].Height), str); #endregion #region Draw column 6 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(365 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width + 10, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 365 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width + 10, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[14].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(365 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width + 10, regprodtable.Rows[0].Height), str); #endregion #region Draw column 7 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(495 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width - 20, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 495 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width - 20, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[15].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(495 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width - 20, regprodtable.Rows[0].Height), str); #endregion #region Draw column 8 e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(595 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width - 60, regprodtable.Rows[0].Height)); e.Graphics.DrawRectangle(Pens.Black, 595 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width - 60, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Columns[6].HeaderText, regprodtable.Font, Brushes.Black, new RectangleF(595 + regprodtable.Columns[0].Width, 200, regprodtable.Columns[0].Width - 60, regprodtable.Rows[0].Height), str); #endregion #region Draw Rows N width = 10 + regprodtable.Columns[0].Width; height = 200; //variable i is declared at class level to preserve the value of i if e.hasmorepages is true while (i < regprodtable.Rows.Count) { if (height > e.MarginBounds.Height) { height = 200; width = 10; e.HasMorePages = true; return; } height += regprodtable.Rows[i].Height; //Draw Row 1 e.Graphics.DrawRectangle(Pens.Black, 10, height, regprodtable.Columns[0].Width - 45, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[0].FormattedValue.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(10, height, regprodtable.Columns[0].Width - 45, regprodtable.Rows[0].Height), str); //Draw Row 2 e.Graphics.DrawRectangle(Pens.Black, 10 + regprodtable.Columns[0].Width - 45, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[1].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(10 + regprodtable.Columns[0].Width - 45, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height), str); //Draw Row 3 e.Graphics.DrawRectangle(Pens.Black, 65 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[10].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(65 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height), str); //Draw Row 4 e.Graphics.DrawRectangle(Pens.Black, 165 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[11].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(165 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height), str); //Draw Row 5 e.Graphics.DrawRectangle(Pens.Black, 265 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[13].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(265 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height), str); //Draw Row 6 e.Graphics.DrawRectangle(Pens.Black, 365 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 20, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[14].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(365 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 20, regprodtable.Rows[0].Height), str); //Draw Row 7 e.Graphics.DrawRectangle(Pens.Black, 495 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[15].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(495 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 50, regprodtable.Rows[0].Height), str); //Draw Row 8 e.Graphics.DrawRectangle(Pens.Black, 595 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 60, regprodtable.Rows[0].Height); e.Graphics.DrawString(regprodtable.Rows[i].Cells[6].Value.ToString(), regprodtable.Font, Brushes.Black, new RectangleF(595 + regprodtable.Columns[0].Width, height, regprodtable.Columns[0].Width - 60, regprodtable.Rows[0].Height), str); width += regprodtable.Columns[0].Width; i++; } #endregion cs.CerrarCnn(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cs.CerrarCnn(); } }
private void findbtn_Click(object sender, EventArgs e) { Conexion s = new Conexion(); String query = ""; SqlCommand sqlQ; SqlDataReader read; if (citext.Text != "" && citext.Font.Italic == true) { if (citext.Text == "") { MessageBox.Show("Ingrese el Nombre o Descripción del Producto a Buscar.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Nombre o Descripción del Producto a Buscar.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (citext.Text == "") { MessageBox.Show("Ingrese el Nombre o Descripción del Producto a Buscar.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { NomP.Text = ""; codP.Text = ""; state.Text = ""; fechav.Text = ""; fechaC.Text = ""; pesoP.Text = ""; volP.Text = ""; descP.Text = ""; MinP.Text = ""; MaxP.Text = ""; cantP.Text = ""; CCUP.Text = ""; PVUP.Text = ""; if (comprobarCodBar() == 1) { query = "SELECT * FROM Productos WHERE CodBarP ='" + Convert.ToInt64(citext.Text) + "' ; "; sqlQ = new SqlCommand(query, s.GetCONN()); s.OpenCnn(); try { read = sqlQ.ExecuteReader(); while (read.Read()) { NomP.Text = read.GetString(1); codP.Text = read.GetInt64(0).ToString(); state.Text = read.GetString(5); fechaC.Text = read.GetDateTime(7).ToString(); descP.Text = read.GetString(2); pesoP.Text = read.GetDouble(3).ToString(); volP.Text = read.GetDouble(4).ToString(); MaxP.Text = read.GetInt32(15).ToString(); MinP.Text = read.GetInt32(14).ToString(); cantP.Text = read.GetInt32(13).ToString(); CCUP.Text = read.GetDouble(10).ToString(); PVUP.Text = read.GetDouble(11).ToString(); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[8]); byte[] imgcod = (byte[])(read[9]); // Se crea un MemoryStream a partir de ese buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); System.IO.MemoryStream mscod = new System.IO.MemoryStream(imgcod); fotoP.Image = Image.FromStream(ms); codFotoP.Image = Image.FromStream(mscod); fechav.Text = read.GetDateTime(6).ToString(); } s.CerrarCnn(); } catch (Exception) { } } else if (comprobarName() == 1) { query = "SELECT * FROM Productos WHERE nomProd ='" + citext.Text + "' ; "; sqlQ = new SqlCommand(query, s.GetCONN()); s.OpenCnn(); try { read = sqlQ.ExecuteReader(); while (read.Read()) { NomP.Text = read.GetString(1); codP.Text = read.GetInt64(0).ToString(); state.Text = read.GetString(5); fechaC.Text = read.GetDateTime(7).ToString(); descP.Text = read.GetString(2); pesoP.Text = read.GetDouble(3).ToString(); volP.Text = read.GetDouble(4).ToString(); MaxP.Text = read.GetInt32(15).ToString(); MinP.Text = read.GetInt32(14).ToString(); cantP.Text = read.GetInt32(13).ToString(); CCUP.Text = read.GetDouble(10).ToString(); PVUP.Text = read.GetDouble(11).ToString(); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[8]); byte[] imgcod = (byte[])(read[9]); // Se crea un MemoryStream a partir de ese buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); System.IO.MemoryStream mscod = new System.IO.MemoryStream(imgcod); fotoP.Image = Image.FromStream(ms); codFotoP.Image = Image.FromStream(mscod); fechav.Text = read.GetDateTime(6).ToString(); } s.CerrarCnn(); } catch (Exception) { } } else if (comprobarDetalle() == 1) { query = "SELECT * FROM Productos WHERE DescProd LIKE '" + citext.Text + "%'"; sqlQ = new SqlCommand(query, s.GetCONN()); s.OpenCnn(); try { read = sqlQ.ExecuteReader(); while (read.Read()) { NomP.Text = read.GetString(1); codP.Text = read.GetInt64(0).ToString(); state.Text = read.GetString(5); fechaC.Text = read.GetDateTime(7).ToString(); descP.Text = read.GetString(2); pesoP.Text = read.GetDouble(3).ToString(); volP.Text = read.GetDouble(4).ToString(); MaxP.Text = read.GetInt32(15).ToString(); MinP.Text = read.GetInt32(14).ToString(); cantP.Text = read.GetInt32(13).ToString(); CCUP.Text = read.GetDouble(10).ToString(); PVUP.Text = read.GetDouble(11).ToString(); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[8]); byte[] imgcod = (byte[])(read[9]); // Se crea un MemoryStream a partir de ese buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); System.IO.MemoryStream mscod = new System.IO.MemoryStream(imgcod); fotoP.Image = Image.FromStream(ms); codFotoP.Image = Image.FromStream(mscod); fechav.Text = read.GetDateTime(6).ToString(); } s.CerrarCnn(); } catch (Exception) { } } else { MessageBox.Show("ERROR. El Producto No Esta Registrado. \nReintente Nuevamente... ", " ", MessageBoxButtons.OK, MessageBoxIcon.Error); s.CerrarCnn(); } } }
private void buscarboton_Click(object sender, EventArgs e) { Conexion f = new Conexion(); if (ciedu.Text != "" && ciedu.Font.Italic == true) { if (ciedu.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Usuario que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Carnet de Identidad del Usuario que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (ciedu.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Usuario que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de buscar Usuario. string query = "SELECT * FROM Usuario WHERE ciUser ='******' ; "; SqlCommand sqlQ = new SqlCommand(query, f.GetCONN()); SqlDataReader read; if (comprobar() == 1) { cius.Text = ""; cius.ForeColor = SystemColors.WindowText; cius.Font = new Font(cius.Font, FontStyle.Regular); nameus.Text = ""; nameus.ForeColor = SystemColors.WindowText; nameus.Font = new Font(nameus.Font, FontStyle.Regular); apelus.Text = ""; apelus.ForeColor = SystemColors.WindowText; apelus.Font = new Font(apelus.Font, FontStyle.Regular); nomedus.Text = ""; nomedus.ForeColor = SystemColors.WindowText; nomedus.Font = new Font(nomedus.Font, FontStyle.Regular); fotous.Text = ""; fotous.ForeColor = SystemColors.WindowText; fotous.Font = new Font(fotous.Font, FontStyle.Regular); corredu.Text = ""; corredu.ForeColor = SystemColors.WindowText; corredu.Font = new Font(corredu.Font, FontStyle.Regular); cargoedus.Text = ""; cargoedus.ForeColor = SystemColors.WindowText; cargoedus.Font = new Font(cargoedus.Font, FontStyle.Regular); teledu.Text = ""; teledu.ForeColor = SystemColors.WindowText; teledu.Font = new Font(teledu.Font, FontStyle.Regular); celedu.Text = ""; celedu.ForeColor = SystemColors.WindowText; celedu.Font = new Font(celedu.Font, FontStyle.Regular); faxedu.Text = ""; faxedu.ForeColor = SystemColors.WindowText; faxedu.Font = new Font(faxedu.Font, FontStyle.Regular); diredu.Text = ""; diredu.ForeColor = SystemColors.WindowText; diredu.Font = new Font(diredu.Font, FontStyle.Regular); try { f.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { cius.Text = read.GetInt32(0).ToString(); nameus.Text = read.GetString(1); apelus.Text = read.GetString(2); nomedus.Text = read.GetString(3); passedus.Text = read.GetString(4); confpass.Text = read.GetString(4); diredu.Text = read.GetString(5); cargoedus.Text = read.GetString(7); corredu.Text = read.GetString(14); teledu.Text = read.GetInt32(10).ToString(); celedu.Text = read.GetInt32(11).ToString(); faxedu.Text = read.GetInt32(12).ToString(); dia.SelectedItem = read.GetString(9).Substring(0, 2); mes.SelectedItem = read.GetString(9).Substring(3, 2); anno.SelectedItem = read.GetString(9).Substring(6, 4); nivelesus.SelectedItem = read.GetString(6); depaedu.SelectedItem = GetDepa(read.GetString(16)); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[13]); // Se crea un MemoryStream a partir de ese buffer if (imageBuffer == null || read[13] == null) { fotoUser.Image = null; } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); fotoUser.Image = Image.FromStream(ms); } if (read.GetString(8) == "Masculino") { sexMax.Checked = true; sexFem.Checked = false; } else { sexFem.Checked = true; sexMax.Checked = false; } } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("ERROR, El Usuario Solicitado no Existe.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void VerProductos_Load(object sender, EventArgs e) { Conexion s = new Conexion(); string query = "SELECT * FROM Productos WHERE CodBarP ='" + codUser + "' ; "; SqlCommand sqlQ = new SqlCommand(query, s.GetCONN()); s.OpenCnn(); SqlDataReader read; if (comprobar() == 1) { NomP.Text = ""; codP.Text = ""; state.Text = ""; fechav.Text = ""; fechaC.Text = ""; pesoP.Text = ""; volP.Text = ""; descP.Text = ""; MinP.Text = ""; MaxP.Text = ""; cantP.Text = ""; CCUP.Text = ""; PVUP.Text = ""; try { read = sqlQ.ExecuteReader(); while (read.Read()) { NomP.Text = read.GetString(1); codP.Text = read.GetInt64(0).ToString(); state.Text = read.GetString(5); fechaC.Text = read.GetDateTime(7).ToString(); descP.Text = read.GetString(2); pesoP.Text = read.GetDouble(3).ToString(); volP.Text = read.GetDouble(4).ToString(); MaxP.Text = read.GetInt32(15).ToString(); MinP.Text = read.GetInt32(14).ToString(); cantP.Text = read.GetInt32(13).ToString(); CCUP.Text = read.GetDouble(10).ToString(); PVUP.Text = read.GetDouble(11).ToString(); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[8]); byte[] imgcod = (byte[])(read[9]); // Se crea un MemoryStream a partir de ese buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); System.IO.MemoryStream mscod = new System.IO.MemoryStream(imgcod); fotoP.Image = Image.FromStream(ms); codFotoP.Image = Image.FromStream(mscod); fechav.Text = read.GetDateTime(6).ToString(); } s.CerrarCnn(); } catch (Exception ex) { MessageBox.Show("Existe un Error con el Comando Ingresado. " + ex.Message + "\n Verificar el Comando.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("ERROR, Debe Seleccionar un Producto de la Tabla de Registro; Para Proceder la Presentación de los Datos del Producto.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buscaredboton_Click(object sender, EventArgs e) { Conexion f = new Conexion(); if (ciedcli.Text != "" && ciedcli.Font.Italic == true) { if (ciedcli.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Cliente que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Carnet de Identidad del Cliente que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (ciedcli.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Cliente que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de Buscar Cliente. string query = "SELECT * FROM Clientes WHERE idCliente ='" + Convert.ToInt32(ciedcli.Text) + "' ; "; SqlCommand sqlQ = new SqlCommand(query, f.GetCONN()); SqlDataReader read; if (comprobar() == 1) { ci.Text = ""; ci.ForeColor = SystemColors.WindowText; ci.Font = new Font(ci.Font, FontStyle.Regular); nomed.Text = ""; nomed.ForeColor = SystemColors.WindowText; nomed.Font = new Font(nomed.Font, FontStyle.Regular); apeled.Text = ""; apeled.ForeColor = SystemColors.WindowText; apeled.Font = new Font(apeled.Font, FontStyle.Regular); nited.Text = ""; nited.ForeColor = SystemColors.WindowText; nited.Font = new Font(nited.Font, FontStyle.Regular); corred.Text = ""; corred.ForeColor = SystemColors.WindowText; corred.Font = new Font(corred.Font, FontStyle.Regular); webed.Text = ""; webed.ForeColor = SystemColors.WindowText; webed.Font = new Font(webed.Font, FontStyle.Regular); teled.Text = ""; teled.ForeColor = SystemColors.WindowText; teled.Font = new Font(teled.Font, FontStyle.Regular); celed.Text = ""; celed.ForeColor = SystemColors.WindowText; celed.Font = new Font(celed.Font, FontStyle.Regular); faxed.Text = ""; faxed.ForeColor = SystemColors.WindowText; faxed.Font = new Font(faxed.Font, FontStyle.Regular); fotoed.Text = ""; fotoed.ForeColor = SystemColors.WindowText; fotoed.Font = new Font(fotoed.Font, FontStyle.Regular); dired.Text = ""; dired.ForeColor = SystemColors.WindowText; dired.Font = new Font(dired.Font, FontStyle.Regular); try { f.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { ci.Text = read.GetInt32(0).ToString(); nomed.Text = read.GetString(1); apeled.Text = read.GetString(2); nited.Text = read.GetString(3); corred.Text = read.GetString(4); webed.Text = read.GetString(5); dired.Text = read.GetString(6); teled.Text = read.GetInt32(8).ToString(); celed.Text = read.GetInt32(9).ToString(); faxed.Text = read.GetInt32(10).ToString(); staed.SelectedItem = read.GetString(15); dia.SelectedItem = read.GetString(11).Substring(0, 2); mes.SelectedItem = read.GetString(11).Substring(3, 2); anno.SelectedItem = read.GetString(11).Substring(6, 4); depaed.SelectedItem = GetDepa(read.GetString(16)); // El campo productImage primero se almacena en un buffer byte[] imageBuffer = (byte[])(read[13]); // Se crea un MemoryStream a partir de ese buffer if (imageBuffer == null || read[13] == null) { fotoCliente.Image = null; } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBuffer); fotoCliente.Image = Image.FromStream(ms); } if (read.GetString(7) == "Masculino") { sexMax.Checked = true; sexFem.Checked = false; } else { sexFem.Checked = true; sexMax.Checked = false; } } } catch (Exception ex) { MessageBox.Show("Existe Datos Nulos con el Cliente Ingresado. \n" + ex.Message + "\nCompruebe Que No Exista Datos Nulos o Vacios con el Cliente a Modificar.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); f.CerrarCnn(); } } else { MessageBox.Show("ERROR, El Cliente Solicitado no Existe.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); f.CerrarCnn(); } } }
private void buscaredboton_Click(object sender, EventArgs e) { Conexion f = new Conexion(); if (ciuser.Text != "" && ciuser.Font.Italic == true) { if (ciuser.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Usuario que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Ingrese el Carnet de Identidad del Usuario que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (ciuser.Text == "") { MessageBox.Show("Ingrese el Carnet de Identidad del Usuario que Muestra en la Tabla de Solicitudes", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Codigo de buscar Usuario. string query = "SELECT * FROM Usuario WHERE ciUser ='******' ; "; SqlCommand sqlQ = new SqlCommand(query, f.GetCONN()); SqlDataReader read; if (comprobar() == 1) { ciuser.ForeColor = SystemColors.WindowText; ciuser.Font = new Font(ciuser.Font, FontStyle.Regular); nameus.Text = ""; nameus.ForeColor = SystemColors.WindowText; nameus.Font = new Font(nameus.Font, FontStyle.Regular); apeus.Text = ""; apeus.ForeColor = SystemColors.WindowText; apeus.Font = new Font(apeus.Font, FontStyle.Regular); nameus.Text = ""; nameus.ForeColor = SystemColors.WindowText; nameus.Font = new Font(nameus.Font, FontStyle.Regular); dirus.Text = ""; dirus.ForeColor = SystemColors.WindowText; dirus.Font = new Font(dirus.Font, FontStyle.Regular); corrus.Text = ""; corrus.ForeColor = SystemColors.WindowText; corrus.Font = new Font(corrus.Font, FontStyle.Regular); telus.Text = ""; telus.ForeColor = SystemColors.WindowText; telus.Font = new Font(telus.Font, FontStyle.Regular); celus.Text = ""; celus.ForeColor = SystemColors.WindowText; celus.Font = new Font(celus.Font, FontStyle.Regular); try { f.OpenCnn(); read = sqlQ.ExecuteReader(); while (read.Read()) { nomus.Text = read.GetString(2); apeus.Text = read.GetString(3); nameus.Text = read.GetString(4); passus.Text = read.GetString(5); confpsss.Text = read.GetString(5); dirus.Text = read.GetString(6); corrus.Text = read.GetString(9); telus.Text = read.GetInt32(10).ToString(); celus.Text = read.GetInt32(11).ToString(); } f.CerrarCnn(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("ERROR, El Usuario Solicitado no Existe.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }