public static List <TbClienteBE> SelectAll() { string ConnectionString = ConfigurationManager.ConnectionStrings["Northwind"].ToString(); string sql = "Select CodCliente, Nombre, Ruc from TbCliente"; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { command.CommandType = CommandType.Text; List <TbClienteBE> Clientes = new List <TbClienteBE>(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { TbClienteBE objCliente = new TbClienteBE( Convert.ToString(reader.GetSqlDecimal(0)), reader.GetString(1), reader.GetString(2)); Clientes.Add(objCliente); } } return(Clientes); } } }
private void frmCliente_Load(object sender, EventArgs e) { Lista = TbClienteBE.SelectAll(); TbClientebindingSource.DataSource = Lista; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }
private void AgregarClienteaFactura() { int i = dataGridView1.CurrentRow.Index; string codigocliente = dataGridView1.Rows[i].Cells[0].Value.ToString(); TbClienteBE oCliente = (from item in Lista.ToArray() where item.CodCliente == codigocliente select item).Single(); onClienteSeleccionado(new object(), oCliente); this.Close(); }
private void AgregarClienteaFactura() { //Agregar Cliente al formulario Documento int i = dataGridView1.CurrentRow.Index; int codigocliente = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value); //query en LINQ TbClienteBE oCliente = (from item in Lista.ToArray() where item.CodCliente == codigocliente select item).Single(); OnClienteSeleccionado(new object(), oCliente); this.Close(); }
//public static List<TbClienteBE> SelectAll() //{ // string ConnectionString = // ConfigurationManager.ConnectionStrings["NorthWind"].ToString(); // string sql = "Select CodCliente, Nombre, Ruc from TbCliente"; // using (SqlConnection connection = new SqlConnection(ConnectionString)) // { // connection.Open(); // using (SqlCommand command = new SqlCommand(sql, connection)) // { // command.CommandType = CommandType.Text; // List<TbClienteBE> Clientes = new List<TbClienteBE>(); // using (SqlDataReader reader = command.ExecuteReader()) // { // while (reader.Read()) // { // TbClienteBE objCliente = new TbClienteBE(); // objCliente.CodCliente =Convert.ToString( reader.GetDecimal(0)); // objCliente.Nombre = reader.GetString(1); // objCliente.Ruc = reader.GetString(2); // Clientes.Add(objCliente); // } // } // return Clientes; // } // } //} //CON ENTERPRISE public static List <TbClienteBE> SelectAll() { Database db = EnterpriseLibraryContainer.Current.GetInstance <Database>("NW"); string sql = "Select CodCliente, Nombre, Ruc from TbCliente"; List <TbClienteBE> clientes = new List <TbClienteBE>(); using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, sql)) { while (dataReader.Read()) { TbClienteBE objTbClienteBE = new TbClienteBE(); objTbClienteBE.CodCliente = Convert.ToString(dataReader.GetDecimal(0)); objTbClienteBE.Nombre = dataReader.GetString(1); objTbClienteBE.Ruc = dataReader.GetString(2); clientes.Add(objTbClienteBE); } } return(clientes); }
void oFrmCliente_OnClienteSeleccionado(object sender, TbClienteBE e) { txtcliente.Text = e.Nombre; txtruc.Text = e.Ruc; otmpCliente = e; }
TbClienteBE otmpCliente; //Variable Temporal void MetodoCliente(object sender, TbClienteBE e) { txtcliente.Text = e.Nombre; txtruc.Text = e.Apellido; otmpCliente = e; }