/// <summary>
        /// Breaks down the bills to make change
        /// </summary>
        /// <param name="b">The bill to be broken</param>
        private void BreakBills(Bills b)
        {
            int   bi = 0;
            Bills ba = b + 1;

            switch (ba)
            {
            case Bills.Two:
                bi = cd.Twos;
                if (bi == 0)
                {
                    ba++;
                    goto case Bills.Five;
                }
                break;

            case Bills.Five:
                bi = cd.Fives;
                if (bi == 0)
                {
                    ba++;
                    goto case Bills.Ten;
                }
                break;

            case Bills.Ten:
                bi = cd.Tens;
                if (bi == 0)
                {
                    ba++;
                    goto case Bills.Twenty;
                }
                break;

            case Bills.Twenty:
                bi = cd.Twenties;
                if (bi == 0)
                {
                    ba++;
                    goto case Bills.Fifty;
                }
                break;

            case Bills.Fifty:
                bi = cd.Fifties;
                if (bi == 0)
                {
                    ba++;
                    goto case Bills.Hundred;
                }
                break;

            case Bills.Hundred:
                bi = cd.Hundreds;
                if (bi == 0)
                {
                    goto default;
                }
                break;

            default:
                new NotImplementedException();
                break;
            }
            switch (ba)
            {
            case Bills.Two:
                cd.RemoveBill(Bills.Two, 1);
                cd.AddBill(Bills.One, 2);
                break;

            case Bills.Five:
                cd.RemoveBill(Bills.Five, 1);
                cd.AddBill(Bills.One, 5);
                break;

            case Bills.Ten:
                cd.RemoveBill(Bills.Ten, 1);
                cd.AddBill(Bills.Five, 2);
                if (b == Bills.Five)
                {
                    break;
                }
                else
                {
                    goto case Bills.Five;
                }

            case Bills.Twenty:
                cd.RemoveBill(Bills.Twenty, 1);
                cd.AddBill(Bills.Ten, 2);
                if (b == Bills.Ten)
                {
                    break;
                }
                else
                {
                    goto case Bills.Ten;
                }

            case Bills.Fifty:
                cd.RemoveBill(Bills.Fifty, 1);
                cd.AddBill(Bills.Twenty, 2);
                cd.AddBill(Bills.Ten, 1);
                if (b == Bills.Twenty)
                {
                    break;
                }
                else
                {
                    goto case Bills.Twenty;
                }

            case Bills.Hundred:
                cd.RemoveBill(Bills.Hundred, 1);
                cd.AddBill(Bills.Fifty, 2);
                if (b == Bills.Fifty)
                {
                    break;
                }
                else
                {
                    goto case Bills.Fifty;
                }

            default:
                new NotImplementedException();
                break;
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var    workId  = Request.QueryString["WorkID"];
                var    fk_flow = Request.QueryString["FK_Flow"];
                var    fid     = Request.QueryString["FID"];
                string url     = string.Empty;

                url = "ChartTrack.htm?FID=" + fid + "&FK_Flow=" + fk_flow + "&WorkID=" + workId;
                //content.Attributes.Add("src", url);
            }
            catch (Exception ee)
            {
                Response.Write("轨迹图加载错误:" + ee.Message);
            }

            string isZhidu = this.Request.QueryString["isZhiDu"];

            if (string.IsNullOrEmpty(isZhidu) == false)
            {
                string zhiduNo = this.Request.QueryString["ZhiDuNo"];
                if (!string.IsNullOrEmpty(zhiduNo))
                {
                    try
                    {
                        //BP.MS.ZhiDu zhidu = new BP.MS.ZhiDu();
                        //zhidu.No = zhiduNo;
                        //zhidu.Retrieve();

                        GenerWorkFlow workflow = new GenerWorkFlow();
                        workflow.WorkID = 0;// Int64.Parse(zhidu.OID);
                        workflow.Retrieve();
                        this.Response.Redirect("Ath.aspx?FK_Flow=" + workflow.FK_Flow + "&WorkID=" + workflow.WorkID + "&FID=" + workflow.FID + "&FK_Node=" + workflow.FK_Node, true);

                        return;
                    }
                    catch (Exception)
                    {
                        throw new Exception("该流程未完成或未找到对应的流程数据!");
                    }
                }
            }

            string flowID = int.Parse(this.FK_Flow).ToString();
            string sql    = "";

            if (string.IsNullOrEmpty(FK_Node))
            {
                sql = "SELECT * FROM Sys_FrmAttachmentDB WHERE FK_FrmAttachment IN (SELECT MyPK FROM Sys_FrmAttachment WHERE  " + BP.WF.Glo.MapDataLikeKey(this.FK_Flow, "FK_MapData") + "  AND IsUpload=1) AND RefPKVal='" + this.OID + "' ORDER BY RDT";
            }
            else
            {
                sql = "SELECT * FROM Sys_FrmAttachmentDB WHERE FK_FrmAttachment IN (SELECT MyPK FROM Sys_FrmAttachment WHERE  FK_MapData='ND" + FK_Node + "' ) AND RefPKVal='" + this.OID + "' ORDER BY RDT";
            }

            //string sql = "SELECT * FROM Sys_FrmAttachmentDB WHERE FK_FrmAttachment IN (SELECT MyPK FROM Sys_FrmAttachment WHERE  FK_MapData ='ND"+FK_Node+"'  AND IsUpload=1) AND RefPKVal='" + this.OID + "' ORDER BY RDT";
            DataTable dt = DBAccess.RunSQLReturnTable(sql);

            if (dt.Rows.Count > 0)
            {
                this.Pub1.AddTable("class='Table' cellpadding='0' cellspacing='0' border='0' style='width: 100%'");
                this.Pub1.AddTR();
                this.Pub1.AddTDGroupTitle("style='text-align:center'", "序");
                this.Pub1.AddTDGroupTitle("附件编号");
                this.Pub1.AddTDGroupTitle("节点");
                this.Pub1.AddTDGroupTitle("名称");
                this.Pub1.AddTDGroupTitle("大小(kb)");
                this.Pub1.AddTDGroupTitle("上传人");
                this.Pub1.AddTDGroupTitle("上传日期");
                this.Pub1.AddTREnd();
                int i = 0;

                foreach (DataRow dr in dt.Rows)
                {
                    i++;
                    this.Pub1.AddTR();
                    this.Pub1.AddTDIdx(i);
                    this.Pub1.AddTD(dr["FK_FrmAttachment"].ToString());
                    string nodeName = "";
                    try
                    {
                        int  nodeID = int.Parse(dr["NodeID"].ToString());
                        Node node   = new Node(nodeID);
                        nodeName = node.Name;
                    }
                    catch
                    {
                    }

                    this.Pub1.AddTD(nodeName);
                    this.Pub1.AddTD("<a href='/WF/CCForm/AttachmentUpload.aspx?DoType=Down&MyPK=" + dr["MyPK"] + "' target=_sd ><img src='/WF/Img/FileType/" + dr["FileExts"] + ".gif' onerror=\"this.src='/WF/Img/FileType/Undefined.gif'\" border=0/>" + dr["FileName"].ToString() + "</a>");
                    this.Pub1.AddTD(dr["FileSize"].ToString());
                    this.Pub1.AddTD(dr["RecName"].ToString());
                    this.Pub1.AddTD(dr["RDT"].ToString());
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();
            }

            Bills bills = new Bills();

            bills.Retrieve(BillAttr.WorkID, this.OID);
            if (bills.Count > 0)
            {
                this.Pub1.AddTable("class='Table' cellpadding='0' cellspacing='0' border='0' style='width: 100%'");
                this.Pub1.AddTR();
                this.Pub1.AddTDGroupTitle("style='text-align:center'", "序");
                this.Pub1.AddTDGroupTitle("名称");
                this.Pub1.AddTDGroupTitle("节点");
                this.Pub1.AddTDGroupTitle("打印人");
                this.Pub1.AddTDGroupTitle("日期");
                this.Pub1.AddTDGroupTitle("功能");
                this.Pub1.AddTREnd();
                int idx = 0;
                foreach (Bill bill in bills)
                {
                    idx++;
                    this.Pub1.AddTR();
                    this.Pub1.AddTDIdx(idx);
                    this.Pub1.AddTD(bill.FK_BillTypeT);
                    this.Pub1.AddTD(bill.FK_NodeT);
                    this.Pub1.AddTD(bill.FK_EmpT);
                    this.Pub1.AddTD(bill.RDT);
                    this.Pub1.AddTD("<a class='easyui-linkbutton' data-options=\"iconCls:'icon-print'\" href='" + this.Request.ApplicationPath + "WF/Rpt/Bill.aspx?MyPK=" + bill.MyPK + "&DoType=Print' >打印</a>");
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();
            }


            int num = bills.Count + dt.Rows.Count;

            if (num == 0)
            {
                Pub1.AddEasyUiPanelInfo("提示", "<h3>当前流程没有数据,或者该流程没有附件或者单据。</h3>");
            }
        }
        /// <summary>
        /// Balances the bills in the drawer to make effective change
        /// </summary>
        /// <param name="b"></param>
        private void BalanceBills(Bills b)
        {
            Bills result   = b;
            int   quantity = 0;

            while (quantity == 0)
            {
                result = b + 1;
                switch (result)
                {
                case Bills.Two:
                    quantity = cd.Twos;
                    break;

                case Bills.Five:
                    quantity = cd.Fives;
                    break;

                case Bills.Ten:
                    quantity = cd.Tens;
                    break;

                case Bills.Twenty:
                    quantity = cd.Tens;
                    break;

                case Bills.Fifty:
                    quantity = cd.Fifties;
                    break;

                case Bills.Hundred:
                    quantity = cd.Hundreds;
                    break;

                default:
                    throw new NotImplementedException("Change cannot be made Huston we have a major problem");
                }
            }

            switch (result)
            {
            case Bills.Hundred:
                cd.RemoveBill(Bills.Hundred, 1);
                cd.AddBill(Bills.Fifty, 2);
                if (b == Bills.Fifty)
                {
                    break;
                }
                else
                {
                    goto case Bills.Fifty;
                }

            case Bills.Fifty:
                cd.RemoveBill(Bills.Fifty, 1);
                cd.AddBill(Bills.Twenty, 2);
                cd.AddBill(Bills.Ten, 1);
                if (b == Bills.Twenty)
                {
                    break;
                }
                else
                {
                    goto case Bills.Twenty;
                }

            case Bills.Twenty:
                cd.RemoveBill(Bills.Twenty, 1);
                cd.AddBill(Bills.Ten, 2);
                if (b == Bills.Ten)
                {
                    break;
                }
                else
                {
                    goto case Bills.Ten;
                }

            case Bills.Ten:
                cd.RemoveBill(Bills.Ten, 1);
                cd.AddBill(Bills.Five, 2);
                if (b == Bills.Five)
                {
                    break;
                }
                else
                {
                    goto case Bills.Five;
                }

            case Bills.Five:
                cd.RemoveBill(Bills.Five, 1);
                cd.AddBill(Bills.Two, 2);
                cd.AddBill(Bills.One, 1);
                if (b == Bills.Two)
                {
                    break;
                }
                else
                {
                    goto case Bills.Two;
                }

            case Bills.Two:
                cd.RemoveBill(Bills.Two, 1);
                cd.AddBill(Bills.One, 2);
                break;

            default:
                throw new NotImplementedException("Should never be reached");
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 处理风格
            this.Page.RegisterClientScriptBlock("s",
                                                "<link href='/WF/Comm/Style/Table" + BP.Web.WebUser.Style + ".css' rel='stylesheet' type='text/css' />");
            #endregion 处理风格

            string    flowID = int.Parse(this.FK_Flow).ToString();
            string    sql    = "SELECT * FROM Sys_FrmAttachmentDB WHERE FK_FrmAttachment IN (SELECT MyPK FROM Sys_FrmAttachment WHERE FK_MapData LIKE 'ND" + flowID + "%' AND IsUpload=1) AND RefPKVal='" + this.OID + "' ORDER BY RDT";
            DataTable dt     = DBAccess.RunSQLReturnTable(sql);
            if (dt.Rows.Count > 0)
            {
                this.Pub1.AddTable();
                //    this.Pub1.AddCaptionLeft("流程附件");
                this.Pub1.AddTR();
                this.Pub1.AddTDTitle("IDX");
                this.Pub1.AddTDTitle("附件编号");
                this.Pub1.AddTDTitle("名称");
                this.Pub1.AddTDTitle("大小(kb)");
                this.Pub1.AddTDTitle("上传人");
                this.Pub1.AddTDTitle("上传日期");
                this.Pub1.AddTREnd();
                int i = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    i++;
                    this.Pub1.AddTR();
                    this.Pub1.AddTDIdx(i);
                    this.Pub1.AddTD(dr["FK_FrmAttachment"].ToString());
                    this.Pub1.AddTD("<a href='" + this.Request.ApplicationPath + "WF/CCForm/AttachmentUpload.aspx?DoType=Down&MyPK=" + dr["MyPK"] + "' target=_sd ><img src='/WF/Img/FileType/" + dr["FileExts"] + ".gif' onerror=\"this.src='/WF/Img/FileType/Undefined.gif'\" border=0/>" + dr["FileName"].ToString() + "</a>");
                    this.Pub1.AddTD(dr["FileSize"].ToString());
                    this.Pub1.AddTD(dr["RecName"].ToString());
                    this.Pub1.AddTD(dr["RDT"].ToString());
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();
            }

            Bills bills = new Bills();
            bills.Retrieve(BillAttr.WorkID, this.OID);
            if (bills.Count > 0)
            {
                this.Pub1.AddTable();
                //    this.Pub1.AddCaptionLeft("单据");
                this.Pub1.AddTR();
                this.Pub1.AddTDTitle("IDX");
                this.Pub1.AddTDTitle("名称");
                this.Pub1.AddTDTitle("节点");
                this.Pub1.AddTDTitle("打印人");
                this.Pub1.AddTDTitle("日期");
                this.Pub1.AddTDTitle("功能");
                this.Pub1.AddTREnd();
                int idx = 0;
                foreach (Bill bill in bills)
                {
                    idx++;
                    this.Pub1.AddTR();
                    this.Pub1.AddTDIdx(idx);

                    this.Pub1.AddTD(bill.FK_BillTypeT);

                    this.Pub1.AddTD(bill.FK_NodeT);
                    this.Pub1.AddTD(bill.FK_EmpT);
                    this.Pub1.AddTD(bill.RDT);
                    this.Pub1.AddTD("<a href='" + this.Request.ApplicationPath + "WF/Rpt/Bill.aspx?MyPK=" + bill.MyPK + "&DoType=Print' >打印</a>");
                    this.Pub1.AddTREnd();
                }
                this.Pub1.AddTableEnd();
            }

            int num = bills.Count + dt.Rows.Count;
            if (num == 0)
            {
                this.Pub1.AddMsgGreen("提示", "<h2>当前流程没有数据,或者该流程没有附件或者单据。</h2>");
            }
        }
Пример #5
0
        public AllocationSummeryPageViewModel(INavigationService navigationService,
                                              IGlobalService globalService,
                                              IDialogService dialogService,
                                              IAllocationService allocationService,
                                              IAdvanceReceiptService advanceReceiptService,
                                              IReceiptCashService receiptCashService,
                                              ICostContractService costContractService,
                                              ICostExpenditureService costExpenditureService,
                                              IInventoryService inventoryService,
                                              IPurchaseBillService purchaseBillService,
                                              IReturnReservationBillService returnReservationBillService,
                                              IReturnBillService returnBillService,
                                              ISaleReservationBillService saleReservationBillService,

                                              ISaleBillService saleBillService
                                              ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "调拨单";

            this.BillType = BillTypeEnum.AllocationBill;

            Filter.StartTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
            Filter.EndTime   = DateTime.Now;

            this.Load = ReactiveCommand.Create(async() =>
            {
                //重载时排它
                ItemTreshold = 1;
                PageCounter  = 0;
                try
                {
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int?businessUserId = Filter.BusinessUserId;
                    int?customerId     = Filter.TerminalId;
                    string billNumber  = Filter.SerchKey;

                    int?makeuserId = Settings.UserId;
                    if (businessUserId.HasValue && businessUserId > 0)
                    {
                        makeuserId = 0;
                    }

                    int?shipmentWareHouseId = 0;
                    int?incomeWareHouseId   = 0;
                    //获取已审核
                    bool?auditedStatus     = true;
                    bool?showReverse       = null;
                    bool?sortByAuditedTime = null;

                    //清除列表
                    Bills?.Clear();

                    var items = await _allocationService.GetAllocationsAsync(makeuserId,
                                                                             businessUserId ?? 0,
                                                                             shipmentWareHouseId,
                                                                             incomeWareHouseId,
                                                                             billNumber,
                                                                             "",
                                                                             auditedStatus,
                                                                             startTime,
                                                                             endTime,
                                                                             showReverse,
                                                                             sortByAuditedTime,
                                                                             0,
                                                                             PageSize,
                                                                             this.ForceRefresh,
                                                                             new System.Threading.CancellationToken());

                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            if (Bills.Count(s => s.Id == item.Id) == 0)
                            {
                                Bills.Add(item);
                            }
                        }

                        if (items.Count() == 0 || items.Count() == Bills.Count)
                        {
                            ItemTreshold = -1;
                        }

                        foreach (var s in Bills)
                        {
                            s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                        }


                        if (Bills.Count > 0)
                        {
                            this.Bills = new ObservableRangeCollection <AllocationBillModel>(Bills);
                        }
                        UpdateTitle();
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });
            //以增量方式加载数据
            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime;
                            DateTime?endTime   = Filter.EndTime;
                            int?businessUserId = Filter.BusinessUserId;
                            int?customerId     = Filter.TerminalId;

                            int?makeuserId = Settings.UserId;
                            if (businessUserId.HasValue && businessUserId > 0)
                            {
                                makeuserId = 0;
                            }

                            int?shipmentWareHouseId = 0;
                            int?incomeWareHouseId   = 0;
                            //获取已审核
                            bool?auditedStatus     = true;
                            bool?showReverse       = null;
                            bool?sortByAuditedTime = null;


                            var items = await _allocationService.GetAllocationsAsync(makeuserId, businessUserId ?? 0, shipmentWareHouseId, incomeWareHouseId, billNumber, "", auditedStatus, startTime, endTime, showReverse, sortByAuditedTime, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                if (items.Count() == 0)
                                {
                                    ItemTreshold = -1;
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                                UpdateTitle();
                            }
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));


            //选择单据
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(AllocationBillPage), ("Bill", x));
                }
                this.Selecter = null;
            }).DisposeWith(DeactivateWith);

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_KEY, 4));

            this.BindBusyCommand(Load);
        }
Пример #6
0
 public BillDetails GetBill(int id)
 {
     return(Bills
            .Include(x => x.Tags)
            .Single(x => x.Id == id).ToModelWithItems());
 }
Пример #7
0
        private static string HealthReport([NotNull] Pawn pawn)
        {
            var segments = new List <string>
            {
                ResponseHelper.JoinPair("TKUtils.PawnHealth.OverallHealth".Localize(), pawn.health.summaryHealth.SummaryHealthPercent.ToStringPercent())
            };

            if (pawn.health.State != PawnHealthState.Mobile)
            {
                segments[0] += $" {GetHealthStateFriendly(pawn.health.State)}";
            }
            else
            {
                segments[0] += $" {GetMoodFriendly(pawn)}";
            }

            if (pawn.health.hediffSet.BleedRateTotal > 0.01f)
            {
                int ticks = HealthUtility.TicksUntilDeathDueToBloodLoss(pawn);

                segments.Add(
                    ticks >= 60000
                        ? ResponseHelper.BleedingSafeGlyphs.AltText("WontBleedOutSoon".Localize().CapitalizeFirst())
                        : $"{ResponseHelper.BleedingBadGlyphs.AltText("BleedingRate".Localize())} ({ticks.ToStringTicksToPeriod(shortForm: true)})"
                    );
            }

            List <PawnCapacityDef> source = GetCapacitiesForPawn(pawn).ToList();

            if (source.Count > 0)
            {
                source = source.OrderBy(d => d.listOrder).ToList();

                string[] capacities = source.Where(capacity => PawnCapacityUtility.BodyCanEverDoCapacity(pawn.RaceProps.body, capacity))
                                      .Select(
                    capacity => ResponseHelper.JoinPair(
                        RichTextHelper.StripTags(capacity.GetLabelFor(pawn)).CapitalizeFirst(),
                        HealthCardUtility.GetEfficiencyLabel(pawn, capacity).First
                        )
                    )
                                      .ToArray();

                segments.Add(capacities.SectionJoin());
            }
            else
            {
                segments.Add("TKUtils.Responses.UnsupportedRace".LocalizeKeyed(pawn.kindDef.race.defName));
            }

            if (!TkSettings.ShowSurgeries)
            {
                return(segments.GroupedJoin());
            }

            BillStack surgeries = pawn.health.surgeryBills;

            if (surgeries?.Count <= 0)
            {
                return(segments.GroupedJoin());
            }

            string[] queued = surgeries !.Bills.Select(item => RichTextHelper.StripTags(item.LabelCap)).ToArray();

            segments.Add(ResponseHelper.JoinPair("TKUtils.PawnHealth.QueuedSurgeries".Localize(), queued.SectionJoin()));

            return(segments.GroupedJoin());
        }
Пример #8
0
 private void QuantityChanged(object sender, TextChangedEventArgs e)
 {
     _bill = (Bills)BindingContext;
 }
        public List <Bills> GetBillData(Bills bill)
        {
            List <Bills> CurrrentBill = _CodeFirstDataContext.PrintBills.Where(x => x.UserId == bill.UserId && x.Status.Equals("PENDING") && x.SessionId.Equals(HttpContext.Current.Session.SessionID)).ToList();

            return(CurrrentBill);
        }
Пример #10
0
 public bool add(Bills Bills)
 {
     return(_billDal.add(Bills));
 }
Пример #11
0
 public bool update(Bills Bills)
 {
     return(_billDal.update(Bills));
 }
Пример #12
0
 public void Update(Bills entity)
 {
     _billsDal.Update(entity);
 }
Пример #13
0
 public void Delete(Bills entity)
 {
     _billsDal.Delete(entity);
 }
Пример #14
0
 public void Add(Bills entity)
 {
     _billsDal.Add(entity);
 }
Пример #15
0
        public void LoadBill(int id)
        {
            var bill = Bills.Find(id);

            LoadBill(bill);
        }
Пример #16
0
        private void dgvBillsList_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                dgvBillsItemList.Rows.Clear();
                if (dgvBillsList.SelectedRows.Count > 0)
                {
                    Bills            bill             = (Bills)dgvBillsList.SelectedRows[0].Tag;
                    StockBillService stockBillService = new StockBillService();
                    bill = stockBillService.FindBill(bill.ID);
                    foreach (BillsItem item in bill.Items)
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        row.Tag = item;

                        DataGridViewTextBoxCell cell = null;
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Drugs.Code;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Drugs.Name;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.UnitPrice.ToString("0.00");
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Drugs.Category.Name;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Drugs.From.Name;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Drugs.Unit;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Drugs.Standard;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Count;
                        row.Cells.Add(cell);

                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = item.Money.ToString("0.00");
                        row.Cells.Add(cell);

                        dgvBillsItemList.Rows.Add(row);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.OnError(ex);
            }
        }
Пример #17
0
 public IBill ExecuteCreation(Bills bill) => _factories[bill].Create();
Пример #18
0
        public static object LoadBillText()
        {
            BillType type;
            int      session, number;

            ParseBill2(out session, out type, out number);

            string format = "html";

            string version   = HttpContext.Current.Request["version"];
            string compareto = HttpContext.Current.Request["compareto"];

            if (version == null)
            {
                string[][] statuses = Bills.GetBillTextStatusCodes(type);
                foreach (string[] s in statuses)
                {
                    if (System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, format, s[0], null)))
                    {
                        version = s[0];
                    }
                }
                if (version == null)
                {
                    if (format == "html")
                    {
                        format = "txt";
                        foreach (string[] s in statuses)
                        {
                            if (System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, format, s[0], null)))
                            {
                                version = s[0];
                            }
                        }
                        if (version == null)
                        {
                            return(TextNotAvailable());
                        }
                    }
                }

                compareto = null;
            }
            else
            {
                foreach (char c in version)
                {
                    if (!char.IsLetter(c) && !char.IsDigit(c))
                    {
                        throw new UserException("Invalid bill version code.");
                    }
                }

                if (compareto != null)
                {
                    foreach (char c in compareto)
                    {
                        if (!char.IsLetter(c) && !char.IsDigit(c))
                        {
                            throw new UserException("Invalid bill version code (compareto).");
                        }
                    }
                }
            }

            try {
                object ret = Bills.LoadBillText(session, type, number, format, version, compareto);
                if (ret is string)
                {
                    Hashtable x = new Hashtable();
                    x["text"] = ret;
                    ret       = x;
                }
                return(ret);
            } catch (System.IO.IOException e) {
                Console.Error.WriteLine(e);
                return(TextNotAvailable());
            }
        }
Пример #19
0
 public List <Bill> GetBills(BillSearchParams search)
 {
     return(Bills.ApplySearch(search)
            .Select(x => x.ToModel())
            .ToList());
 }
Пример #20
0
 public static XPathNavigator LoadBill(int session, string type, int number)
 {
     return(Bills.LoadBill(session, EnumsConv.BillTypeFromString(type), number));
 }
Пример #21
0
 internal override void AddBill(decimal bill)
 {
     Bills.Add(bill);
 }
Пример #22
0
        public ActionResult CreateBills()
        {
            Bills bills = new Bills();

            return(View(bills));
        }
Пример #23
0
 private bool validatePayment(Bills bill)
 {
     return(bill.IsPaid == false && bill.Amount > 0 && bill.Tips >= 0);
 }
Пример #24
0
        public PurchasePageViewModel(INavigationService navigationService,
                                     IGlobalService globalService,
                                     IDialogService dialogService,
                                     IAllocationService allocationService,
                                     IAdvanceReceiptService advanceReceiptService,
                                     IReceiptCashService receiptCashService,
                                     ICostContractService costContractService,
                                     ICostExpenditureService costExpenditureService,
                                     IInventoryService inventoryService,
                                     IPurchaseBillService purchaseBillService,
                                     IReturnReservationBillService returnReservationBillService,
                                     IReturnBillService returnBillService,
                                     ISaleReservationBillService saleReservationBillService,
                                     ISaleBillService saleBillService
                                     ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "采购单据";

            this.BillType = BillTypeEnum.PurchaseBill;

            this.Load = ReactiveCommand.Create(async() =>
            {
                ItemTreshold = 1;
                PageCounter  = 0;

                try
                {
                    Bills?.Clear();
                    int?manufacturerId = 0;
                    int?businessUserId = Filter.BusinessUserId;
                    string billNumber  = Filter.SerchKey;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                    int?makeuserId = Settings.UserId;
                    if (Filter.BusinessUserId == Settings.UserId)
                    {
                        businessUserId = 0;
                    }
                    int?wareHouseId = 0;
                    string remark   = "";
                    //获取未审核
                    bool?auditedStatus     = false;
                    bool?sortByAuditedTime = null;
                    bool?showReverse       = null;


                    var pending = new List <PurchaseBillModel>();


                    var result = await _purchaseBillService.GetPurchaseBillsAsync(makeuserId, businessUserId, manufacturerId, wareHouseId, billNumber, remark, null, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm    = s;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).Where(s => s.MakeUserId == Settings.UserId || s.BusinessUserId == Settings.UserId).ToList();
                    }
                    if (pending.Any())
                    {
                        Bills = new System.Collections.ObjectModel.ObservableCollection <PurchaseBillModel>(pending);
                    }
                    UpdateTitle();
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });



            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?manufacturerId = 0;
                            int?businessUserId = Filter.BusinessUserId;
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                            int?makeuserId = Settings.UserId;
                            if (Filter.BusinessUserId == Settings.UserId)
                            {
                                businessUserId = 0;
                            }
                            int?wareHouseId = 0;
                            string remark   = "";
                            //获取未审核
                            bool?auditedStatus     = false;
                            bool?sortByAuditedTime = null;
                            bool?showReverse       = null;

                            var items = await _purchaseBillService.GetPurchaseBillsAsync(makeuserId, businessUserId, manufacturerId, wareHouseId, billNumber, remark, null, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                            }
                            UpdateTitle();
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));

            //选择单据
            this.SelectedCommand = ReactiveCommand.Create <PurchaseBillModel>(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(PurchaseOrderBillPage), ("Bill", x), ("IsSubmitBill", true));
                }
            });


            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_VIEW_KEY, 9));

            this.BindBusyCommand(Load);
        }
Пример #25
0
        private void ToolBar1_ButtonClick(object sender, System.EventArgs e)
        {
            try
            {
                Btn btn = (Btn)sender;
                switch (btn.ID)
                {
                case BP.Web.Controls.NamesOfBtn.Export:
                case NamesOfBtn.Excel:     //数据导出
                    Bill        en  = new Bill();
                    Bills       ens = new Bills();
                    QueryObject qo  = new QueryObject(ens);
                    if (this.DoType == "My")
                    {
                        qo.AddWhere(BillAttr.FK_Emp, WebUser.No);
                        qo.addAnd();
                        qo.AddWhere(BillAttr.FK_Flow, this.FK_Flow);
                    }
                    else
                    {
                        qo = this.ToolBar1.GetnQueryObject(ens, en);
                    }

                    DataTable dt    = qo.DoQueryToTable();
                    DataTable myDT  = new DataTable();
                    Attrs     attrs = en.EnMap.Attrs;
                    foreach (Attr attr in attrs)
                    {
                        myDT.Columns.Add(new DataColumn(attr.Desc, typeof(string)));
                    }

                    foreach (DataRow dr in dt.Rows)
                    {
                        DataRow myDR = myDT.NewRow();
                        foreach (Attr attr in attrs)
                        {
                            myDR[attr.Desc] = dr[attr.Key];
                        }
                        myDT.Rows.Add(myDR);
                    }

                    string file = "";
                    try
                    {
                        file = this.ExportDGToExcel(myDT, en.EnDesc);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            file = this.ExportDGToExcel(ens.ToDataTableDescField(), en.EnDesc);
                        }
                        catch
                        {
                            throw new Exception("数据没有正确导出可能的原因之一是:系统管理员没正确的安装Excel组件,请通知他,参考安装说明书解决。@系统异常信息:" + ex.Message);
                        }
                    }
                    this.SetDGData();
                    return;

                case NamesOfBtn.Excel_S:     //数据导出.
                    Entities ens1 = this.SetDGData();
                    try
                    {
                        this.ExportDGToExcel(ens1.ToDataTableDesc(), this.HisEn.EnDesc);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("数据没有正确导出可能的原因之一是:系统管理员没正确的安装Excel组件,请通知他,参考安装说明书解决。@系统异常信息:" + ex.Message);
                    }
                    this.SetDGData();
                    return;

                case NamesOfBtn.Xml:     //数据导出
                    return;

                case "Btn_Print":      //数据导出.
                    return;

                default:
                    this.PageIdx = 1;
                    this.SetDGData(1);
                    this.ToolBar1.SaveSearchState(this.EnsName, null);
                    return;
                }
            }
            catch (Exception ex)
            {
                if (!(ex is System.Threading.ThreadAbortException))
                {
                    this.ResponseWriteRedMsg(ex);
                    //在这里显示错误
                }
            }
        }
Пример #26
0
 public void AddBill(Bill bill)
 {
     Bills.Add(bill);
 }
Пример #27
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     Bills ds = new Bills();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Пример #28
0
 /// <summary>
 /// public method to add bills to the drawer
 /// </summary>
 /// <param name="t">type of bill</param>
 /// <param name="q">quantity of bill</param>
 public void AddBill(Bills t, int q)
 {
     drawer.AddBill(t, q);
 }
Пример #29
0
 public ActionResult AddBill(Bills bill)
 {
     db.Bills.Add(bill);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #30
0
 /// <summary>
 /// public method to remove bills to the drawer
 /// </summary>
 /// <param name="t">type of bill</param>
 /// <param name="q">quantity of bill</param>
 public void RemoveBill(Bills t, int q)
 {
     drawer.RemoveBill(t, q);
 }
        /// <summary>
        /// Handles every single button click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtClick(object sender, RoutedEventArgs e)
        {
            switch (((Button)sender).Name)
            {
            case "IncreasePennies":
                ChangeOfProperty("Pennies", 0, .01);
                break;

            case "IncreaseNickels":
                ChangeOfProperty("Nickels", 0, .05);
                break;

            case "IncreaseDimes":
                ChangeOfProperty("Dimes", 0, .1);
                break;

            case "IncreaseQuarters":
                ChangeOfProperty("Quarters", 0, .25);
                break;

            case "IncreaseHalfDollars":
                ChangeOfProperty("HalfDollars", 0, .5);
                break;

            case "IncreaseDollars":
                ChangeOfProperty("Dollars", 0, 1);
                break;

            case "IncreaseOnes":
                ChangeOfProperty("Ones", 0, 1);
                break;

            case "IncreaseTwos":
                ChangeOfProperty("Twos", 0, 2);
                break;

            case "IncreaseFives":
                ChangeOfProperty("Fives", 0, 5);
                break;

            case "IncreaseTens":
                ChangeOfProperty("Tens", 0, 10);
                break;

            case "IncreaseTwenties":
                ChangeOfProperty("Twenties", 0, 20);
                break;

            case "IncreaseFifties":
                ChangeOfProperty("Fifties", 0, 50);
                break;

            case "IncreaseHundreds":
                ChangeOfProperty("Hundreds", 0, 100);
                break;

            case "DecreasePennies":
                if (Pennies != 0)
                {
                    ChangeOfProperty("Pennies", 1, .01);
                }
                break;

            case "DecreaseNickels":
                if (Nickels != 0)
                {
                    ChangeOfProperty("Nickels", 1, .05);
                }
                break;

            case "DecreaseDimes":
                if (Dimes != 0)
                {
                    ChangeOfProperty("Dimes", 1, .1);
                }
                break;

            case "DecreaseQuarters":
                if (Quarters != 0)
                {
                    ChangeOfProperty("Quarters", 1, .25);
                }
                break;

            case "DecreaseHalfDollars":
                if (HalfDollars != 0)
                {
                    ChangeOfProperty("HalfDollars", 1, .5);
                }
                break;

            case "DecreaseDollars":
                if (Dollars != 0)
                {
                    ChangeOfProperty("Dollars", 1, 1);
                }
                break;

            case "DecreaseOnes":
                if (Ones != 0)
                {
                    ChangeOfProperty("Ones", 1, 1);
                }
                break;

            case "DecreaseTwos":
                if (Twos != 0)
                {
                    ChangeOfProperty("Twos", 1, 2);
                }
                break;

            case "DecreaseFives":
                if (Fives != 0)
                {
                    ChangeOfProperty("Fives", 1, 5);
                }
                break;

            case "DecreaseTens":
                if (Tens != 0)
                {
                    ChangeOfProperty("Tens", 1, 10);
                }
                break;

            case "DecreaseTwenties":
                if (Twenties != 0)
                {
                    ChangeOfProperty("Twenties", 1, 20);
                }
                break;

            case "DecreaseFifties":
                if (Fifties != 0)
                {
                    ChangeOfProperty("Fifties", 1, 50);
                }
                break;

            case "DecreaseHundreds":
                if (Hundreds != 0)
                {
                    ChangeOfProperty("Hundreds", 1, 100);
                }
                break;

            case "CancelPay":
                NewOrder();
                break;

            case "CardPay":
                CardTerminal ct = new CardTerminal();
                ResultCode   r  = ct.ProcessTransaction(Total);
                switch (r)
                {
                case ResultCode.Success:
                    Paid = Total;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Paid"));
                    Receipt(1);
                    break;

                case ResultCode.InsufficentFunds:
                    MessageBox.Show("Error: Card has insufficient funds\n\nTry different card or pay with cash.");
                    Error.Text    = "Error: Card has insufficient";
                    ExtError.Text = "funds";
                    break;

                case ResultCode.CancelledCard:
                    MessageBox.Show("Error: Card cancelled\n\nTry different card or pay with cash.");
                    Error.Text    = "Error: Card cancelled";
                    ExtError.Text = "";
                    break;

                case ResultCode.ReadError:
                    MessageBox.Show("Error: Bad swipe\n\nPlease try swiping again.");
                    Error.Text    = "Error: Bad swipe";
                    ExtError.Text = "";
                    break;

                case ResultCode.UnknownErrror:
                    MessageBox.Show("Error: Unknown error\n\n Please try swiping again.");
                    Error.Text    = "Error: Unknown error";
                    ExtError.Text = "";
                    break;
                }
                break;

            case "CashPay":
                foreach (Coins c in Enum.GetValues(typeof(Coins)) as Coins[])
                {
                    switch (c)
                    {
                    case Coins.Penny:
                        cd.AddCoin(c, Pennies);
                        break;

                    case Coins.Nickel:
                        cd.AddCoin(c, Nickels);
                        break;

                    case Coins.Dime:
                        cd.AddCoin(c, Dimes);
                        break;

                    case Coins.Quarter:
                        cd.AddCoin(c, Quarters);
                        break;

                    case Coins.HalfDollar:
                        cd.AddCoin(c, HalfDollars);
                        break;

                    case Coins.Dollar:
                        cd.AddCoin(c, Dollars);
                        break;
                    }
                }
                foreach (Bills c in Enum.GetValues(typeof(Bills)) as Bills[])
                {
                    switch (c)
                    {
                    case Bills.One:
                        cd.AddBill(c, Ones);
                        break;

                    case Bills.Two:
                        cd.AddBill(c, Twos);
                        break;

                    case Bills.Five:
                        cd.AddBill(c, Fives);
                        break;

                    case Bills.Ten:
                        cd.AddBill(c, Tens);
                        break;

                    case Bills.Twenty:
                        cd.AddBill(c, Twenties);
                        break;

                    case Bills.Fifty:
                        cd.AddBill(c, Fifties);
                        break;

                    case Bills.Hundred:
                        cd.AddBill(c, Hundreds);
                        break;
                    }
                }
                if (LeftToPay < 0)
                {
                    Change = LeftToPay;
                    double ch = Change;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Change"));
                    var changeC = new List <Coins>();
                    var changeB = new List <Bills>();
                    var c       = Enum.GetValues(typeof(Coins)) as Coins[];
                    var b       = Enum.GetValues(typeof(Bills)) as Bills[];
                    Array.Reverse(c);
                    Array.Reverse(b);
                    int    bi = 0;
                    double v  = Math.Round(0.0, 2);
                    foreach (Bills i in b)
                    {
                        Bills j = i;
                        switch (j)
                        {
                        case Bills.One:
                            bi = cd.Ones;
                            v  = 1;
                            break;

                        case Bills.Two:
                            bi = cd.Twos;
                            v  = 2;
                            if (bi == 0)
                            {
                                j--;
                                goto case Bills.One;
                            }
                            break;

                        case Bills.Five:
                            bi = cd.Fives;
                            v  = 5;
                            break;

                        case Bills.Ten:
                            bi = cd.Tens;
                            v  = 10;
                            break;

                        case Bills.Twenty:
                            bi = cd.Twenties;
                            v  = 20;
                            break;

                        case Bills.Fifty:
                            bi = cd.Fifties;
                            v  = 50;
                            break;

                        case Bills.Hundred:
                            bi = cd.Hundreds;
                            v  = 100;
                            break;
                        }
                        while (ch - v >= 0)
                        {
                            if (bi == 0)
                            {
                                BreakBills(j);
                            }
                            ch -= v;
                            cd.RemoveBill(j, 1);
                            changeB.Add(j);
                            bi--;
                        }
                    }
                    foreach (Coins i in c)
                    {
                        Coins j = i;
                        switch (j)
                        {
                        case Coins.Penny:
                            bi = cd.Pennies;
                            v  = 0.01;
                            break;

                        case Coins.Nickel:
                            bi = cd.Nickels;
                            v  = 0.05;
                            break;

                        case Coins.Dime:
                            bi = cd.Dimes;
                            v  = 0.10;
                            break;

                        case Coins.Quarter:
                            bi = cd.Quarters;
                            v  = 0.25;
                            break;

                        case Coins.HalfDollar:
                            bi = cd.HalfDollars;
                            v  = 0.50;
                            if (bi == 0)
                            {
                                j--;
                                goto case Coins.Quarter;
                            }
                            break;

                        case Coins.Dollar:
                            bi = cd.Dollars;
                            v  = 1.00;
                            if (bi == 0)
                            {
                                j--;
                                goto case Coins.HalfDollar;
                            }
                            break;
                        }
                        while (ch - v >= 0)
                        {
                            if (bi == 0)
                            {
                                int   be = 0;
                                Coins co = j + 1;
                                switch (co)
                                {
                                case Coins.Nickel:
                                    be = cd.Nickels;
                                    if (be == 0)
                                    {
                                        co++;
                                        goto case Coins.Dime;
                                    }
                                    break;

                                case Coins.Dime:
                                    be = cd.Dimes;
                                    if (be == 0)
                                    {
                                        co++;
                                        goto case Coins.Quarter;
                                    }
                                    break;

                                case Coins.Quarter:
                                    be = cd.Quarters;
                                    if (be == 0)
                                    {
                                        co++;
                                        goto case Coins.HalfDollar;
                                    }
                                    break;

                                case Coins.HalfDollar:
                                    be = cd.HalfDollars;
                                    if (be == 0)
                                    {
                                        co++;
                                        goto case Coins.Dollar;
                                    }
                                    break;

                                case Coins.Dollar:
                                    be = cd.Dollars;
                                    if (be == 0)
                                    {
                                        if (cd.Ones > 0)
                                        {
                                            cd.RemoveBill(Bills.One, 1);
                                            cd.AddCoin(Coins.Dollar, 1);
                                        }
                                        else
                                        {
                                            BreakBills(Bills.One);
                                            goto case Coins.Dollar;
                                        }
                                    }
                                    break;

                                default:
                                    new NotImplementedException();
                                    break;
                                }
                                switch (co)
                                {
                                case Coins.Nickel:
                                    cd.RemoveCoin(Coins.Nickel, 1);
                                    cd.AddCoin(Coins.Penny, 5);
                                    break;

                                case Coins.Dime:
                                    cd.RemoveCoin(Coins.Dime, 1);
                                    cd.AddCoin(Coins.Nickel, 2);
                                    if (j == Coins.Nickel)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        goto case Coins.Nickel;
                                    }

                                case Coins.Quarter:
                                    cd.RemoveCoin(Coins.Quarter, 1);
                                    cd.AddCoin(Coins.Dime, 2);
                                    cd.AddCoin(Coins.Nickel, 1);
                                    if (j == Coins.Dime)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        goto case Coins.Dime;
                                    }

                                case Coins.HalfDollar:
                                    cd.RemoveCoin(Coins.HalfDollar, 1);
                                    cd.AddCoin(Coins.Quarter, 2);
                                    if (j == Coins.Quarter)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        goto case Coins.Quarter;
                                    }

                                case Coins.Dollar:
                                    cd.RemoveCoin(Coins.Dollar, 1);
                                    cd.AddCoin(Coins.Quarter, 4);
                                    if (j == Coins.Quarter)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        goto case Coins.Quarter;
                                    }

                                default:
                                    new NotImplementedException();
                                    break;
                                }
                            }
                            ch -= v;
                            cd.RemoveCoin(j, 1);
                            changeC.Add(j);
                            bi--;
                        }
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.Append("Change to give back:\n\t");
                    foreach (Bills bill in changeB)
                    {
                        sb.Append(bill.ToString() + "\n\t");
                    }
                    foreach (Coins coin in changeC)
                    {
                        sb.Append(coin.ToString() + "\n\t");
                    }
                    MessageBox.Show(sb.ToString());
                }
                while (cd.Pennies >= 105)
                {
                    cd.RemoveCoin(Coins.Penny, 5);
                    cd.AddCoin(Coins.Nickel, 1);
                }
                while (cd.Nickels >= 82)
                {
                    cd.RemoveCoin(Coins.Nickel, 2);
                    cd.AddCoin(Coins.Dime, 1);
                }
                while (cd.Dimes >= 105)
                {
                    cd.RemoveCoin(Coins.Dime, 5);
                    cd.AddCoin(Coins.Quarter, 2);
                }
                while (cd.Quarters >= 44)
                {
                    cd.RemoveCoin(Coins.Quarter, 4);
                    cd.AddBill(Bills.One, 1);
                }
                while (cd.HalfDollars >= 2)
                {
                    cd.RemoveCoin(Coins.HalfDollar, 2);
                    cd.AddBill(Bills.One, 1);
                }
                while (cd.Dollars >= 5)
                {
                    cd.RemoveCoin(Coins.Dollar, 5);
                    cd.AddBill(Bills.Five, 1);
                }
                while (cd.Ones >= 80)
                {
                    cd.RemoveBill(Bills.One, 5);
                    cd.AddBill(Bills.Five, 1);
                }
                while (cd.Twos >= 5)
                {
                    cd.RemoveBill(Bills.Two, 5);
                    cd.AddBill(Bills.Ten, 1);
                }
                while (cd.Fives >= 8)
                {
                    cd.RemoveBill(Bills.Five, 2);
                    cd.AddBill(Bills.Ten, 1);
                }
                while (cd.Tens >= 4)
                {
                    cd.RemoveBill(Bills.Ten, 2);
                    cd.AddBill(Bills.Twenty, 1);
                }
                while (cd.Twenties >= 5)
                {
                    cd.RemoveBill(Bills.Twenty, 5);
                    cd.AddBill(Bills.Hundred, 1);
                }
                while (cd.Fifties >= 2)
                {
                    cd.RemoveBill(Bills.Fifty, 2);
                    cd.AddBill(Bills.Hundred, 1);
                }
                Receipt(0);
                break;
            }
            if (LeftToPay <= 0)
            {
                CashPay.IsEnabled = true;
            }
            else
            {
                CashPay.IsEnabled = false;
            }
            if (Paid != 0)
            {
                CardPay.IsEnabled = false;
            }
            else
            {
                CardPay.IsEnabled = true;
            }
        }
Пример #32
0
 private void linkLabel_bills_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     Bills bills = new Bills();
     bills.setCustomerId(selectedCustomerId);
     bills.Show();
 }