Ejemplo n.º 1
0
        /// <summary>
        /// Maps Grade EF object to Grade Model Object and
        /// returns the Grade model object.
        /// </summary>
        /// <param name="result">EF Grade object to be mapped.</param>
        /// <returns>Grade Model Object.</returns>
        public Grade MapEFToModel(EF.Models.Grade data)
        {
            var grade = new Grade()
            {
                GradeId   = data.GradeId,
                Value     = data.Value,
                CreatedOn = data.CreatedOn,
                TimeStamp = data.TimeStamp,
                Deleted   = data.Deleted,
                CreatedBy = _userService.GetUserFullName(data.AspNetUser),
                UpdatedBy = _userService.GetUserFullName(data.AspNetUser1),
            };
            List <Denomination> denominations = new List <Denomination>();

            var sizes = GetAllSizes();

            foreach (var size in sizes)
            {
                var denomination = new Denomination()
                {
                    DenominationId = size.SizeId,
                    Value          = size.Value,
                    Quantity       = 0
                };
                denominations.Add(denomination);
            }

            grade.Denominations = denominations;
            return(grade);
        }
Ejemplo n.º 2
0
		public Denomination ComputeChange(int totalCents, Func<IList<Denomination>, Denomination> reducer) 
		{
			if(totalCents < 0)
				throw new ArgumentOutOfRangeException("totalCents");
			if (_dict.ContainsKey(totalCents))
				return _dict[totalCents];
			else if (totalCents > 0)
			{
				var temp = new List<Denomination>();
				foreach (var c in Configuration.CoinTypes.Keys)
				{
					if (totalCents >= c)
					{
						var results = ComputeChange(totalCents - c, reducer);
						var coinKey = results.TotalCoins + 1;
						var coinList = new List<int>(results.Coins) { c };

						var r = new Denomination(coinKey, coinList.ToArray());
						temp.Add(r);
					}

				}
				//_dict.Add(totalCents, temp.MinBy(x => x.TotalCoins));
				_dict.Add(totalCents, reducer(temp));
				return _dict[totalCents];
			}
			else
			{
				return new Denomination(0, new int[] { });
			}
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, Denomination denomination)
        {
            if (id != denomination.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    denomination.User_Id = User.Identity.Name;
                    _context.Update(denomination);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DenominationExists(denomination.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Terminal_Id"] = new SelectList(_context.Terminal, "Id", "Name", denomination.Terminal_Id);
            return(View(denomination));
        }
        public Denomination Calculate()
        {
            base.Validate(RequireAmount);

            var denominationWithdrawn = new Denomination()
            {
                DenominationValue = DenominationToProcess, Value = DenominationToProcess
            };

            IDenominationLogic logic = new DenominationLogic();

            var denominations            = logic.GetDenominationValue();
            var denominationBeingProcess = denominations.Where(x => x.DenominationValue == DenominationToProcess).SingleOrDefault();
            var quantity = (int)(RequireAmount / DenominationToProcess);

            // make sure we have enough notes
            if (quantity > denominationBeingProcess.Quantity)
            {
                quantity = denominationBeingProcess.Quantity;
            }
            if (quantity > 0)
            {
                // dispense the denomination
                denominationWithdrawn.Quantity = quantity;
                logic.UpdateDenomination(DenominationToProcess, -quantity);
            }

            return(denominationWithdrawn);
        }
Ejemplo n.º 5
0
 public void CoinToStringTest()
 {
     foreach (Denomination d in Denomination.GetValues(typeof(Denomination)))
     {
         Assert.AreEqual(new Coin(d).ToString().ToUpper(), d.ToString());
     }
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,ApplicationUserId,Name,YearFounded,BankName,Logo,LogoBlobName")] Denomination denomination)
        {
            if (id != denomination.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(denomination);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DenominationExists(denomination.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationUserId"] = new SelectList(_context.Users, "Id", "Id", denomination.ApplicationUserId);
            return(View(denomination));
        }
Ejemplo n.º 7
0
        public JsonResult AddDenomination(RupeeDetails rupeeDetails, string UserID)
        {
            Common            common       = new Common();
            Studio365Entities Entity       = new Studio365Entities();
            ResponseData      responseData = new ResponseData()
            {
                Message    = common.SuccessMessage,
                ReturnType = common.ReturnTypeMessage
            };

            try
            {
                int denominationCount = (from d in Entity.Denominations where d.Date == DateTime.Now select d).Count();
                if (denominationCount == 0)
                {
                    Denomination denomination = new Denomination()
                    {
                        RupeeCounts = JsonConvert.SerializeObject(rupeeDetails),
                        userID      = UserID,
                        Date        = DateTime.Now
                    };
                    Entity.Denominations.Add(denomination);
                    Entity.SaveChanges();
                }
                else
                {
                    responseData.Message = common.duplicateDenomination;
                }
            }
            catch (Exception ex)
            {
                responseData.Message = ex.Message.ToString();
            }
            return(Json(responseData, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
    protected void gvDenom_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow gvRow   = (GridViewRow)((Button)e.CommandSource).NamingContainer;
        SPType      oSPType = (SPType)Session[Constants.SES_SPTYPE];

        if (((Button)e.CommandSource).Text.Equals("Select"))
        {
            txtDenomination.Enabled = false;
            txtSeries.Enabled       = false;
            LoadDenomDetailData(gvRow.Cells[2].Text.Trim());
        }
        else if (((Button)e.CommandSource).Text.Equals("Delete"))
        {
            if (oSPType.ListOfDenomination.Denomination.Count > 0)
            {
                hdSPTypeID.Value = gvRow.Cells[2].Text.Trim();
                hdDenomID.Value  = gvRow.Cells[3].Text.Trim();
                Denomination oDenomination = oSPType.ListOfDenomination.Denomination.Where(d => d.DenominationID.Equals(Convert.ToInt32(hdDenomID.Value))).SingleOrDefault();
                if (oDenomination != null)
                {
                    oSPType.ListOfDenomination.Denomination.Remove(oDenomination);
                }
                Session[Constants.SES_SPTYPE] = oSPType;
                ReloadDenomTmpListFromSession();
                ResetDenom();
            }
        }
    }
Ejemplo n.º 9
0
        public ActionResult Settled(Denomination obj)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var result = iSettlement.Settle(obj);
                    return(Json(new
                    {
                        ErrorCode = result.ErrorCode,
                        Message = result.Msg,
                        Id = result.Id,
                        JsonRequestBehavior.AllowGet
                    }));
                }
                catch (Exception ex)
                {
                    return(Json(new { ErrorCode = 1, Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }

            Response.TrySkipIisCustomErrors = true;
            string messages = string.Join("; ", ModelState.Values
                                          .SelectMany(x => x.Errors)
                                          .Select(x => x.ErrorMessage));

            return(Json(new { ErrorCode = 1, Message = messages }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        public List <Denomination> GiveChange()
        {
            List <Denomination> change = new List <Denomination>();

            while (m_InsertedMoney > 0)
            {
                int          currentValue;
                int          previouseValue = 0;
                Denomination value          = null;

                foreach (Denomination item in Currency.GetCurrencyDenominations())
                {
                    currentValue = (int)m_InsertedMoney / item.Value;
                    if (currentValue < previouseValue && currentValue > 0 || previouseValue == 0)
                    {
                        previouseValue = currentValue;
                        value          = item;
                    }
                }
                m_InsertedMoney -= value.Value;
                change.Add(value);
            }

            return(change);
        }
Ejemplo n.º 11
0
    private void LoadDenomDetailData(string sTypeID, string sDenomID, SPTypeList spList)
    {
        if (spList != null)
        {
            if (spList.ListOfSPType.Count > 0)
            {
                SPType oSpType = null;
                for (int i = 0; i < spList.ListOfSPType.Count; i++)
                {
                    oSpType = (SPType)spList.ListOfSPType[i];
                    if (sTypeID.Equals(oSpType.SPTypeID.Trim()))
                    {
                        for (int j = 0; j < oSpType.ListOfDenomination.Denomination.Count; j++)
                        {
                            Denomination oDenomination = oSpType.ListOfDenomination.Denomination[j];
                            if (oDenomination.DenominationID == Convert.ToInt32(sDenomID))
                            {
                                txtDenomination.Text      = oDenomination.DenominationID.ToString();
                                txtReOrderLevel.Text      = oDenomination.ReOrderLevel.ToString().Trim();
                                txtSeries.Text            = oDenomination.Series.ToString().Trim();
                                txtNoOfDigitInSeries.Text = oDenomination.NoOfDigitsInSeries.ToString().Trim();

                                //ucUserDet.UserDetail = oDenomination.UserDetail;

                                hdDenomID.Value = oDenomination.DenominationID.ToString();
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
        public List <Denomination> ShowDenomination()
        {
            SqlCommand com = new SqlCommand(GetAllDenomination, con);

            com.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter(com);
            DataTable      ds = new DataTable();

            da.Fill(ds);
            List <Denomination> data = new List <Denomination>();

            foreach (DataRow item in ds.Rows)
            {
                Denomination record = new Denomination();
                record.ID = item["ID_Denomination"] != null?Int32.Parse(item["ID_Denomination"].ToString()) : 0;

                record.Price = item["Price"] != null?Int32.Parse(item["Price"].ToString()) : 0;

                record.Status = !string.IsNullOrEmpty(item["Status"].ToString()) ? (Int32.Parse(item["Status"].ToString()) == 1 ? "On" : "Off") : "";

                data.Add(record);
            }
            return(data);
        }
Ejemplo n.º 13
0
        public void MoneyExchanger_GetDenominations_Amount1Euro_1EuroDenomination()
        {
            var moneyExchanger = new MoneyExchanger();
            var denominations = moneyExchanger.GetDenominations(1);

            var denomination = new Denomination(Currency.Euro, 1000);
            Assert.IsTrue(denominations.Count == 1 && denominations.ContainsKey(denomination) && denominations[denomination] == 1);
        }
        public ActionResult Update()
        {
            var          id   = Int32.Parse(Request["id"]);
            Denomination data = db.FinDenomination(id);

            ViewBag.data = data;
            return(View());
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            Denomination denomination = db.Denominations.Find(id);

            db.Denominations.Remove(denomination);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        private void InitialUISetup()
        {
            cbSize.DataSource   = Enum.GetValues(typeof(CoffeeSize));
            cbAmount.DataSource = Denomination.GetAll();

            ClearOrder();
            UpdateCurrentPayment();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Constructs a new instance of this object
        /// </summary>
        /// <param name="actualCashCalculatorViewModel"></param>
        /// <param name="currency"></param>
        public ActualCashDenominationViewModel(ActualCashCurrencyViewModel parent
                                               , Denomination denom)
        {
            Parent  = parent;
            m_denom = denom;

            LoadFromSummary(Parent.Parent.Summary);
        }
Ejemplo n.º 18
0
        public void ToString_CanReceiveCustomFormatsAndProviders()
        {
            var pointTwo = new Denomination(.2m);
            var snailDecimalSeparator = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();

            snailDecimalSeparator.NumberDecimalSeparator = "@";

            Assert.That(pointTwo.ToString(".000", snailDecimalSeparator), Is.EqualTo("@200"));
        }
        public Denomination CounterSettlement(string userId, DateTime date)
        {
            SqlParameter[] param = { new SqlParameter("@flag", SqlDbType.VarChar,                         50)
                                     {
                                         Value = "s"
                                     }
                                     ,                         new SqlParameter("@Date",   SqlDbType.Date)
                                     {
                                         Value = date
                                     }
                                     ,                         new SqlParameter("@UserId", SqlDbType.NVarChar, 128)
                                     {
                                         Value = userId
                                     } };
            var            result = SqlHelper.ExecuteDataSet("spCounterSettlement", param);
            Denomination   obj    = new Denomination();

            if (result.Tables.Count == 2)
            {
                DataTable tbl = result.Tables[0];

                if (result.Tables[1].Rows.Count > 0)
                {
                    DataRow tbl1 = result.Tables[1].Rows[0];

                    obj.Id                = Convert.ToInt32(tbl1["Id"]);
                    obj.Rs1000            = Convert.ToDecimal(tbl1["Rs1000"]);
                    obj.Rs500             = Convert.ToDecimal(tbl1["Rs500"]);
                    obj.Rs100             = Convert.ToDecimal(tbl1["Rs100"]);
                    obj.Rs50              = Convert.ToDecimal(tbl1["Rs50"]);
                    obj.Rs20              = Convert.ToDecimal(tbl1["Rs20"]);
                    obj.Rs10              = Convert.ToDecimal(tbl1["Rs10"]);
                    obj.Rs5               = Convert.ToDecimal(tbl1["Rs5"]);
                    obj.Coins             = Convert.ToDecimal(tbl1["Coins"]);
                    obj.IC                = Convert.ToDecimal(tbl1["IC"]);
                    obj.SettlementRequest = Convert.ToString(tbl1["SettlementRequest"]);
                    obj.Impression        = Convert.ToString(tbl1["Impression"]);
                    //obj.SettledBy = Convert.ToString(tbl["SettledBy"]);
                    obj.Remarks = Convert.ToString(tbl1["Remarks"]);
                    obj.Status  = Convert.ToInt32(tbl1["Status"]);

                    List <DenominationGraph> list = new List <DenominationGraph>();
                    foreach (DataRow dr in tbl.Rows)
                    {
                        DenominationGraph obj1 = new DenominationGraph();

                        obj1.PaymentMode = dr["PaymentMode"].ToString();
                        obj1.GrandTotal  = Convert.ToDecimal(dr["GrandTotal"]);

                        list.Add(obj1);
                    }
                    obj.GraphList = list;
                }
            }
            return(obj);
        }
 public ActionResult Edit([Bind(Include = "ID,Type")] Denomination denomination)
 {
     if (ModelState.IsValid)
     {
         db.Entry(denomination).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(denomination));
 }
Ejemplo n.º 21
0
    private void SetSPType(SPType oSpType)
    {
        txtSpTypeId.Text    = oSpType.SPTypeID.ToString().Trim();
        txtDescription.Text = oSpType.TypeDesc.ToString().Trim();
        ddlCurrency.Text    = oSpType.Currency.CurrencyID.Trim();
        hdSPTypeID.Value    = oSpType.SPTypeID.ToString().Trim();
        if (string.IsNullOrEmpty(hdDataType.Value))
        {
            //When Loading from Approver End
            UserDetails userDetails = ucUserDet.UserDetail;
            userDetails.MakerID  = oSpType.UserDetails.MakerID;
            userDetails.MakeDate = oSpType.UserDetails.MakeDate;
            ucUserDet.UserDetail = userDetails;
        }
        else if (hdDataType.Value.Equals("T"))
        {
            //When loading from temp table
            UserDetails userDetails = ucUserDet.UserDetail;
            userDetails.CheckDate      = oSpType.UserDetails.CheckDate;
            userDetails.CheckerID      = oSpType.UserDetails.CheckerID;
            userDetails.CheckDate      = oSpType.UserDetails.CheckDate;
            userDetails.CheckerComment = oSpType.UserDetails.CheckerComment;
            ucUserDet.UserDetail       = userDetails;
        }

        DataTable oDataTable = new DataTable("dtData");

        oDataTable.Columns.Add(new DataColumn("bfDenomSPType", typeof(string)));
        oDataTable.Columns.Add(new DataColumn("bfDenomination", typeof(string)));
        oDataTable.Columns.Add(new DataColumn("bfSPSeries", typeof(string)));
        oDataTable.Columns.Add(new DataColumn("bfDigitsInSlNo", typeof(string)));
        oDataTable.Columns.Add(new DataColumn("bfReOrderLevel", typeof(string)));

        DataRow row = null;

        gvDenom.DataSource = null;
        gvDenom.DataBind();
        if (oSpType.ListOfDenomination.Denomination.Count > 0)
        {
            for (int j = 0; j < oSpType.ListOfDenomination.Denomination.Count; j++)
            {
                Denomination oDenomination = (Denomination)oSpType.ListOfDenomination.Denomination[j];

                row = oDataTable.NewRow();
                row["bfDenomSPType"]  = oSpType.SPTypeID.ToString();
                row["bfDenomination"] = oDenomination.DenominationID.ToString();
                row["bfSPSeries"]     = oDenomination.Series.ToString();
                row["bfDigitsInSlNo"] = oDenomination.NoOfDigitsInSeries.ToString();
                row["bfReOrderLevel"] = oDenomination.ReOrderLevel.ToString();
                oDataTable.Rows.Add(row);
            }
            gvDenom.DataSource = oDataTable;
            gvDenom.DataBind();
        }
    }
Ejemplo n.º 22
0
 public Coin(string CoinName)
 {
     if (Enum.TryParse <Denomination>(CoinName, true, out Denomination coin))
     {
         this.denomination = coin;
     }
     else
     {
         throw new ArgumentException("Invalid name for coin");
     }
 }
Ejemplo n.º 23
0
    private void LoadDenomDataListBySPTypeID(string spTYpeID, SPTypeList spList)
    {
        gvDenom.DataSource = null;
        gvDenom.DataBind();

        if (!string.IsNullOrEmpty(spTYpeID) && spList != null)
        {
            if (spList.ListOfSPType.Count > 0)
            {
                DataTable oDataTable = new DataTable("dtData");

                oDataTable.Columns.Add(new DataColumn("bfDenomSPType", typeof(string)));
                oDataTable.Columns.Add(new DataColumn("bfDenomination", typeof(string)));
                oDataTable.Columns.Add(new DataColumn("bfSPSeries", typeof(string)));
                oDataTable.Columns.Add(new DataColumn("bfDigitsInSlNo", typeof(string)));
                oDataTable.Columns.Add(new DataColumn("bfReOrderLevel", typeof(string)));

                DataRow row     = null;
                SPType  oSpType = spTypeList.ListOfSPType.Where(d => d.SPTypeID.Equals(spTYpeID)).SingleOrDefault();
                if (oSpType != null)
                {
                    if (oSpType.ListOfDenomination.Denomination.Count > 0)
                    {
                        for (int j = 0; j < oSpType.ListOfDenomination.Denomination.Count; j++)
                        {
                            Denomination oDenomination = (Denomination)oSpType.ListOfDenomination.Denomination[j];

                            row = oDataTable.NewRow();
                            row["bfDenomSPType"]  = oSpType.SPTypeID.ToString();
                            row["bfDenomination"] = oDenomination.DenominationID.ToString();
                            row["bfSPSeries"]     = oDenomination.Series.ToString();
                            row["bfDigitsInSlNo"] = oDenomination.NoOfDigitsInSeries.ToString();
                            row["bfReOrderLevel"] = oDenomination.ReOrderLevel.ToString();
                            oDataTable.Rows.Add(row);
                        }
                    }
                }
                //
                else
                {
                }
                gvDenom.DataSource = oDataTable;
                gvDenom.DataBind();
            }
            else
            {
                ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_ERROR);
            }
        }
        else
        {
            ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_ERROR);
        }
    }
Ejemplo n.º 24
0
 public Coin(Denomination CoinEnumeral)
 {
     if (IsValid(typeof(Denomination), CoinEnumeral))
     {
         this.CoinEnumeral = CoinEnumeral;
     }
     else
     {
         throw new ArgumentException("Invalid demonination for coin");
     }
 }
Ejemplo n.º 25
0
        // Gets the singular form of the denomination passed in.
        // Example: Dollars returns "Dollar"
        public string SingularDenominationName(Denomination denomination)
        {
            // Gets the info for the enum.
            var memberInfo = typeof(Denomination).GetMember(denomination.ToString());

            // Gets the attributes for the enum.
            var attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

            // Gets the "Description" attribute for the enum.
            return(((DescriptionAttribute)attrs[0]).Description);
        }
Ejemplo n.º 26
0
 public Coin(decimal CoinValue)
 {
     if (IsValid(typeof(Denomination), ((Denomination)Convert.ToInt32((decimal)CoinValue))))
     {
         this.denomination = ((Denomination)Convert.ToInt32((decimal)CoinValue));
     }
     else
     {
         throw new ArgumentException("Invalid value for coin");
     }
 }
        public ActionResult Create([Bind(Include = "ID,Type")] Denomination denomination)
        {
            if (ModelState.IsValid)
            {
                denomination.ID = Guid.NewGuid();
                db.Denominations.Add(denomination);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(denomination));
        }
Ejemplo n.º 28
0
 public static string PrettyPrint(this Denomination denomination, ulong amount)
 => denomination == Denomination.Hundred ? $"{amount} Benjamin{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.Fifty ? $"{amount} fift{(amount != 1 ? "ies" : "y")}" :
 denomination == Denomination.Twenty ? $"{amount} twent{(amount != 1 ? "ies" : "y")}" :
 denomination == Denomination.Ten ? $"{amount} ten{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.Five ? $"{amount} five{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.One ? $"{amount} one{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.Quarter ? $"{amount} quarter{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.Dime ? $"{amount} dime{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.Nickel ? $"{amount} nickel{(amount != 1 ? "s" : "")}" :
 denomination == Denomination.Penny ? $"{amount} penn{(amount != 1 ? "ies" : "y")}" :
 $"{amount} ????";
Ejemplo n.º 29
0
 // This constructor will take a string and return the appropriate enumeral
 public Coin(string CoinName)
 {
     Denomination coinEnumeral;
     if (Enum.IsDefined(typeof(Denomination), CoinName) &&
         Enum.TryParse<Denomination>(CoinName, out coinEnumeral))
     {
         coinObject = coinEnumeral;
     }
     else
     {
         coinObject = Coin.Denomination.SLUG;
     }
 }
        // GET: Denominations/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Denomination denomination = db.Denominations.Find(id);

            if (denomination == null)
            {
                return(HttpNotFound());
            }
            return(View(denomination));
        }
Ejemplo n.º 31
0
        public void Insert(Denomination denomination)
        {
            if (denomination == null)
            {
                throw new ArgumentNullException();
            }
            if (_items.Contains(denomination))
            {
                throw new ArgumentException("duplicate");
            }

            _items.Add(denomination);
            Save();
        }
        // This constructor will take a string and return the appropriate enumeral
        public Coin(string CoinName)
        {
            Denomination coinEnumeral;

            if (Enum.IsDefined(typeof(Denomination), CoinName) &&
                Enum.TryParse <Denomination>(CoinName, out coinEnumeral))
            {
                coinObject = coinEnumeral;
            }
            else
            {
                coinObject = Coin.Denomination.SLUG;
            }
        }
Ejemplo n.º 33
0
 // parametered constructor – coin will be of appropriate value
 public Coin(decimal CoinValue)
 {
     Denomination castFromValue = (Denomination)(CoinValue * 100);
     switch (castFromValue)
     {
         case Denomination.NICKEL:
         case Denomination.DIME:
         case Denomination.QUARTER:
         case Denomination.HALFDOLLAR:
             coinObject = castFromValue;
             break;
         default:
             coinObject = Denomination.SLUG;
             break;
     }
 }
Ejemplo n.º 34
0
 public int getValue(Denomination denom)
 {
     switch (denom)
     {
         case Denomination.QUARTERS_LOOSE:
             return numQuarters;
         case Denomination.QUARTER_ROLLS:
             return numQuarterRolls;
         case Denomination.NICKELS_LOOSE:
             return numNickels;
         case Denomination.NICKEL_ROLLS:
             return numNickelRolls;
         case Denomination.DIMES_LOOSE:
             return numDimes;
         case Denomination.DIME_ROLLS:
             return numDimeRolls;
         case Denomination.PENNIES_LOOSE:
             return numPennies;
         case Denomination.PENNY_ROLLS:
             return numPennyRolls;
         case Denomination.ONES:
             return numOnes;
         case Denomination.FIVES:
             return numFives;
         case Denomination.TENS:
             return numTens;
         case Denomination.TWENTIES:
             return numTwenties;
         case Denomination.FIFTIES:
             return numFifties;
         case Denomination.HUNDREDS:
             return numHundreds;
         default:
             return -1;
     }//End Switch
 }
Ejemplo n.º 35
0
 public void setValue(Denomination denom, int value)
 {
     switch(denom)
     {
         case Denomination.QUARTERS_LOOSE:
             setQuarters(value);
             break;
         case Denomination.QUARTER_ROLLS:
             setQuarterRolls(value);
             break;
         case Denomination.NICKELS_LOOSE:
             setNickels(value);
             break;
         case Denomination.NICKEL_ROLLS:
             setNickelRolls(value);
             break;
         case Denomination.DIMES_LOOSE:
             setDimes(value);
             break;
         case Denomination.DIME_ROLLS:
             setDimeRolls(value);
             break;
         case Denomination.PENNIES_LOOSE:
             setPennies(value);
             break;
         case Denomination.PENNY_ROLLS:
             setPennyRolls(value);
             break;
         case Denomination.ONES:
             setOnes(value);
             break;
         case Denomination.FIVES:
             setFives(value);
             break;
         case Denomination.TENS:
             setTens(value);
             break;
         case Denomination.TWENTIES:
             setTwenties(value);
             break;
         case Denomination.FIFTIES:
             setFifties(value);
             break;
         case Denomination.HUNDREDS:
             setHundreds(value);
             break;
     }//End Switch
 }
Ejemplo n.º 36
0
        static void Main(string[] args)
        {
            string strServer = "localhost";
            string strDB = "LittleTree";
            string strUser = "******";
            string strPass = "******";

            string strConn = string.Format("Server={0};Database={1};Uid={2};Pwd={3}", strServer, strDB, strUser, strPass);

            if (args.Contains("--init"))
            {
                Program pg = new Program();
                pg.initdb(strConn);
            }

            if (args.Length == 0)
            {
                while (true)
                {
                    Console.Write("\n"
                        + "dnm: Denomination \n"
                        + "ctg: Category \n"
                        + "trn: Transaction \n"
                        //+ "--init: Initialize database \n"
                        + "csv: Import CSV \n"
                        + "ext: Exit \n"
                        + "\n");
                    Console.Write("Select option : ");
                    string strOption = Console.ReadLine();

                    switch (strOption)
                    {
                        case "dnm":
                            Denomination dnm = new Denomination(strConn);
                            if (dnm.dialogue() == 0)
                            {
                                break;
                            }
                            else
                            {
                                return;
                            }

                        case "ctg":
                            Category ctg = new Category(strConn);
                            if (ctg.dialogue() == 0)
                            {
                                break;
                            }
                            else
                            {
                                return;
                            }

                        case "trn":
                            Transaction trn = new Transaction(strConn);
                            if (trn.dialogue() == 0)
                            {
                                break;
                            }
                            else
                            {
                                return;
                            }

                        case "--init":
                            Program pg = new Program();
                            pg.initdb(strConn);
                            break;

                        case "csv":
                            CSV csv = new CSV(strConn);
                            if (csv.dialogue() == 0)
                            {
                                break;
                            }
                            else
                            {
                                return;
                            }

                        case "ext":
                            return;

                        default:
                            Console.WriteLine(string.Format("Inputted '{0}' is not suporteed.", strOption));
                            break;
                    }

                    continue;

                }
            }
        }
Ejemplo n.º 37
0
 // parametered constructor – coin will be of appropriate value
 // if value passed is outside normal set (e.g. 5 cents = Nickel)
 // coin is a slug     
 public Coin(Denomination CoinEnumeral)
 {
     coinObject = CoinEnumeral;
 }
Ejemplo n.º 38
0
 // parameterless constructor – coin will be a slug
 public Coin()
 {
     coinObject = Denomination.SLUG;
 }
Ejemplo n.º 39
0
     // parametered constructor – coin will be of appropriate value    
     
 public Coin(decimal CoinValue)
 {
     this.CoinEnumeral = (Denomination)(Decimal.ToInt32(CoinValue*100));
 }
 public BillDenomination(Denomination denom)
 {
     this.Id = denom.Id;
     this.BillAmount = denom.BillAmount;
     this.SerialNumber = denom.SerialNumber;
 }
Ejemplo n.º 41
0
 public Coin(Denomination coin) {
     Enumeral = coin;
 }
Ejemplo n.º 42
0
     // This constructor will take a string and return the appropriate enumeral    
 public Coin(string CoinName)          
 {
     this.CoinEnumeral = (Denomination) Enum.Parse(typeof(Denomination), CoinName);
 }
Ejemplo n.º 43
0
 // parametered constructor – coin will be of appropriate value    
 // if value passed is outside normal set (e.g. 5 cents = Nickel)    
 // coin is a slug         
 public Coin(Denomination CoinEnumeral)     
 {
     this.CoinEnumeral = CoinEnumeral;
 }
Ejemplo n.º 44
0
        private void add(string strMode)
        {
            string _TransDate;
            string _MainCategoryId;
            string _SubCategoryId;
            string _Amount;
            string _DenomiId;
            string _Memo;

            DateTime dt = DateTime.Today;
            string _Today = dt.ToShortDateString();
            Console.Write(string.Format("Trans date? (Default : {0}) : ", _Today));
            _TransDate = Console.ReadLine();
            if (_TransDate == "")
            {
                _TransDate = _Today;
            }

            while (true)
            {
                Console.Write("Input MainCategoryId (Optional) : ");
                _MainCategoryId = Console.ReadLine();

                switch (_MainCategoryId)
                {
                    case "\t":
                        Category ctg = new Category(_strConn);
                        ctg.listMain();
                        continue;
                    case "":
                        //Noneを選択
                        _MainCategoryId = "1";
                        break;
                    case "x":
                        return;
                    default:
                        break;
                }

                break;
            }

            while (true)
            {
                Console.Write("Input SubCategoryId (Optional) : ");
                _SubCategoryId = Console.ReadLine();
                switch (_SubCategoryId)
                {
                    case "\t":
                        Category ctg = new Category(_strConn);
                        ctg.list();
                        continue;
                    case "":
                        //Noneを選択
                        _SubCategoryId = "1";
                        break;
                    case "x":
                        return;
                    default:
                        break;
                }

                break;
            }

            while (true)
            {
                Console.Write("Input Amount : ");
                _Amount = Console.ReadLine();

                //Expenseの場合に符号を逆転
                if (strMode =="e")
                {
                    _Amount = "-" + _Amount;
                }

                try
                {
                    Convert.ToDecimal(_Amount);
                }
                catch
                {
                    Console.WriteLine("Inputed was not decimal number. \n");
                    continue;
                }

                break;
            }

            while (true)
            {

                Console.Write("Input DenomiId : ");
                _DenomiId = Console.ReadLine();

                Denomination dnm = new Denomination(_strConn);

                switch (_DenomiId)
                {
                    case "\t":
                        dnm.list();
                        continue;
                    case "x":
                        return;
                    case "":
                        Console.WriteLine("Input valid DenomiId");
                        continue;
                    default:
                        break;
                }

                if (dnm.find(_DenomiId) == "")
                {
                    Console.WriteLine(_DenomiId + " is not valid.");
                    continue;
                }

                break;
            }

            Console.Write("Input Memo (Optional) : ");
            _Memo = Console.ReadLine();

            string strCommand;
            strCommand = string.Format(@"
                insert into GeneralTrans(
                    TransDate
                ,   MainCategoryId
                ,   SubCategoryId
                ,   Amount
                ,   DenomiId
                ,   Memo)
                values(
                    '{0}'     #TransDate
                ,   {1}     #MainCategoryId
                ,   {2}     #SubCategoryId
                ,   {3}     #Amount
                ,   {4}     #DenomiId
                ,   '{5}'     #Memo
                )
                ", _TransDate, _MainCategoryId, _SubCategoryId, _Amount, _DenomiId, _Memo);

            Sql sql = new Sql(_strConn);
            sql.exec(strCommand);
        }