void Fillcombo_suppler() { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.suplier;"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(quarry, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string suName = MyReader.GetString("suplier_name"); cmb_b_m_suppler.Items.Add(suName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void FillcomboMaterial() { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.meterial;"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(quarry, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string mtName = MyReader.GetString("meterial_name"); com_metirial.Items.Add(mtName); string umtName = MyReader.GetString("meterial_name"); cmb_m_update.Items.Add(umtName); string dmtName = MyReader.GetString("meterial_name"); cmb_m_delete.Items.Add(dmtName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void Fillcombo_order_customers() { string con = "server=localhost;user id=root;password=;database=youken_springs"; string quarry = "select * from youken_springs.customers;"; MySqlConnection ConDataBase = new MySqlConnection(con); MySqlCommand cmdDataBase = new MySqlCommand(quarry, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string cuName = MyReader.GetString("customer_name"); cmb_inv_order_customer.Items.Add(cuName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cmb_m_delete_SelectedIndexChanged(object sender, EventArgs e) { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.meterial where meterial_name ='" + cmb_m_delete.Text + "';"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(quarry, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string dmid = MyReader.GetInt32("meterial_id").ToString(); lbl_m_d_id.Text = dmid; string dmtName = MyReader.GetString("meterial_name"); lbl_m_name_delete.Text = dmtName; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Messege", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// ***************************************************** 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(); }
private void cmb_inv_order_customer_SelectedIndexChanged(object sender, EventArgs e) { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.customers where customer_name ='" + cmb_inv_order_customer.Text + "';"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(query, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { custormer_id = MyReader.GetString("cus_id"); } ConDataBase.Close(); lbl_rs.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Messege", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//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(); }
private void cmb_Product_SelectedIndexChanged(object sender, EventArgs e) { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.products where name ='" + cmb_Product.Text + "';"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(query, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { product_id = MyReader.GetString("product_id"); product_uprice = MyReader.GetInt32("unit_price").ToString(); // txt_p_custemer.Text = product_uprice; } ConDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Messege", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void BtnUpdate_Click(object sender, EventArgs e) { try { MySqlConnection conn = new MySqlConnection(connectionString); String s1 = Request.QueryString[0]; String insert1 = "Update Users SET TYPE=@TYPE,OID=@OID,USER=@USER, PWD=@PWD,FULLNAME=@FULLNAME,EMAIL=@EMAIL,MOBILE=@MOBILE,ACTIVE=@ACTIVE,NOTE=@NOTE WHERE uid =@UID"; MySqlCommand command = new MySqlCommand(insert1, conn); command.Parameters.AddWithValue("@TYPE", TbType.SelectedValue); command.Parameters.AddWithValue("@OID", TbOffice.SelectedValue); command.Parameters.AddWithValue("@USER", TbUsername.Text); command.Parameters.AddWithValue("@PWD", TbPassword.Text); command.Parameters.AddWithValue("@FULLNAME", TbFullNAME.Text); command.Parameters.AddWithValue("@EMAIL", TbEmail.Text); command.Parameters.AddWithValue("@MOBILE", TbMobile.Text); command.Parameters.AddWithValue("@ACTIVE", TbActive.SelectedValue); command.Parameters.AddWithValue("@NOTE", Tbtxtuser.Text); command.Parameters.AddWithValue("@UID", s1); MySqlDataReader MyReader; conn.Open(); MyReader = command.ExecuteReader(); while (MyReader.Read()) { } conn.Close(); LblError.Attributes.CssStyle.Add("color", "green"); LblError.Text = "تم التحديث بنجاح"; } catch (Exception ex) { LblError.Text = ex.Message; } }
void FillcomboProduct() { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.products;"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(quarry, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string pdName1 = MyReader.GetString("name"); cmb_product_name1.Items.Add(pdName1); string pdName2 = MyReader.GetString("name"); cmb_product_name2.Items.Add(pdName2); string pdName3 = MyReader.GetString("name"); cmb_product_name3.Items.Add(pdName3); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//**************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(); }
public bool selectById() { MyCommand = CommandBuilder(@"select id, name, contact, email, password, gender, dateOfBirth, address, cityId, createDate, image, type from ledger where id = @id"); MyCommand.Parameters.AddWithValue("@id", Id); MyReader = ExecuteReader(MyCommand); while (MyReader.Read()) { Name = MyReader["name"].ToString(); Contact = MyReader["contact"].ToString(); Email = MyReader["email"].ToString(); Password = MyReader["password"].ToString(); Gender = Convert.ToInt32(MyReader["gender"]); DateOfBirth = Convert.ToDateTime(MyReader["dateOfBirth"]); Address = MyReader["address"].ToString(); CityId = Convert.ToInt32(MyReader["cityId"]); CreateDate = Convert.ToDateTime(MyReader["createDate"]); try { Image = (byte[])MyReader["image"]; } catch { } Type = MyReader["type"].ToString(); return(true); } return(false); }
/// <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); } }
private void cmb_b_m_suppler_SelectedIndexChanged(object sender, EventArgs e) { string Constring = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.suplier where suplier_name='" + cmb_b_m_suppler.Text + "';"; MySqlConnection ConDataBase = new MySqlConnection(Constring); MySqlCommand cmdDataBase = new MySqlCommand(quarry, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string suName = MyReader.GetString("suplier_name"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Messege", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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; }
/// <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); }
////////////////////////////////////////////////////////////order/////////////////////////////////////// void FillComboOrders() { string con = "datasource=localhost;port=3306;username=root;password="******"select * from youken_springs.products;"; MySqlConnection ConDataBase = new MySqlConnection(con); MySqlCommand cmdDataBase = new MySqlCommand(query, ConDataBase); MySqlDataReader MyReader; try { ConDataBase.Open(); MyReader = cmdDataBase.ExecuteReader(); while (MyReader.Read()) { string prname = MyReader.GetString("name"); cmb_Product.Items.Add(prname); } ConDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void panel5_MouseClick(object sender, MouseEventArgs e) { string kon1 = "server=localhost;database=aplikasispp;uid=root;pwd='';"; MySqlConnection k = new MySqlConnection(kon1); k.Open(); string query = "DELETE FROM spp where id_spp ='" + this.id_spp.Text + "';"; MySqlCommand MyCommand = new MySqlCommand(query, k); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); DialogResult dialog = MessageBox.Show("Apakah benar ingin di hapus?", "Hapus", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { MessageBox.Show("Data Berhasil di Hapus"); while (MyReader.Read()) { } id_spp.Text = ""; tahun.Text = ""; bulan.Text = ""; nominal.Text = ""; k.Close(); tampilandatagrid(); } }
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 SubmitButton_Enter(object sender, EventArgs e) { SqlConnection cnn; cnn = new SqlConnection("Server=.\\SQLEXPRESS;Database=DTMS; Integrated Security=true"); String Query = "insert into teacher (teacher_id,teacher_name,teacher_dept,teacher_designation,contact_number) values ('" + this.TeacherIdTextBox.Text + "','" + this.TeacherNameTextBox.Text + "', '" + this.TeacherDeptComboBox.Text + "','" + this.TeacherDesignationomboBox.Text + "','" + this.ContactTextBox.Text + "');"; SqlCommand cmd = new SqlCommand(Query, cnn); SqlDataReader MyReader; //if (ContactTextBox.TextLength < 11) // MessageBox.Show(" Contact Number can not be less than 11 digit"); //else //{ try { cnn.Open(); MyReader = cmd.ExecuteReader(); //MessageBox.Show("Saved", "Result", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand); MessageBox.Show("saved"); while (MyReader.Read()) { } } catch (Exception ex) { MessageBox.Show(ex.Message); } //} }
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()); } }
/// <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 bool SelectById() { MyCommand = CommandBuilder("SELECT id, name, email, contact, password, gender, dateOfBirth, userType, joinDate, joinIp, address, cityId FROM users WHERE id=@id"); MyCommand.Parameters.AddWithValue("@id", Id); MyReader = ExecuteReader(MyCommand); while (MyReader.Read()) { Id = Convert.ToInt32(MyReader["id"]); Name = MyReader["name"].ToString(); Email = MyReader["email"].ToString(); Contact = MyReader["contact"].ToString(); Password = MyReader["password"].ToString(); Gender = MyReader["gender"].ToString(); DateOfBirth = Convert.ToDateTime(MyReader["dateOfBirth"]); UserType = MyReader["userType"].ToString(); JoinDate = Convert.ToDateTime(MyReader["joinDate"].ToString()); JoinIp = MyReader["joinIp"].ToString(); Address = MyReader["address"].ToString(); CityId = Convert.ToInt32(MyReader["cityId"].ToString()); return(true); } return(false); }
public bool SelectByOthers() { MyCommand = CommandBuilder("SELECT id, name, email, contact, password, gender, dateOfBirth, userType, joinDate, joinIp, address, cityId FROM users where id>0"); if (Email != null && Email != "") { MyCommand.CommandText += " and email=@email "; MyCommand.Parameters.AddWithValue("@email", Email); } if (Password != null && Password != "") { MyCommand.CommandText += " and password = @password"; MyCommand.Parameters.AddWithValue("@password", Password); } MyReader = ExecuteReader(MyCommand); while (MyReader.Read()) { Id = Convert.ToInt32(MyReader["id"]); Name = MyReader["name"].ToString(); Email = MyReader["email"].ToString(); Password = MyReader["password"].ToString(); Gender = MyReader["gender"].ToString(); DateOfBirth = Convert.ToDateTime(MyReader["dateOfBirth"]); UserType = MyReader["userType"].ToString(); JoinDate = Convert.ToDateTime(MyReader["joinDate"]); JoinIp = MyReader["joinIp"].ToString(); Address = MyReader["address"].ToString(); CityId = Convert.ToInt32(MyReader["cityId"]); return(true); } return(false); }
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); }
/// <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); }
/*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); }
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); }
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); }
private void button3_Click(object sender, EventArgs e) { string grupch = "update urun set grup='" + textBox4.Text + "'where id ='" + textBox1.Text + "' "; bagla.Open(); SqlCommand ch = new SqlCommand(grupch, bagla); SqlDataReader MyReader; try { MyReader = ch.ExecuteReader(); MessageBox.Show("Ürün Grubu Güncellendi"); while (MyReader.Read()) { } bagla.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } bagla.Open(); SqlDataAdapter urun = new SqlDataAdapter("select * from urun", bagla); DataTable tablo = new DataTable(); urun.Fill(tablo); string[] row = new string[] { "'" + tablo.Rows[0][1].ToString() + "'", "" + tablo.Rows[0][2].ToString() + "", "" + tablo.Rows[0][3].ToString() + "", "" + tablo.Rows[0][4].ToString() + "", "" + tablo.Rows[0][5].ToString() + "" }; dataGridView1.DataSource = tablo; bagla.Close(); }
public void RunAsync() { var myReader = new MyReader(); myReader.Reading += MyReader_Reading; Action worker = () => myReader.Read(); Action<IAsyncResult> callback = asyncResult => { var inlineAsyncResult = (AsyncResult)asyncResult; var inlineWorker = (Action)inlineAsyncResult.AsyncDelegate; inlineWorker.EndInvoke(asyncResult); }; var asyncCallback = new AsyncCallback(callback); var asyncOperation = AsyncOperationManager.CreateOperation(new object { }); worker.BeginInvoke(asyncCallback, asyncOperation); }
public void RunAsync() { var reader = new MyReader(); reader.Reading += OnRead; Action worker = () => reader.Read(); Action<IAsyncResult> callback = asyncResult => { var asyncResult2 = (AsyncResult)asyncResult; var inlineWorker = asyncResult2.AsyncDelegate as Action; inlineWorker.EndInvoke(asyncResult); }; var asyncOperation = AsyncOperationManager.CreateOperation(new object()); var asyncCallback = new AsyncCallback(callback); worker.BeginInvoke(asyncCallback, asyncOperation); }