private void button1_Click(object sender, EventArgs e) { EFTCard eftCard=new EFTCard(); eftCard.CardName=txtBoxItem.Text; List<EFTCard> eftcards = eftCardmanager.GetEftCards(); var existingEftCard = from card in eftcards where card.CardName == eftCard.CardName select card; if (existingEftCard.ToList().Count > 0) { MessageBox.Show("Item name already exists. Please try with another."); } else if (button1.Text=="Add") { eftCardmanager.InsertEftCard(eftCard); lodaData(); txtBoxItem.Clear(); } else if (button1.Text == "Update") { eftCard.Id = selectedEftCard.Id; eftCardmanager.UpdateEftCard(eftCard); lodaData(); txtBoxItem.Clear(); } button1.Text = "Add"; btnEdit.Text = "Edit"; }
public List<EFTCard> GetEftCards() { List<EFTCard> eftCards = new List<EFTCard>(); string sSql = SqlQueries.GetQuery(Query.GetEftCatds); try { this.OpenConnection(); IDataReader oReader = this.ExecuteReader(sSql); while (oReader.Read()) { EFTCard eftCard = new EFTCard(); eftCard.Id = Convert.ToInt32(oReader[0]); eftCard.CardName = oReader[1].ToString(); eftCards.Add(eftCard); } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in getEftCards()", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occured at getEftCards()", ex); } else { throw new Exception("Exception occure at getEftCards()", ex); } } finally { this.CloseConnection(); } return eftCards; }
public CResult DeleteEFTCard(EFTCard eftcard) { CResult tempResult = new CResult(); try { string deletSql = string.Format(SqlQueries.GetQuery(Query.DeleteEftCard), eftcard.CardName); this.ExecuteNonQuery(deletSql); this.CommitTransection(); tempResult.IsSuccess = true; } catch (Exception ex) { tempResult.IsException = true; this.RollBackTransection(); Console.Write("###" + ex + "###"); Logger.Write("Exception : " + ex + " in DeleteEftcard()", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occure at DeleteEftcard()", ex); } else { throw new Exception("Exception occure at DeleteEftcard()", ex); } } finally { this.CloseConnection(); } return tempResult; }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { selectedEftCard = (EFTCard)listBox1.SelectedItem; }
public bool UpdateEftCard(EFTCard eftCard) { CResult cResult = Database.Instance.GetEfTcard.UpdateEFTCardList(eftCard); return cResult.IsSuccess; }
public bool InsertEftCard(EFTCard eftCard) { CResult cResult= Database.Instance.GetEfTcard.InsertEFTCard(eftCard); return cResult.IsSuccess; }
public bool DeteleEftcard(EFTCard eftCard) { CResult cResult = Database.Instance.GetEfTcard.DeleteEFTCard(eftCard); return cResult.IsSuccess; }
private void saveEFTCardAgainsOrderid(EFTCard eftCard) { if (eFTCardManager.AllReadyExiste(orderID)) { eFTCardManager.UpdateEFTPaymentByOrderID(orderID, eftCard.Id, eftCard.CardName); } else { eFTCardManager.InsertEFTPayment(orderID, eftCard.Id, eftCard.CardName); } }