static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Airline  airline  = new Airline();
            Finance  finance  = new Finance();
            Sales    sales    = new Sales();
            Catering catering = new Catering();

            //link modules with events
            airline.FlightEvent    += finance.OnFlightEvent;
            airline.FlightEvent    += sales.OnFlightEvent;
            airline.FlightEvent    += catering.OnFlightEvent;
            catering.CateringEvent += finance.OnCateringEvent;

            //simulate app
            FlightReader  fr      = new FlightReader();
            List <Flight> flights = fr.ReadFlights();

            foreach (var f in flights)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(f);
                airline.AddFlight(f);
            }

            //check observers
            catering.PrintOrderReport();
            sales.PrintAnalysisReport();
            finance.PrintCateringReport(2021);
            finance.PrintFuelReport(2021);
        }
Example #2
0
        public virtual async Task ReturnLicense(long id)
        {
            var item = await _softLicenseRepository.FirstOrDefaultAsync(t => t.Id == id);

            if (item == null)
            {
                throw new UserFriendlyException("卡密数据不存在!");
            }
            if (item.Status != SoftLicenseStatus.Sell && item.Status != SoftLicenseStatus.HasUse)
            {
                throw new UserFriendlyException("卡密当前状态不能退货!");
            }
            item.SellType = SoftLicenseSellType.Manually;
            item.Status   = SoftLicenseStatus.Retuurn;

            await _softLicenseRepository.UpdateAsync(item);

            //写入财务记录
            Finance finance = new Finance();

            finance.Type   = FinanceType.Expenses;
            finance.Money  = item.Price;
            finance.Remark = string.Format("退货卡密:{0}", item.LicenseNo);

            await _financeRepository.InsertAsync(finance);
        }
Example #3
0
        public IActionResult UpdateFinance([FromBody] Finance finances)
        {
            if (finances == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(finances)} cannot be null"
                }));
            }

            try
            {
                var response = BillingHelpers.UpdateFinance(finances);
                if (response != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = response
                    }));
                }
            }
            catch (Exception)
            {
            }

            return(Ok(new APIResponse()
            {
                status = APIStatus.FAIL.ToString(), response = "Updation Failed."
            }));
        }
Example #4
0
        public ObjFinance Map(Finance model)
        {
            return(new ObjFinance()
            {
                Id = model.Id,
                FinanceType = model.FinanceType,

                SubTypeId = model.SubTypeId,
                SubTypeName = model.SubTypeId != null ? model.SubType.Name : "",

                ProjectId = model.ProjectId,
                ProjectName = model.Project.Title,

                Date = model.Date,

                Place = model.Place,

                Cost = model.Cost,
                Currency = model.Currency,

                UserId = model.UserId,
                UserName = model.UserId != null ? model.User.Fio : "",

                DocumentName = model.DocumentName,

                CreatedId = model.CreatedId,
            });
        }
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            bool foundGrowCrop = FindParentGrowCrop();

            if (!foundGrowCrop)
            {
                Summary.WriteWarning(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
                throw new ApsimXException(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
            }

            grandParentCropLand = (IATCropLand)parentGrowCrop.Parent;

            // get finance resource
            Finance finance = Resources.FinanceResource();

            if (finance != null)
            {
                bankAccount = Resources.GetResourceItem(this, typeof(Finance), AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
            }

            // get labour specifications
            labour = Apsim.Children(this, typeof(LabourFilterGroupSpecified)).Cast <LabourFilterGroupSpecified>().ToList();
            if (labour == null)
            {
                labour = new List <LabourFilterGroupSpecified>();
            }

            costDate = CostDateFromHarvestDate();
        }
Example #6
0
        //public static List<BrandModel> GetBrandModelList()
        //{
        //    try
        //    {
        //        using (Repository<BrandModel> repo = new Repository<BrandModel>())
        //        {
        //            return repo.BrandModel.AsEnumerable()
        //                       .Where(b => b.Active.Equals("Y", StringComparison.OrdinalIgnoreCase))
        //                       .ToList();
        //        }
        //    }
        //    catch { throw; }
        //}
        public static Finance RegisterFiances(Finance finance)
        {
            try
            {
                using Repository <Finance> repo = new Repository <Finance>();
                finance.AddDate  = DateTime.Now;
                finance.EditDate = DateTime.Now;
                finance.Active   = "Y";

                var reacord = repo.Finance.OrderByDescending(x => x.AddDate).FirstOrDefault();
                if (reacord != null)
                {
                    finance.Code = CommonHelper.IncreaseCode(reacord.Code);
                }
                else
                {
                    finance.Code = "1";
                }

                repo.Finance.Add(finance);
                if (repo.SaveChanges() > 0)
                {
                    return(finance);
                }

                return(null);
            }
            catch { throw; }
        }
Example #7
0
 private void btnUpdateAcc_Click(object sender, EventArgs e)
 {
     try
     {
         int     AccId  = int.Parse(hdnAccountId.Value);
         string  CEType = hdnCollapseExpand.Value;
         decimal dValue = 0;
         try{
             dValue = decimal.Parse(txtSum.Text);
         }
         catch {}
         if (CEType == "0")
         {
             Finance.UpdateTargetAccount(AccId, dValue, cbSaveParent.Checked);
         }
         else
         {
             Finance.UpdateEstimatedAccount(AccId, dValue, cbSaveParent.Checked);
         }
     }
     catch (WrongDataException)
     {
     }
     BindDG();
 }
Example #8
0
        public void BlackScholes()
        {
            NArray s;

            using (var stream = new RandomNumberStream(StorageLocation.Host, RandomNumberGeneratorType.MRG32K3A))
            {
                var normal = new Normal(stream, 0, 1);
                s = 100 * NMath.Exp(NArray.CreateRandom(5, normal) * 0.2);
            }

            double k          = 90;
            var    volatility = 0.2;
            var    t          = 5;
            var    df         = Math.Exp(-0.005 * t);

            var result = NArray.Evaluate(() =>
            {
                var f = s / df;
                return(df * Finance.BlackScholes(CallPut.Call, f, k, volatility, t));
            }, s);

            var sds   = s + 1e-6;
            var check = (df * Finance.BlackScholes(CallPut.Call, sds / df, k, volatility, t)
                         - df * Finance.BlackScholes(CallPut.Call, s / df, k, volatility, t)) * 1e6;

            Assert.IsTrue(TestHelpers.AgreesAbsolute(result[1], check));
        }
Example #9
0
        protected void btnSave_click(object sender, System.EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            if (ProjectId > 0)
            {
                Finance.AddActualFinancesForProject(int.Parse(ddAccounts.SelectedValue), ProjectId, txtDescription.Text, decimal.Parse(txtValue.Text));
            }
            else if (TaskId > 0)
            {
                Finance.AddActualFinancesForTask(int.Parse(ddAccounts.SelectedValue), TaskId, txtDescription.Text, decimal.Parse(txtValue.Text));
            }
            else if (IncidentId > 0)
            {
                Finance.AddActualFinancesForIncident(int.Parse(ddAccounts.SelectedValue), IncidentId, txtDescription.Text, decimal.Parse(txtValue.Text));
            }
            else if (DocumentId > 0)
            {
                Finance.AddActualFinancesForDocument(int.Parse(ddAccounts.SelectedValue), DocumentId, txtDescription.Text, decimal.Parse(txtValue.Text));
            }
            else if (EventId > 0)
            {
                Finance.AddActualFinancesForEvent(int.Parse(ddAccounts.SelectedValue), EventId, txtDescription.Text, decimal.Parse(txtValue.Text));
            }
            else if (ToDoId > 0)
            {
                Finance.AddActualFinancesForToDo(int.Parse(ddAccounts.SelectedValue), ToDoId, txtDescription.Text, decimal.Parse(txtValue.Text));
            }
            CancelFunc();
        }
Example #10
0
        /// <summary>
        /// 删除班费收支
        /// </summary>
        /// <param name="finance"></param>
        /// <returns></returns>
        public async Task <bool> DeleteFinance(Finance finance)
        {
            try
            {
                string  url = APIUrl.Finance.DeleteFinance;
                JObject obj = new JObject();
                obj.Add(APIKey.Finance.Root, finance.ToJObject());

                JsonObject json = await GetJsonByPost(url, obj.ToString());

                if (json != null)
                {
                    if (json.ContainsKey(APIKey.Status))
                    {
                        return(json[APIKey.Status].GetString() == APIValue.Success);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Example #11
0
        public DataRespond insertFinance(FinanceRequest finance)
        {
            DataRespond data = new DataRespond();

            try
            {
                var fi = new Finance();
                fi.name     = finance.name;
                fi.moneys   = finance.moneys;
                fi.status   = finance.status;
                fi.cbid     = finance.cbid;
                fi.uscreate = finance.uscreate;
                fi.person   = finance.person;
                DateTime daycr = DateTime.ParseExact(finance.createday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                fi.createday = daycr;
                data.success = true;
                data.message = "insert succeses";
                m_financeResponsitory.insertFinance(fi);
            }
            catch (Exception e)
            {
                data.message = e.Message;
                data.error   = e;
                data.success = false;
            }

            return(data);
        }
Example #12
0
        public void PresentValue()
        {
            // $,1061.68 at 0.5% over 12 periods
            var futureValue = Finance.PresentValue(1061.68M, 0.5M, 12);

            Assert.AreEqual(1000, futureValue);
        }
Example #13
0
        public void AddMoney(double amount)
        {
            Finance shopIncome = _dbContext.Financies.First(finance => finance.Name == ShopIncomeName);

            shopIncome.Amount += amount;
            _dbContext.SaveChanges();
        }
Example #14
0
        public void FutureValue()
        {
            // $1,000 at 0.5% over 12 periods
            var futureValue = Finance.FutureValue(1000M, 0.5M, 12);

            Assert.AreEqual(1061.68M, futureValue);
        }
        /// <summary>
        /// National Insurance Number
        /// </summary>
        public static string Nino(this Finance finance, bool includeSeparator = true)
        {
            const string valid1stPrefixChars = "ABCEGHJKLMNOPRSTWXYZ";
            //const string valid2ndPrefixChars = "ABCEGHJKLMN PRSTWXYZ";
            const string validSuffixChars = "ABCD";

            var prefix = finance.Random.String2(2, chars: valid1stPrefixChars);

            if (prefix.EndsWith("O"))
            { //second character in prefix can't end with an 'O'
              //Remap O to an X.
                prefix = prefix.Replace('O', 'X');
            }

            //check for invalid prefixes
            if (prefix == "GB" || prefix == "BG" || prefix == "NK" ||
                prefix == "KN" || prefix == "TN" || prefix == "NT" ||
                prefix == "ZZ")
            {
                //if the prefix is any of the invalid prefixes,
                //Remap an invalid prefix to a well known valid one.
                prefix = "CE";
            }

            var suffix = finance.Random.String2(1, validSuffixChars);

            if (includeSeparator)
            {
                return(finance.Random.ReplaceNumbers($"{prefix} ## ## ## {suffix}"));
            }
            return(finance.Random.ReplaceNumbers($"{prefix}######{suffix}"));
        }
Example #16
0
        public FinanceWindow()
        {
            InitializeComponent();

            using (var db = new LiteDatabase("pcclinic.db"))
            {
                LiteCollection <Finance> financeCollection = db.GetCollection <Finance>("finances");
                string query;
                try
                {
                    query = financeCollection.FindById(1).Money.ToString();
                }
                catch (NullReferenceException)
                {
                    //
                    LiteCollection <Finance> financeCOllection = db.GetCollection <Finance>("finances");

                    Finance finance = new Finance(0m);

                    financeCollection.Insert(finance);
                    query = financeCOllection.FindById(1).Money.ToString();
                }

                lblMoney.Content = "Money: £" + query;
            }
        }
Example #17
0
        public string GetAccountList(string callType, string xmlMessage)
        {
            string result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                            "<" + callType + ">" +
                            "<Result>False</Result>" +
                            "<Description></Description></" + callType + ">";
            string logID = Guid.NewGuid().ToString();

            try
            {
                FileLogger.WriteLog(logID + "|Start:" + xmlMessage, 1, "", callType);

                if (Helper.CheckAuthCode(callType, xmlMessage))
                {
                    Finance f = new Finance();
                    result = f.GetAccountList(xmlMessage);
                }
            }
            catch (Exception err)
            {
                result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                         "<" + callType + ">" +
                         "<Result>False</Result>" +
                         "<Description>" + err.Message + "</Description></" + callType + ">";
            }
            FileLogger.WriteLog(logID + "|End:" + result, 1, "", callType);
            return(result);
        }
Example #18
0
        public IActionResult RegisterFiances([FromBody] Finance finances)
        {
            if (finances == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(finances)} cannot be null"
                }));
            }
            try
            {
                var response = BillingHelpers.RegisterFiances(finances);

                if (response != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = response
                    }));
                }

                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = "Registration Failed"
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
Example #19
0
        public Club(
            int id,
            int lp,
            string name,
            string city,
            string league,
            int money,
            Tactics tactics,
            StatisticsClub statistics)
        {
            this.id        = id;
            this.ordinalNr = lp;
            this.name      = name;
            this.city      = city;
            fullName       = name + " " + city;
            this.league    = league;

            this.tactics         = tactics;
            this.statistics      = statistics;
            this.statistics.club = this;

            squad   = new Squad(this);
            stadium = new Stadium(this, 4000);
            finance = new Finance(this, money);
        }
Example #20
0
        public void can_create_shortcode()
        {
            var f = new Finance();

            f.ShortCode().Should().Be("61-86-06");
            f.ShortCode(false).Should().Be("064391");
        }
Example #21
0
        public virtual async Task SellLicense(long id)
        {
            var item = await _softLicenseRepository.FirstOrDefaultAsync(t => t.Id == id);

            if (item == null)
            {
                throw new UserFriendlyException("卡密数据不存在!");
            }
            if (item.Status != SoftLicenseStatus.Normal)
            {
                throw new UserFriendlyException("卡密当前状态不能出售!");
            }
            item.SellType   = SoftLicenseSellType.Manually;
            item.Status     = SoftLicenseStatus.Sell;
            item.SellerTime = DateTime.Now;

            await _softLicenseRepository.UpdateAsync(item);

            //写入财务记录
            Finance finance = new Finance();

            finance.Type   = FinanceType.InCome;
            finance.Money  = item.Price;
            finance.Remark = string.Format("出售卡密:{0}", item.LicenseNo);

            await _financeRepository.InsertAsync(finance);
        }
Example #22
0
 public HttpResponseMessage PutFinance(int FinanceID, [FromBody] Finance finance)
 {
     try
     {
         using (project1Entities db = new project1Entities())
         {
             var data = db.Finances.Find(FinanceID);
             if (data == null)
             {
                 return(Request.CreateResponse(HttpStatusCode.NotFound, "Purchase with finance id " + FinanceID + "not found"));
             }
             else
             {
                 data.Email           = finance.Email;
                 data.Months          = finance.Months;
                 data.EmiAmount       = finance.EmiAmount;
                 data.TotalAmount     = finance.TotalAmount;
                 data.RemainingAmount = finance.RemainingAmount;
                 data.purchaseDate    = finance.purchaseDate;
                 data.ProductID       = finance.ProductID;
                 data.LastPaymentDate = finance.LastPaymentDate;
                 db.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, data));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Example #23
0
        public void CreditCard_With_Multiple_Types()
        {
            var cc = Finance.CreditCard(CreditCardType.Forbrugsforeningen, CreditCardType.AmericanExpress, CreditCardType.Dankort);

            Assert.AreEqual(0, RegexMatchesCount(cc, "[/#]"), $"{nameof(cc)} is '{cc}'");
            Assert.AreEqual(0, RegexMatchesCount(cc, "L"));
        }
        public async Task <bool> Make_a_request_that_will_return_true_for_finance()
        {
            var test_url = new Finance();
            var url      = $"{test_url.DefaultGateway}bankgl/get/all/bankgl";

            return(await Access_service_via_the_default_Gateway(url));
        }
Example #25
0
        private void dgAccounts_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            int ActualId = int.Parse(e.CommandArgument.ToString());

            Finance.DeleteActualFinances(ActualId);
            BindDG();
        }
Example #26
0
        public HttpResponseMessage PostFinance(string Email, int ProductID, [FromBody] Finance finance)
        {
            try
            {
                using (project1Entities db = new project1Entities())
                {
                    var limit = db.CardDetails.Where(cd => cd.Email == Email).FirstOrDefault();
                    var price = db.Products.Where(pr => pr.ProductID == ProductID).FirstOrDefault();
                    if (limit.CurrentLimit > price.Price)
                    {
                        limit.CurrentLimit   = limit.CurrentLimit - price.Price;
                        finance.purchaseDate = DateTime.Now;
                        db.Finances.Add(finance);

                        db.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.Created, finance));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Finance id cannot be created due to low current limit"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #27
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBox[] textBoxesArray = { ObjectDataTextBox, ObjectDataTextBox1 };
            ObjectDataTextBox.Clear();
            ObjectDataTextBox1.Clear();
            switch (comboBox1.SelectedItem.ToString())
            {
            case "Tents":
                Finance.PopulateTents(textBoxesArray);

                break;

            case "Sales":
                Finance.PopulateSales(textBoxesArray);
                break;

            case "Tickets":
                Finance.PopulateTickets(textBoxesArray);
                break;

            default:
                MessageBox.Show("select something bithc");
                break;
            }
        }
Example #28
0
        public void should_return_a_coupon()
        {
            var coupon = Finance.Coupon();

            Console.WriteLine($@"Coupon=[{coupon}]");

            Assert.That(coupon, Is.GreaterThan(0));
        }
        public async Task <string> Return_finance_appsettingsurls_async()
        {
            var test_url = new Finance();
            var client   = new HttpClient();
            var response = await client.GetStringAsync($"{test_url.Backend}test_response/finance/get/baseurls");

            return(response);
        }
Example #30
0
        public ActionResult DeleteConfirmed(int id)
        {
            Finance finance = db.Finances.Find(id);

            db.Finances.Remove(finance);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 static void Main()
 {
     Staff[] nojo = new Staff[100];
     nojo[0] = new Manager();
     nojo[1] = new Personnel();
     nojo[2] = new Account();
     nojo[3] = new Manager();
     nojo[4] = new Finance();
 }