private void initCardButton_Click(object sender, RoutedEventArgs e) { using (SmartCardTransaction scT = new SmartCardTransaction(this.smartCard.device)) { string puk; try { String pin = "1234"; KeyPair pq = new KeyPair(p, q); puk = this.smartCard.InitDevice(pq, pin); } catch (ErrorCode ex) { String msg = String.Format("Could not INITIALIZE DEVICE. error code: {0} {1}", ex.SW1, ex.SW2); System.Windows.MessageBox.Show(msg); } } this.CleanAndClose(); }
private void virginMode_Click(object sender, RoutedEventArgs e) { using (SmartCardTransaction scT = new SmartCardTransaction(this.device.device)) { try { device.SetVirginMode(); } catch (ErrorCode ex) { String msg = String.Format("Could not set card in virgin mode: {0}{X2} {1}{X2} in commando {3}", ex.SW1, ex.SW2, ex.Command); System.Windows.MessageBox.Show(msg); } catch (Exception ex) { String msg = String.Format("Could not set card in virgin mode: {0}", ex.Message); System.Windows.MessageBox.Show(msg); } this.Close(); } }
public static List <SmartCardTransaction> GetSmartCardTransactions(Filters filter) { SqlConnection myConnection = null; List <SmartCardTransaction> result = new List <SmartCardTransaction>(); SmartCardTransaction trans = null; DataTable dt = new DataTable(); try { using (myConnection = GetConnection(GetConnectionString(Helper.Configuration.CONNECTION_KEY))) { myConnection.Open(); SqlCommand cmd = new SqlCommand("EbusSmartCardTrans", myConnection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@smartCardNumBi", Convert.ToInt64(filter.SerialNumber).ToString("X")); cmd.Parameters.AddWithValue("@smartCardNumLi", ToLittleHex(Convert.ToInt64(filter.SerialNumber).ToString("X"))); cmd.Parameters.AddWithValue("@fromDate", ConvertStringToDateSaFormat(filter.FromDate).ToString("yyyy-MM-dd")); cmd.Parameters.AddWithValue("@toDate", ConvertStringToDateSaFormat(filter.ToDate).ToString("yyyy-MM-dd")); cmd.CommandTimeout = 500000; //SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); //while (dr.Read()) //{ foreach (DataRow dr in dt.Rows) { trans = new SmartCardTransaction(); if (dr["ClassID"] != null && dr["ClassID"].ToString() != string.Empty) { trans.ClassID = Convert.ToInt32(dr["ClassID"].ToString()); } if (dr["ClassName"] != null && dr["ClassName"].ToString() != string.Empty) { trans.ClassName = dr["ClassName"].ToString(); } if (dr["NonRevenue"] != null && dr["NonRevenue"].ToString() != string.Empty) { trans.NonRevenue = dr["NonRevenue"].ToString(); } if (dr["Revenue"] != null && dr["Revenue"].ToString() != string.Empty) { trans.Revenue = dr["Revenue"].ToString(); } if (dr["TransTime"] != null && dr["TransTime"].ToString() != string.Empty) { trans.TransDate = DateTime.Parse(dr["TransTime"].ToString()); trans.TDate = trans.TransDate.ToString("dd/MM/yyyy"); trans.TTime = trans.TransDate.ToString("hh:mm tt"); } if (dr["SerialNumber"] != null && dr["SerialNumber"].ToString() != string.Empty) { trans.SerialNumber = dr["SerialNumber"].ToString(); } if (dr["SerialNumberHex"] != null && dr["SerialNumberHex"].ToString() != string.Empty) { trans.SerialNumberHex = dr["SerialNumberHex"].ToString(); } if (dr["RouteID"] != null && dr["RouteID"].ToString() != string.Empty) { trans.RouteID = dr["RouteID"].ToString(); } if (dr["JourneyID"] != null && dr["JourneyID"].ToString() != string.Empty) { trans.JourneyID = dr["JourneyID"].ToString(); } if (dr["OperatorID"] != null && dr["OperatorID"].ToString() != string.Empty) { trans.OperatorID = dr["OperatorID"].ToString(); } if (dr["OperatorName"] != null && dr["OperatorName"].ToString() != string.Empty) { trans.OperatorName = dr["OperatorName"].ToString(); } if (dr["ETMID"] != null && dr["ETMID"].ToString() != string.Empty) { trans.ETMID = dr["ETMID"].ToString(); } if (dr["BusID"] != null && dr["BusID"].ToString() != string.Empty) { trans.BusID = dr["BusID"].ToString(); } if (dr["DutyID"] != null && dr["DutyID"].ToString() != string.Empty) { trans.DutyID = dr["DutyID"].ToString(); } if (dr["ModuleID"] != null && dr["ModuleID"].ToString() != string.Empty) { trans.ModuleID = dr["ModuleID"].ToString(); } if (dr["RevenueBalance"] != null && dr["RevenueBalance"].ToString() != string.Empty) { trans.RevenueBalance = dr["RevenueBalance"].ToString(); } if (dr["TransDay"] != null && dr["TransDay"].ToString() != string.Empty) { trans.TransDay = dr["TransDay"].ToString(); } if (dr["AmountRecharged"] != null && dr["AmountRecharged"].ToString() != string.Empty) { trans.AmountRecharged = dr["AmountRecharged"].ToString(); } if (dr["TripsRecharged"] != null && dr["TripsRecharged"].ToString() != string.Empty) { trans.TripsRecharged = dr["TripsRecharged"].ToString(); } result.Add(trans); } } } catch (Exception) { throw; } finally { myConnection.Close(); } return(result); }