public void saveNewCharge() { chargeDao = new LaundryChargeDao(); LaundryChargeDataEntity charge = new LaundryChargeDataEntity(); charge.Name = "Pickup"; charge.Amount = 10.00M; chargeDao.SaveOrUpdate(charge); charge = new LaundryChargeDataEntity(); charge.Name = "Deliver"; charge.Amount = 20.00M; chargeDao.SaveOrUpdate(charge); }
public void Delete(LaundryChargeDataEntity p_charge) { using(var session = NHibernateHelper.OpenSession()) { using(var transaction = session.BeginTransaction()) { try { session.Delete(p_charge); transaction.Commit(); } catch(Exception ex) { transaction.Rollback(); throw ex; } } } }
private List<LaundryChargeDataEntity> GetChargesDataValueChange(List<int> rowIndexChange, out string errorMessage) { List<LaundryChargeDataEntity> charges = new List<LaundryChargeDataEntity>(); LaundryChargeDataEntity charge = null; LaundryChargeDataEntity newCharge = null; List<string> updateCharges = new List<string>(); string errorMsg = string.Empty; string name = string.Empty; decimal price = 0; bool isNameExists = true; foreach(int rowIndex in rowIndexChange) { charge = new LaundryChargeDataEntity(); newCharge = new LaundryChargeDataEntity(); name = dgvCharges.Rows[rowIndex].Cells["Name"].Value.ToString().Trim(); price = Convert.ToDecimal(dgvCharges.Rows[rowIndex].Cells["Amount"].Value.ToString()); newCharge = m_chargesEntity.Find(chargesEntity => chargesEntity.Name.ToUpper() == name.ToUpper()); if(newCharge == null || newCharge.ChargeID == 0) isNameExists = false; if(rowIndex < chargesMaxRowIndex) { int chargeID = (int)dgvCharges.Rows[rowIndex].Cells["ChargeID"].Value; charge = m_chargesEntity.Find(chargesEntity => chargesEntity.ChargeID == chargeID); if(charge.Name.ToUpper().Equals(name.ToUpper())) { charge.Name = name; charge.Amount = price; charges.Add(charge); } else if(!charge.Name.ToUpper().Equals(name.ToUpper()) && !isNameExists && !updateCharges.Contains(name.ToUpper())) { charge.Name = name; charge.Amount = price; charges.Add(charge); updateCharges.Add(charge.Name.ToUpper()); } else { errorMsg += name + " , "; } } else { if(!isNameExists && !updateCharges.Contains(name.ToUpper())) { charge.Name = name; charge.Amount = price; updateCharges.Add(charge.Name.ToUpper()); charges.Add(charge); } else { errorMsg += name + ", "; } } } errorMessage = errorMsg; return charges; }