Exemplo n.º 1
0
        /// <summary>
        /// for event
        /// </summary>
        ///
        protected void toolStripButton_save_Click(object sender, EventArgs e)
        {
            bool isSellCorrect = getCard(out card);

            if (isSellCorrect == false)
            {
                return;
            }

            card.Status = 1;
            //
            if (this.openMode == 1 && CardDao.getInstance().FindByID(card.ID) == null)
            {
                MessageBox.Show("该单据已经被删除了。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //this.Enabled = true;
                return;
            }

            try
            {
                if (openMode == 0)
                {
                    CardDao.getInstance().Insert(card, out cardID);
                    MessageBox.Show(string.Format("增加{0}成功!", this.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    openMode = 1;
                }
                else if (openMode == 1)
                {
                    CardDao.getInstance().Update(card);
                    MessageBox.Show(string.Format("保存{0}成功!", this.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                //主要是保存按钮恢复到初始状态
                this.initCard();
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存有误,可能是往来单位或货品属性被修改过,请重新编辑!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //so important: if edit ,it should be refresh also, because edit will del exist item and add new item
            this.invokeUpdateNotify(UpdateType.CardUpdate);
        }
Exemplo n.º 2
0
        private async Task SaveReview(int cardInstanceId)
        {
            using (var cardDao = new CardDao(DbContext))
            {
                CardInstance cardInstance = await cardDao.GetCardInstanceWithPlan(cardInstanceId);

                if (cardInstance == null)
                {
                    return;
                }

                DateTimeOffset now  = DateTimeOffset.Now;
                CardPlan       plan = cardInstance.Plan;
                if (plan.NextDate != null &&
                    now < plan.NextDate)
                {
                    return;
                }

                var    value       = int.Parse(GetParameter("value"));
                Values reviewValue = GetValueFromOrdinal(value);

                PlannerResult plannerResult = Planner.PlanNext(
                    reviewValue,
                    now,
                    plan.LastDate);

                plan.LastDate = now;
                plan.LastDays = plannerResult.PassedDays;
                plan.NextDate = plannerResult.NextDate;
                plan.NextDays = plannerResult.DaysNext;

                var review = cardInstance.AddReview();
                review.DateTime = now;
                review.Value    = reviewValue;

                await cardDao.UpdateCardInstance(cardInstance);
            }
        }
Exemplo n.º 3
0
        //弃核
        private void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            if (ConsumeDao.getInstance().FindList(cardID, 0).Count > 0)
            {
                MessageBox.Show("弃核失败,该卡片已经消费过,请先删除相应的消费。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            card.Status   = 1;
            card.CardTime = DateTime.Now;

            CardDao.getInstance().Update(card);

            MessageBox.Show("弃核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.initCard();

            this.invokeUpdateNotify(UpdateType.CardUpdate);
        }
Exemplo n.º 4
0
        //弃核
        private void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            List <Consume> cons = ConsumeDao.getInstance().FindList(consume.CardID, 0);

            if (cons[cons.Count - 1].ID > consume.ID)
            {
                MessageBox.Show("弃核失败,该卡片后面还有消费,请先删除相应的消费。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            consume.Status      = 1;
            consume.ConsumeTime = DateTime.Now;
            ConsumeDao.getInstance().Update(consume);

            //注意这里,这样合不合理,如果通过dao find出来就没问题,如果是this.getConsume就不行,getConsume后,还是重新find一下,这样就没问题
            Card card = consume.Card;

            if (card.LeftNumber == 0)
            {
                card.Status = 3;
            }
            card.LeftNumber += consume.Number;

            CardDao.getInstance().Update(card);

            MessageBox.Show("弃核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.initConsume();

            this.invokeUpdateNotify(UpdateType.CardUpdate);
            this.invokeUpdateNotify(UpdateType.ConsumeUpdate);
        }
Exemplo n.º 5
0
        public List <OrderDetails> ViewOrdersByUser(long usrId, int startIndex, int count)
        {
            UserProfile User = UserProfileDao.Find(usrId);

            List <OrderDetails> ordersDetails = new List <OrderDetails>();

            List <Order> orders = User.Orders.ToList();

            int c = 0;

            for (int i = startIndex; i < orders.Count; i++)
            {
                if (c == count)
                {
                    break;
                }
                List <OrderLine> orderLines = orders.ElementAt(i).OrderLines.ToList();

                List <OrderLineDetails> orderLinesDetails = new List <OrderLineDetails>();
                for (int j = 0; j < orderLines.Count; j++)
                {
                    string           productName   = orderLines.ElementAt(j).Product.name;
                    int              numberOfUnits = orderLines.ElementAt(j).numberOfUnits;
                    float            unitPrize     = (float)orderLines.ElementAt(j).unitPrize;
                    OrderLineDetails orderLine     = new OrderLineDetails(orders.ElementAt(i).orderId, productName, numberOfUnits, unitPrize);
                    orderLinesDetails.Add(orderLine);
                }
                long     orderId       = orders.ElementAt(i).orderId;
                string   cardNumber    = CardDao.Find(orders.ElementAt(i).idCard).cardNumber;
                int      postalAddress = orders.ElementAt(i).postalAddress;
                DateTime orderDate     = orders.ElementAt(i).orderDate;
                ordersDetails.Add(new OrderDetails(orderId, usrId, cardNumber, postalAddress, orderDate, orderLinesDetails));
                c++;
            }
            return(ordersDetails);
        }