public static List <DBPostpaidBillTransaction> GetDataByWalletStatus(string wallet, DateTime past, DateTime present) { List <DBPostpaidBillTransaction> data = new List <DBPostpaidBillTransaction>(); MySqlConnection con = DBConnection.ConnectDatabase(); try { // AND MySqlCommand cmd = new MySqlCommand("SELECT * FROM " + tablename + " WHERE (date BETWEEN '" + past.ToString("yyyy-MM-dd") + " 0:0:0" + "' AND '" + present.ToString("yyyy-MM-dd") + " 23:59:59" + "') AND wallet_id ='" + wallet + "' AND (status='Paid' OR status='Pending')", con); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DBPostpaidBillTransaction rawData = new DBPostpaidBillTransaction(); rawData.Id = reader.GetInt32(0); rawData.Date = reader.GetDateTime(1); rawData.BillsCode = reader.GetString(2); rawData.Parameter1 = reader.GetString(3); rawData.Parameter2 = reader.GetString(4); rawData.Amount = reader.GetFloat(5); rawData.Convenience_fee = reader.GetFloat(6); rawData.Wallet_Id = reader.GetString(7); rawData.Ecpaytrackingno = reader.GetString(8); rawData.Customer_Fullname = reader.GetString(9); rawData.Total = reader.GetFloat(10); rawData.Status = reader.GetString(11); rawData.Customer_Number = reader.GetString(12); data.Add(rawData); } } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } return(data); }
public static List <DBPostpaidBillTransaction> GetData() { List <DBPostpaidBillTransaction> data = new List <DBPostpaidBillTransaction>(); MySqlConnection con = DBConnection.ConnectDatabase(); try { MySqlCommand cmd = new MySqlCommand("SELECT * FROM " + tablename + " ORDER BY id DESC", con); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DBPostpaidBillTransaction rawData = new DBPostpaidBillTransaction(); rawData.Id = reader.GetInt32(0); rawData.Date = reader.GetDateTime(1); rawData.BillsCode = reader.GetString(2); rawData.Parameter1 = reader.GetString(3); rawData.Parameter2 = reader.GetString(4); rawData.Amount = reader.GetFloat(5); rawData.Convenience_fee = reader.GetFloat(6); rawData.Wallet_Id = reader.GetString(7); rawData.Ecpaytrackingno = reader.GetString(8); rawData.Customer_Fullname = reader.GetString(9); rawData.Total = reader.GetFloat(10); rawData.Status = reader.GetString(11); rawData.Customer_Number = reader.GetString(12); data.Add(rawData); } } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } return(data); }
public static DBPostpaidBillTransaction GetDataSendingStatus(string s) { DBPostpaidBillTransaction data = null; MySqlConnection con = DBConnection.ConnectDatabase(); try { MySqlCommand cmd = new MySqlCommand("SELECT * FROM " + tablename + " WHERE id=(SELECT MIN(id) from " + tablename + " WHERE status='" + s + "')", con); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); data.Id = reader.GetInt32(0); data.Date = reader.GetDateTime(1); data.BillsCode = reader.GetString(2); data.Parameter1 = reader.GetString(3); data.Parameter2 = reader.GetString(4); data.Amount = reader.GetFloat(5); data.Convenience_fee = reader.GetFloat(6); data.Wallet_Id = reader.GetString(7); data.Ecpaytrackingno = reader.GetString(8); data.Customer_Fullname = reader.GetString(9); data.Total = reader.GetFloat(10); data.Status = reader.GetString(11); data.Customer_Number = reader.GetString(12); } reader.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show(ex.ToString()); } finally { con.Close(); } return(data); }