public List <UserInfo> GetTopExp() { var rs = new List <UserInfo>(); var sql = "SELECT top 100 * FROM [portal].[dbo].view_user_info ORDER BY EXP DESC"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { var u = new UserInfo { uid = MyReader.GetInt64(MyReader.GetOrdinal("id")), userName = MyReader.GetString(MyReader.GetOrdinal("username")), fullName = MyReader.GetString(MyReader.GetOrdinal("fullname")), cashWin = MyReader.GetInt64(MyReader.GetOrdinal("EXP")) }; rs.Add(u); } MyReader.Close(); conn.Close(); return(rs); }
/// <summary> /// Danh sách top user thắng nhiều (top) theo từng Game Id /// </summary> /// <param name="zoneId"></param> /// <param name="top"></param> /// <returns></returns> public List <UserInfo> GetTopUserByZoneID(int zoneId, int top) { var rs = new List <UserInfo>(); var sql = "select b.id,b.username, b.fullname,sum(a.cash) as total_cash_win from newDB.game_history a inner join newDB.view_user_info b on a.user_id = b.id where a.cash > 0 AND (trans_type=1 or trans_type=18) AND game_id = @zoneId" + " group by a.user_id order by total_cash_win desc" + " limit 0, @top"; MySqlConnection conn = new MySqlConnection(Constants.DBConnection); MySqlCommand MyCommand = new MySqlCommand(sql, conn); MyCommand.Parameters.AddWithValue("zoneId", zoneId); MyCommand.Parameters.AddWithValue("top", top); MySqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { UserInfo u = new UserInfo(); u.uid = MyReader.GetInt64("id"); u.userName = MyReader.GetString("username"); u.fullName = MyReader.GetString("fullname"); u.cashWin = MyReader.GetInt64("total_cash_win"); rs.Add(u); } MyReader.Close(); conn.Close(); return(rs); }
/// <summary> /// Báo cáo Danh sách user nạp nhiều tiền nhất (theo tổng số tiền Su đã nạp) /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="top"></param> /// <returns></returns> public List <ReportUserChargeMoneyItem> ReportUserChargedMost(DateTime from, DateTime to, int top) { var rs = new List <ReportUserChargeMoneyItem>(); string sql = String.Format("SELECT h.user_id, u.username, u.fullname, u.ip, u.gameCash, u.vCash, SUM(h.cash) AS 'SuNap' FROM newDB.game_history h INNER JOIN newDB.view_user_info u ON h.user_id = u.id WHERE h.trans_type = 4 and h.time > '{0}' and h.time < '{1}' group by h.user_id, u.username, u.fullname order by SUM(h.cash) desc limit 0, {2}", from.ToString("yyyy-MM-dd HH:mm:ss"), to.ToString("yyyy-MM-dd HH:mm:ss"), top); MySqlConnection conn = new MySqlConnection(Constants.DBConnection); MySqlCommand MyCommand = new MySqlCommand(sql, conn); MySqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { ReportUserChargeMoneyItem item1 = new ReportUserChargeMoneyItem(); item1.user_id = MyReader.GetInt32("user_id"); item1.username = MyReader.GetString("username"); item1.fullname = MyReader.GetString("fullname"); item1.ip = MyReader.GetString("ip"); item1.gameCash = MyReader.GetInt64("gameCash"); item1.vCash = MyReader.GetInt64("vCash"); if (String.IsNullOrEmpty(item1.fullname)) { item1.fullname = item1.username; } item1.moenyCharged = MyReader.GetInt64("SuNap"); rs.Add(item1); } MyReader.Close(); conn.Close(); return(rs); }
public List <GameGuideItem> GameGuideGetAll() { var lst = new List <GameGuideItem>(); string sql = "SELECT gui.*, ga.Name FROM [portal].[dbo].gameGuide gui LEFT JOIN [portal].[dbo].game ga ON ga.ID = gui.game_id ORDER BY gui.id DESC"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { var item = new GameGuideItem { id = MyReader.GetInt32(MyReader.GetOrdinal("id")), game = MyReader.GetString(MyReader.GetOrdinal("Name")), description = MyReader.GetString(MyReader.GetOrdinal("description")), game_id = MyReader.GetInt32(MyReader.GetOrdinal("game_id")), }; lst.Add(item); } MyReader.Close(); conn.Close(); return(lst); }
/*update 24/03*/ public List <GameTextItem> GetAll() { var lst = new List <GameTextItem>(); string sql = "SELECT * FROM [portal].[dbo].chuchaychay ORDER BY id DESC"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { var item = new GameTextItem { ID = MyReader.GetInt32(MyReader.GetOrdinal("id")), Title = MyReader.GetString(MyReader.GetOrdinal("Title")), Link = MyReader.GetString(MyReader.GetOrdinal("Link")), DataStart = MyReader.GetDateTime(MyReader.GetOrdinal("DataStart")), DateEnd = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")), IsDelete = MyReader.GetBoolean(MyReader.GetOrdinal("IsDelete")), Order = MyReader.GetInt32(MyReader.GetOrdinal("Orders")), DataStartstring = MyReader.GetDateTime(MyReader.GetOrdinal("DataStart")).ToShortDateString(), DateEndstring = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")).ToShortDateString() }; lst.Add(item); } MyReader.Close(); conn.Close(); return(lst); }
//**************recuperation du nom et prenom de la table Perso dans le form Accident**************// private void btnRecVict_Click(object sender, EventArgs e) { string sqlreq = "select Perso_Nom,Perso_Prenom From Perso INNER JOIN Accident ON Perso.Perso_Matricule = Accident.IdAccident where Perso.Perso_Matricule=" + Convert.ToInt32(textBoxMatr.Text) + ""; SqlDataReader MyReader; SqlCommand cmd = new SqlCommand(sqlreq, chaineConn.Cnx); chaineConn.Cnx.Open(); try { MyReader = cmd.ExecuteReader(); if (MyReader.HasRows) { while (MyReader.Read()) { string nom = MyReader.GetString(0); string prenom = MyReader.GetString(1); textBoxNom.Text = nom; textBoxPrenom.Text = prenom; } } MyReader.Close(); } catch (Exception exception) { Console.WriteLine(exception); } chaineConn.Cnx.Close(); }
void folio_pedido() // Método para mostrar el folio siguiente al último registrado en la base de datos { int folio = 0; MySqlConnection conexion = Conectar(); String sentencia = "SELECT IDpedido FROM pedido ORDER BY IDpedido DESC LIMIT 1"; MySqlCommand comando = new MySqlCommand(sentencia, conexion); conexion.Open(); comando.ExecuteNonQuery(); MySqlDataReader MyReader; MyReader = comando.ExecuteReader(); while (MyReader.Read()) { folio = (MyReader.GetInt16("IDpedido")); folio = folio + 1; } if (folio == 0) { folio = 1; } MyReader.Close(); conexion.Close(); var folio_padded = folio.ToString().PadLeft(4, '0'); textBox_idPedido.Text = folio_padded; }
public JsonResult Put(EmployeeData data) { string query = @" update dbo.Employee set QuickLookId = '" + data.QuickLookId + @"', FirstName = '" + data.FirstName + @"', LastName = '" + data.LastName + @"', PhoneNumber = '" + data.PhoneNumber + @"', Address = '" + data.Address + @"', City = '" + data.City + @"', State = '" + data.State + @"', Country = '" + data.Country + @"', ImageURL = '" + data.ImageURL + @"' where EmployeeID = " + data.EmployeeID + @" "; DataTable table = new DataTable(); string sqlConnection = _configuration.GetConnectionString("EmployeeAppCon"); SqlDataReader MyReader; using (SqlConnection myConnection = new SqlConnection(sqlConnection)) { myConnection.Open(); using (SqlCommand myCommand = new SqlCommand(query, myConnection)) { MyReader = myCommand.ExecuteReader(); table.Load(MyReader);; MyReader.Close(); myConnection.Close(); } } return(new JsonResult("Updated Sucessfully")); }
public List <Paciente> Filtar(string nome) { try { using (MyConnection = new MySqlConnection(ConnectionString)) { MyConnection.Open(); using (MyCommand = new MySqlCommand("SELECT * FROM pacientes WHERE nome LIKE '" + nome + "%'", MyConnection)) { using (MyReader = MyCommand.ExecuteReader()) { List <Paciente> pacientes = new List <Paciente>(); while (MyReader.Read()) { pacientes.Add(new Content().Get(MyReader)); } return(pacientes); } } } } finally { MyReader.Close(); MyCommand.Dispose(); MyConnection.Close(); } }
public AnnouncementItem GetOne(int ID) { var item = new AnnouncementItem(); string sql = "SELECT * FROM [newDB].[dbo].[event] WHERE id = @id"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); MyCommand.Parameters.AddWithValue("id", ID); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { item.ID = MyReader.GetInt32(MyReader.GetOrdinal("id")); item.begin_time = MyReader.GetDateTime(MyReader.GetOrdinal("DateStart")); item.end_time = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")); item.Subject = MyReader.GetString(MyReader.GetOrdinal("name")); item.UrlImage = MyReader.GetString(MyReader.GetOrdinal("UrlImage")); item.Content = MyReader.GetString(MyReader.GetOrdinal("content")); item.DoiTuong = MyReader.GetString(MyReader.GetOrdinal("DoiTuong")); item.ThoiGian = MyReader.GetString(MyReader.GetOrdinal("ThoiGian")); item.GameID = MyReader.GetInt32(MyReader.GetOrdinal("GameID")); item.DisplayOrder = MyReader.GetInt32(MyReader.GetOrdinal("DisplayOrder")); item.begin_timestring = item.begin_time.ToString(Constants.DateFormat); item.end_timestring = item.end_time.ToString(Constants.DateFormat); } MyReader.Close(); conn.Close(); return(item); }
public JsonResult Delete(int Id) { string query = @" delete from dbo.Employee where EmployeeID = " + Id + @" "; DataTable table = new DataTable(); string sqlConnection = _configuration.GetConnectionString("EmployeeAppCon"); SqlDataReader MyReader; using (SqlConnection myConnection = new SqlConnection(sqlConnection)) { myConnection.Open(); using (SqlCommand myCommand = new SqlCommand(query, myConnection)) { MyReader = myCommand.ExecuteReader(); table.Load(MyReader);; MyReader.Close(); myConnection.Close(); } } return(new JsonResult("Delete Sucessfully")); }
public List <AnnouncementItem> GetAll(int currentRecord = 0, int numberRecord = 10) { var lst = new List <AnnouncementItem>(); string sql = "SELECT * FROM [newDB].[dbo].[event] where [IsDelete] = 0 order by id desc OFFSET " + currentRecord + " ROWS FETCH NEXT " + numberRecord + "ROWS ONLY "; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { var item = new AnnouncementItem { ID = MyReader.GetInt32(MyReader.GetOrdinal("id")), DisplayOrder = MyReader.GetInt32(MyReader.GetOrdinal("DisplayOrder")), begin_time = MyReader.GetDateTime(MyReader.GetOrdinal("DateStart")), end_time = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")), Subject = MyReader.GetString(MyReader.GetOrdinal("name")), Content = MyReader.GetString(MyReader.GetOrdinal("content")), }; lst.Add(item); } MyReader.Close(); conn.Close(); return(lst); }
private void button_Click(object sender, RoutedEventArgs e) { try { string Query = "insert into hopedatabase.patient_data (`patient_name`, `patient_age`, `patient_contact_no`, `patient_address`, `time_of_admission`, `patient_sex`, `patient_occupation`) values('" + patient_name.Text + "','" + patient_age.Text + "','" + patient_contact_no2.Text + "','" + patient_address.Text + "','" + datepicker.Text + "','" + comboboxPatient_sex.SelectedItem.ToString() + "','" + patient_occupation.Text + "');"; MySqlCommand MyCommand = new MySqlCommand(Query, connn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); MessageBox.Show("Patient Registered"); string Query1 = "insert into hopedatabase.patient_data ( `patient_blood_group` ) values('" + comboboxBloodGroup.SelectedItem.ToString() + "');"; MySqlCommand MyCommand1 = new MySqlCommand(Query1, connn); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); patient_name.Text = ""; patient_address.Text = ""; patient_age.Text = ""; patient_contact_no2.Text = ""; referred_by.Text = ""; datepicker.Text = ""; patient_occupation.Text = ""; comboboxBloodGroup.Items.Clear(); comboboxPatient_sex.Items.Clear(); load_blood_group(); load(); patient_name.IsEnabled = false; patient_address.IsEnabled = false; patient_age.IsEnabled = false; referred_by.IsEnabled = false; comboboxBloodGroup.IsEnabled = false; } catch { } //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} }
public List <UserInfo> GetTopNapTien() { var rs = new List <UserInfo>(); var sql = "SELECT b.id, b.fullname, b.username, ABS(SUM(a.cash)) AS cashWin FROM [portal].[dbo].game_history a INNER JOIN [portal].[dbo].view_user_info b ON a.user_id = b.id WHERE trans_type = 4 AND a.cash > 0 GROUP BY b.id, b.fullname, b.username ORDER BY ABS(SUM(a.cash)) DESC"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { var u = new UserInfo { uid = MyReader.GetInt64(MyReader.GetOrdinal("id")), userName = MyReader.GetString(MyReader.GetOrdinal("username")), fullName = MyReader.GetString(MyReader.GetOrdinal("fullname")), cashWin = MyReader.GetInt64(MyReader.GetOrdinal("cashWin")) }; rs.Add(u); } MyReader.Close(); conn.Close(); return(rs); }
/// <summary> /// /// </summary> /// <param name="TextQuery"></param> /// <param name="result"></param> /// <returns></returns> public bool ExecuteWithRead(string TextQuery, out DataTable result) { result = new DataTable(); if (!ExecuteQuery(QueryParser(TextQuery))) { return(false); } for (int i = 0; i < MyReader.FieldCount; i++) { result.Columns.Add(MyReader.GetName(i), MyReader.GetFieldType(i)); } while (MyReader.Read()) { DataRow dr = result.NewRow(); for (int col = 0; col < MyReader.FieldCount; col++) { dr[col] = MyReader.GetValue(col); } result.Rows.Add(dr); } MyReader.Close(); return(true); }
public bool PacienteInternado(int paciente) { try { using (MyConnection = new MySqlConnection(ConnectionString)) { MyConnection.Open(); using (MyCommand = new MySqlCommand("SELECT * FROM internacoes WHERE paciente=@paciente AND data_saida='" + DateTime.MinValue.ToString("yyyy-MM-dd") + "'", MyConnection)) { MyCommand.Parameters.AddWithValue("@paciente", paciente); using (MyReader = MyCommand.ExecuteReader()) { List <Internacao> internacoes = new List <Internacao>(); while (MyReader.Read()) { internacoes.Add(new Content().Get(MyReader)); } return(internacoes.Count > 0); } } } } finally { MyReader.Close(); MyCommand.Dispose(); MyConnection.Close(); } }
/// <summary> /// возвращает список данных элемента справочника по его IDD или же ID (регулируется параметром ThisID) /// </summary> /// <param name="IDDorID"></param> /// <param name="SCType"></param> /// <param name="FieldList"></param> /// <param name="DataMap"></param> /// <param name="ThisID"></param> /// <returns></returns> public bool GetSCData(string IDDorID, string SCType, List <string> FieldList, out Dictionary <string, object> DataMap, bool ThisID) { SCType = "Спр." + SCType; DataMap = new Dictionary <string, object>(); if (!ExecuteQuery("SELECT " + ToFieldString(FieldList) + " FROM " + GetSynh(SCType) + " (nolock)" + " WHERE " + (ThisID ? "ID" : GetSynh(SCType + ".IDD")) + "='" + IDDorID + "'")) { return(false); } if (MyReader.Read()) { for (int i = 0; i < MyReader.FieldCount; i++) { DataMap[FieldList[i]] = MyReader[i]; } MyReader.Close(); return(true); } else { MyReader.Close(); FExcStr = "Элемент справочника не найден!"; return(false); } }
public List <Internacao> Listar(int paciente) { try { using (MyConnection = new MySqlConnection(ConnectionString)) { MyConnection.Open(); using (MyCommand = new MySqlCommand("SELECT * FROM internacoes WHERE paciente=@paciente ORDER BY id DESC", MyConnection)) { MyCommand.Parameters.AddWithValue("@paciente", paciente); using (MyReader = MyCommand.ExecuteReader()) { List <Internacao> internacoes = new List <Internacao>(); while (MyReader.Read()) { internacoes.Add(new Content().Get(MyReader)); } return(internacoes); } } } } finally { MyReader.Close(); MyCommand.Dispose(); MyConnection.Close(); } }
//PESTAÑA "NUEVO", OPCION PARA AGREGAR NUEVOS PEDIDOS private void agregarPedido_btn_Click_1(object sender, EventArgs e) // Hacer click en "Nuevo", hacer visible la tab pedidos y cargar los clientes existentes { DateTime today = DateTime.Today; tab_pedidos.Visible = true; tab_pedidos.SelectTab(0); comboBox_producto1.SelectedIndex = -1; textBox_cliente.Clear(); textBox_cantidad1.Clear(); cargar_productos(); folio_pedido(); MySqlConnection conexion = Conectar(); String sentencia = "SELECT nombre FROM clientes"; MySqlCommand comando = new MySqlCommand(sentencia, conexion); conexion.Open(); comando.ExecuteNonQuery(); MySqlDataReader MyReader; MyReader = comando.ExecuteReader(); while (MyReader.Read()) { autotext_clientes.Add(MyReader.GetString(0)); } textBox_cliente.AutoCompleteMode = AutoCompleteMode.SuggestAppend; textBox_cliente.AutoCompleteSource = AutoCompleteSource.CustomSource; textBox_cliente.AutoCompleteCustomSource = autotext_clientes; MyReader.Close(); conexion.Close(); }
public Internacao Buscar(string[] colunas, string[] valores) { try { using (MyConnection = new MySqlConnection(ConnectionString)) { MyConnection.Open(); using (MyCommand = new MySqlCommand(RawSelect("internacoes", colunas, valores), MyConnection)) { using (MyReader = MyCommand.ExecuteReader()) { if (MyReader.Read()) { return(new Content().Get(MyReader)); } else { return(null); } } } } } finally { MyConnection.Close(); MyCommand.Dispose(); MyReader.Close(); } }
// ***************************************************** PESTAÑA MODIFICAR PEDIDO ******************************************************************* private void pestañaModificarPedido_Btn_Click(object sender, EventArgs e) { tab_pedidos.Visible = true; tab_pedidos.SelectTab(1); textBox_buscarFolio.Clear(); cargar_productos(); MySqlConnection conexion = Conectar(); String sentencia = "SELECT nombre FROM clientes"; MySqlCommand comando = new MySqlCommand(sentencia, conexion); conexion.Open(); comando.ExecuteNonQuery(); MySqlDataReader MyReader; MyReader = comando.ExecuteReader(); while (MyReader.Read()) { autotext_clientes.Add(MyReader.GetString(0)); } textBox_clienteEncontrado.AutoCompleteMode = AutoCompleteMode.SuggestAppend; textBox_clienteEncontrado.AutoCompleteSource = AutoCompleteSource.CustomSource; textBox_clienteEncontrado.AutoCompleteCustomSource = autotext_clientes; MyReader.Close(); conexion.Close(); }
/// <summary> /// Borrar una Oferta /// </summary> /// <returns></returns> public bool BorrarOferta(Oferta unaOferta) { bool borrado = false; string sql = "delete from oferta where id=" + unaOferta.Id + ";"; MySqlCommand comandoInsert = new MySqlCommand(sql, conexion); MySqlDataReader MyReader; try { MyReader = comandoInsert.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader.Read()) { } MyReader.Close(); borrado = true; } catch (MySqlException ex) { switch (ex.Number) { case 1452: throw new Exception("No se puede borrar, no existe este idEmpresa en Empresa"); default: throw; } } return(borrado); }
public GameGuideItem GameGuideGetOne(int id) { var item = new GameGuideItem(); string sql = "SELECT * FROM [portal].[dbo].gameGuide WHERE id = @id"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); MyCommand.Parameters.AddWithValue("id", id); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { item = new GameGuideItem { id = MyReader.GetInt32(MyReader.GetOrdinal("id")), description = MyReader.GetString(MyReader.GetOrdinal("description")), game_id = MyReader.GetInt32(MyReader.GetOrdinal("game_id")), }; } MyReader.Close(); conn.Close(); return(item); }
private void comboboxDoctorName_SelectionChanged(object sender, SelectionChangedEventArgs e) { ///////Loading Doctor Department Value try { string Query = "select id,department from doctor where name='" + comboboxDoctorName.SelectedItem.ToString() + "';"; MySqlCommand MyCommand2 = new MySqlCommand(Query, conn); MySqlDataReader MyReader2; MyReader2 = MyCommand2.ExecuteReader(); while (MyReader2.Read()) { docId = MyReader2.GetString(0); docDept = MyReader2.GetString(1); textboxDoctorDept.Text = docDept; } MyReader2.Close(); string Query1 = "select department from doctor where name='" + comboboxDoctorName.SelectedItem.ToString() + "';"; MySqlCommand MyCommand = new MySqlCommand(Query, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); assd.IsEnabled = true; } catch { } }
public GameTextItem GetOne(int ID) { var item = new GameTextItem(); string sql = "SELECT * FROM [portal].[dbo].chuchaychay WHERE id = @id"; SqlConnection conn = new SqlConnection(Constants.DBConnection); SqlCommand MyCommand = new SqlCommand(sql, conn); MyCommand.Parameters.AddWithValue("id", ID); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { item = new GameTextItem { ID = MyReader.GetInt32(MyReader.GetOrdinal("id")), Title = MyReader.GetString(MyReader.GetOrdinal("Title")), Link = MyReader.GetString(MyReader.GetOrdinal("Link")), DataStart = MyReader.GetDateTime(MyReader.GetOrdinal("DataStart")), DateEnd = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")), IsDelete = MyReader.GetBoolean(MyReader.GetOrdinal("IsDelete")), Order = MyReader.GetInt32(MyReader.GetOrdinal("Orders")), }; } MyReader.Close(); conn.Close(); return(item); }
public List <ConfigMiniPokerItem> GetConfigXeng() { var rs = new List <ConfigMiniPokerItem>(); var sql = "SELECT top 1 * FROM [newDB].[dbo].configQuayXeng ORDER BY id DESC"; var conn = new SqlConnection(Constants.DBConnection); var MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { var u = new ConfigMiniPokerItem { Id = MyReader.GetInt32(MyReader.GetOrdinal("id")), a = MyReader.GetInt32(MyReader.GetOrdinal("a")), a1 = MyReader.GetInt32(MyReader.GetOrdinal("a1")), a2 = MyReader.GetInt32(MyReader.GetOrdinal("a2")), a3 = MyReader.GetInt32(MyReader.GetOrdinal("a3")), a4 = MyReader.GetInt32(MyReader.GetOrdinal("a4")), a5 = MyReader.GetInt32(MyReader.GetOrdinal("a5")), a6 = MyReader.GetInt32(MyReader.GetOrdinal("a6")) }; rs.Add(u); } MyReader.Close(); conn.Close(); return(rs); }
private void comboboxpatient_name_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { clear_data(); string sql = "SELECT patient_contact_no,patient_age,patient_blood_group,patient_address,time_of_admission,patient_sex,referred_by,patient_occupation,patient_id from hopedatabase.patient_data where patient_name='" + comboboxpatient_name.SelectedItem + "';"; MySqlCommand MyCommand = new MySqlCommand(sql, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { patient_contact_no.Text = MyReader.GetString(0).ToString(); patient_age.Text = MyReader.GetString(1).ToString(); patient_bloodgroup.Text = MyReader.GetString(2).ToString(); patient_address.Text = MyReader.GetString(3).ToString(); time_of_admission.Text = MyReader.GetString(4).ToString(); patient_sex.Text = MyReader.GetString(5).ToString(); referred_by.Text = MyReader.GetString(6).ToString(); patient_occupation.Text = MyReader.GetString(7).ToString(); selected_id = MyReader.GetString(8).ToString(); } MyReader.Close(); } catch (Exception eee) { MessageBox.Show(eee.Message.ToString()); } }
public ConfigMiniPokerItem GetConfigXengDetail(int id) { var rs = new ConfigMiniPokerItem(); var sql = "SELECT * FROM [newDB].[dbo].configQuayXeng where id = " + id; var conn = new SqlConnection(Constants.DBConnection); var MyCommand = new SqlCommand(sql, conn); SqlDataReader MyReader; conn.Open(); MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { rs = new ConfigMiniPokerItem { Id = MyReader.GetInt32(MyReader.GetOrdinal("id")), a = MyReader.GetInt32(MyReader.GetOrdinal("a")), a1 = MyReader.GetInt32(MyReader.GetOrdinal("a1")), a2 = MyReader.GetInt32(MyReader.GetOrdinal("a2")), a3 = MyReader.GetInt32(MyReader.GetOrdinal("a3")), a4 = MyReader.GetInt32(MyReader.GetOrdinal("a4")), a5 = MyReader.GetInt32(MyReader.GetOrdinal("a5")), a6 = MyReader.GetInt32(MyReader.GetOrdinal("a6")) }; } MyReader.Close(); conn.Close(); return(rs); }
public bool SelectById() { Command = MyCommand(@"Select Id,Name,Email,FatherName,MotherName, LocalGuardian,IdNumber,BloodGroup,AddressPresent, AddressPermanent,CityId,ProgramId from Student WHERE Id = @Id"); Command.Parameters.AddWithValue("@Id", Id); MyReader = ExecuteReader(Command); while (MyReader.Read()) { Name = MyReader["name"].ToString(); Email = MyReader["email"].ToString(); FatherName = MyReader["FatherName"].ToString(); MotherName = MyReader["MotherName"].ToString(); LocalGuardian = MyReader["dateOfBirth"].ToString(); IdNumber = MyReader["IdNumber"].ToString(); BloodGroup = MyReader["BloodGroup"].ToString(); AddressPresent = MyReader["AddressPresent"].ToString(); AddressPermanent = MyReader["AddressPermanent"].ToString(); Image = (byte[])MyReader["Image"]; CityId = Convert.ToInt32(MyReader["cityId"]); ProgramId = Convert.ToInt32(MyReader["ProgramId"]); return(true); } MyReader.Close(); return(false); }
private void btnAddTest_Click(object sender, RoutedEventArgs e) { if (txtTestName.Text.Equals("") || comboDiseaseType.Text.Equals("") || comboDiseaseName.Text.Equals("") || comboDiseaseName.Text.Equals("") || txtCost.Text.Equals("")) { MessageBox.Show("Please Fill All Fields"); } else { try { string Query = "insert into user.test_name values('" + txtTestName.Text + "','" + comboDiseaseType.SelectedItem.ToString() + "','" + comboDiseaseName.SelectedItem.ToString() + "','" + txtCost.Text + "');"; MySqlCommand MyCommand = new MySqlCommand(Query, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); MessageBox.Show("Test Added"); txtTestName.Text = ""; txtCost.Text = ""; table(); txtCost.Text = ""; txtTestName.Text = ""; comboDiseaseName.Items.Clear(); comboDiseaseType.Items.Clear(); load_combo_disease_typee(); } catch { } } }