Exemplo n.º 1
0
        //没有加入cashDirection和arrearDirection, status, hide
        public void Update(PayReceipt info)
        {
            string commandText = string.Format("update PayReceipt set serial='{0}', bill_time='{1}', comment='{2}', customer_id={3}, bill_type={4}, handle_people='{5}', previousArrears={6}, amount={7}, thisPayed={8}, status={9} where ID={10}",
                                               info.serial, info.bill_time, info.comment, info.customer_id <= 0 ? "null" : info.customer_id.ToString(), (int)info.bill_type, info.handle_people, info.previousArrears, info.amount, info.thisPayed, info.status, info.id);

            DbHelperAccess.executeNonQuery(commandText);
        }
Exemplo n.º 2
0
        private IReceipt PayReceipt(PayReceipt request)
        {
            //Check receipt is available
            var existingReceipt = receiptRepo.GetReceipt(request.Code);

            if (existingReceipt == null)
            {
                throw new Exception(ReceiptMessage.ReceiptDoesNotExist);
            }

            //Check ticket is available
            var ticket = ticketRepo.GetTicket(existingReceipt.TicketId);

            if (ticket == null)
            {
                throw new Exception(TicketMessage.TicketDoesNotFound);
            }

            //Check ticket does not sold before
            var status = ticketStatusRepo.GetTicketStatus(ticket.UserAuthId, ticket.Code, existingReceipt.DepartureDate, ticket.DepartureTime);

            if (status.Status.Equals((int)TicketStatusConstant.Sold))
            {
                throw new Exception(TicketMessage.TickerIsSold);
            }

            //Update receipt
            var newReceipt = receiptRepo.UpdateReceipt(existingReceipt, ToPayReceipt(existingReceipt, request));

            //Update ticket status
            var newStatus = ticketStatusRepo.UpdateTicketStatus(ticket.UserAuthId, ticket.Code, newReceipt.DepartureDate, ticket.DepartureTime, (int)TicketStatusConstant.Sold);

            return(newReceipt);
        }
Exemplo n.º 3
0
        private static IReceipt ToPayReceipt(IReceipt existingReceipt, PayReceipt request)
        {
            var receipt = ((Receipt.Repository.OrmLite.Receipt)existingReceipt).CreateCopy();

            receipt.Status = (int)ReceiptStatusConstant.Paid;
            receipt.Note   = request.Note;
            return(receipt);
        }
Exemplo n.º 4
0
        public object Post(PayReceipt request)
        {
            //Create new receipt
            var receipt = PayReceipt(request);

            return(new PayReceiptResponse()
            {
                Status = (int)CommonStatus.Success,
                Data = receipt.ConvertTo <Receipt.ServiceModel.Types.Receipt>()
            });
        }
Exemplo n.º 5
0
        private PayReceipt formatPayReceipt(DataRow dr)
        {
            PayReceipt payReceipt = new PayReceipt();

            if (dr != null)
            {
                payReceipt.id        = (int)dr["ID"];
                payReceipt.serial    = dr["serial"] as string;
                payReceipt.bill_time = (DateTime)dr["bill_time"];
                payReceipt.comment   = dr["comment"] as string;
                payReceipt.status    = (int)dr["status"];
                payReceipt.bill_type = (PayReceipt.BillType)dr["bill_type"];

                int customerID = 0;
                if (int.TryParse(dr["customer_id"].ToString(), out customerID))
                {
                    payReceipt.customer_id = customerID;
                }

                payReceipt.handle_people = dr["handle_people"] as string;

                double previousArrears, amount, thisPayed;
                if (double.TryParse(dr["previousArrears"].ToString(), out previousArrears))
                {
                    payReceipt.previousArrears = previousArrears;
                }
                if (double.TryParse(dr["amount"].ToString(), out amount))
                {
                    payReceipt.amount = amount;
                }
                if (double.TryParse(dr["thisPayed"].ToString(), out thisPayed))
                {
                    payReceipt.thisPayed = thisPayed;
                }

                payReceipt.cashDirection   = (int)dr["cashDirection"];
                payReceipt.arrearDirection = (int)dr["arrearDirection"];

                try
                {
                    payReceipt.customerName = dr["name"] as string;
                }
                catch { }
                payReceipt.hide = (int)dr["hide"];

                return(payReceipt);
            }
            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// for init circulation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void initPayReceipt()
        {
            if (openMode == 0)
            {
                switchMode(openMode);
                int max = PayReceiptDao.getInstance().getMaxCode(conf.serial);
                this.textBox_serial.Text     = string.Format("{0}-{1}-{2:0000}", conf.serial, DateTime.Now.ToString("yyyyMMdd"), max + 1);
                this.lookupText1.LookupArg   = null;
                this.lookupText1.Text_Lookup = null;
                this.dateTime_time.Value     = DateTime.Now;
                this.textBox_operator.Text   = null;

                this.textBox_sum.Text             = null;
                this.textBox_previousArrears.Text = null;
                this.textBox_thisPayed.Text       = null;
                this.textBox_accumulative.Text    = null;

                this.textBox_comment.Text = null;

                this.resetNeedSave(false);

                return;
            }

            payReceipt = PayReceiptDao.getInstance().FindByID(payReceiptID);

            this.textBox_serial.Text   = payReceipt.serial;
            this.dateTime_time.Value   = payReceipt.bill_time;
            this.textBox_comment.Text  = payReceipt.comment;
            this.textBox_operator.Text = payReceipt.handle_people;

            this.textBox_sum.Text = payReceipt.amount.ToString();

            this.lookupText1.LookupArg   = new LookupArg(payReceipt.customer_id, payReceipt.customerName);
            this.lookupText1.Text_Lookup = payReceipt.customerName;

            //如果是未审核状态,以前欠款应该如何生成?
            if (payReceipt.status > 1)
            {
                this.textBox_previousArrears.Text = payReceipt.previousArrears.ToString();
            }

            this.textBox_thisPayed.Text = payReceipt.thisPayed.ToString();

            openMode = payReceipt.status;

            this.resetNeedSave(false);
            this.switchMode(payReceipt.status);
        }
Exemplo n.º 7
0
 public bool Insert(PayReceipt info, out int id)
 {
     try
     {
         string commandText = string.Format("insert into PayReceipt(serial, bill_time, comment, customer_id, bill_type, handle_people, previousArrears, amount, status, cashDirection, arrearDirection, thisPayed, hide) values('{0}', '{1}', '{2}', {3}, {4}, '{5}', {6}, {7}, {8}, {9}, {10}, {11}, {12})",
                                            info.serial, info.bill_time, info.comment, info.customer_id <= 0 ? "null" : info.customer_id.ToString(), (int)info.bill_type, info.handle_people, info.previousArrears, info.amount, info.status, info.cashDirection, info.arrearDirection, info.thisPayed, info.hide);
         DbHelperAccess.executeNonQuery(commandText);
         id = DbHelperAccess.executeMax("ID", "PayReceipt");
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// for get value from controls
        /// </summary>
        //没有获取status
        protected bool getPayReceipt(out PayReceipt payReceipt)
        {
            payReceipt               = new PayReceipt();
            payReceipt.id            = this.payReceiptID;
            payReceipt.bill_type     = conf.type;
            payReceipt.bill_time     = this.dateTime_time.Value;
            payReceipt.handle_people = textBox_operator.Text;
            payReceipt.comment       = textBox_comment.Text;

            payReceipt.cashDirection   = conf.cashDirection;
            payReceipt.arrearDirection = conf.arrearDirection;

            string name;

            if (ValidateUtility.getName(this.textBox_serial, this.errorProvider1, out name) == false)
            {
                return(false);
            }
            payReceipt.serial = name;

            if (this.lookupText1.Visible == true && ValidateUtility.getLookupValueID(this.lookupText1, this.errorProvider1, out payReceipt.customer_id) == false)
            {
                return(false);
            }

            double sum = 0, pay, previousArrears;

            if ((this.panel_sum.Visible == false || ValidateUtility.getDouble(this.textBox_sum, this.errorProvider1, true, true, out sum))
                //如果是退点,本单付款就不是必填,否则为必填
                && (this.label_pay_need.Visible == true && ValidateUtility.getDouble(this.textBox_thisPayed, this.errorProvider1, true, true, out pay) || this.label_pay_need.Visible == false && ValidateUtility.getDouble(this.textBox_thisPayed, this.errorProvider1, false, true, out pay)) &&
                ValidateUtility.getDouble(this.textBox_previousArrears, this.errorProvider1, false, false, out previousArrears))
            {
                payReceipt.amount = sum;
                //欠款用的是呈现给用户看得,一般为正数
                payReceipt.previousArrears = previousArrears;
                payReceipt.thisPayed       = pay;
            }
            else
            {
                return(false);
            }

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

            PayReceipt maxPr = PayReceiptDao.getInstance().FindLastestByCustomerID(this.payReceipt.customer_id, false);

            if (maxPr != null && !maxPr.serial.Equals(this.payReceipt.serial))
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", maxPr.serial), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            ProductCirculation pc = cirDao.FindLastestByCustomerID(this.payReceipt.customer_id, false);

            if (pc != null && pc.CirculationTime > payReceipt.bill_time)
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", pc.Code), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //直接取以前的欠款,简单
            double arrear;

            double.TryParse(this.textBox_previousArrears.Text, out arrear);

            CustomerDao.getInstance().update_arrear(this.payReceipt.customer_id, this.conf.arrearDirection * arrear);
            PayReceiptDao.getInstance().UpdateStatus(this.payReceipt.id, 1);

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

            openMode = 1;
            this.switchMode(1);

            this.invokeUpdateNotify(this.conf.finishNotifyType);
        }
Exemplo n.º 10
0
        private void generatePayReceipt(double arrearDif, double previousArrear, int customerID)
        {
            PayReceipt payReceipt = new PayReceipt();

            payReceipt.bill_type       = PayReceipt.BillType.ChangeArrear;
            payReceipt.bill_time       = DateTime.Now;
            payReceipt.cashDirection   = arrearDif > 0 ? -1 : 1;
            payReceipt.arrearDirection = previousArrear + arrearDif > 0 ? 1 : -1;

            int max = PayReceiptDao.getInstance().getMaxCode("QKTZ");

            payReceipt.serial = string.Format("{0}-{1}-{2:0000}", "QKTZ", DateTime.Now.ToString("yyyyMMdd"), max + 1);

            payReceipt.customer_id = customerID;

            payReceipt.amount = Math.Abs(arrearDif);
            //previousArrear用的是正数表示
            payReceipt.previousArrears = Math.Round(previousArrear * payReceipt.arrearDirection, 2);

            payReceipt.status  = 4;
            payReceipt.comment = "修改欠款数据时自动生成";
            PayReceiptDao.getInstance().Insert(payReceipt, out payReceipt.id);
        }
Exemplo n.º 11
0
        //弃核
        private void toolStripButton_finishCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否弃核,退回到未审核状态?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            //判断是否支持负库存
            string negative = ConfDao.getInstance().Get(20);

            if ((string.IsNullOrEmpty(negative) || negative != "1") && conf.productDirection == 1)
            {
                foreach (ProductCirculationRecord record in records)
                {
                    int leftNum = cirDao.getProductDao().FindNumByID(record.ProductID);
                    if (record.TotalNum > leftNum)
                    {
                        MessageBox.Show(string.Format("{0} 库存不足,数量为{1},弃核失败!", record.ProductName, leftNum), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Enabled = true;
                        return;
                    }
                }
            }

            //circulation不用重新get,因为考虑到审核过的有重新init,而且其值不能改变
            ProductCirculation maxCir = cirDao.FindLastestByCustomerID(this.circulation.CustomerID, false);

            if (maxCir != null && !maxCir.Code.Equals(circulation.Code))
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", maxCir.Code), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            PayReceipt payReceipt = PayReceiptDao.getInstance().FindLastestByCustomerID(circulation.CustomerID, false);

            if (payReceipt != null && circulation.CirculationTime < payReceipt.bill_time)
            {
                MessageBox.Show(string.Format("弃核失败,在此单之后存在已审核的单据,请先弃核{0}", payReceipt.serial), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            foreach (ProductCirculationRecord record in records)
            {
                //更新产品数量
                this.cancelUpdateCostAndProfit(circulation, record);
            }

            double arrear;

            double.TryParse(this.textBox_previousArrears.Text, out arrear);

            CustomerDao.getInstance().update_arrear(circulation.CustomerID, conf.arrearsDirection * arrear);
            cirDao.UpdateStatus(circulationID, 1);

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

            openMode = 1;
            this.switchMode(1);

            this.invokeUpdateNotify(this.conf.finishNotifyType);
        }
Exemplo n.º 12
0
        private void setLastPayReceipt(int customerId)
        {
            ProductCirculation cir            = cirDao.FindLastestByCustomerID(customerId, true);
            PayReceipt         payReceipt     = PayReceiptDao.getInstance().FindLastestByCustomerID(customerId, true);
            double             lastPayReceipt = 0;
            int      cashDirection            = 0;
            DateTime dt = DateTime.Now;

            if (cir != null && payReceipt != null)
            {
                if (cir.CirculationTime < payReceipt.bill_time)
                {
                    lastPayReceipt = payReceipt.thisPayed;
                    cashDirection  = payReceipt.cashDirection;
                    dt             = payReceipt.bill_time;
                }
                else
                {
                    lastPayReceipt = cir.ThisPayed;
                    cashDirection  = cir.FlowType * -1;
                    dt             = cir.CirculationTime;
                }
            }
            else if (cir != null && payReceipt == null)
            {
                lastPayReceipt = cir.ThisPayed;
                cashDirection  = cir.FlowType * -1;
                dt             = cir.CirculationTime;
            }
            else if (cir == null && payReceipt != null)
            {
                lastPayReceipt = payReceipt.thisPayed;
                cashDirection  = payReceipt.cashDirection;
                dt             = payReceipt.bill_time;
            }

            if (lastPayReceipt == 0 || cashDirection == 0)
            {
                label_lastPayReceipt.Text = "";
            }
            else
            {
                label_lastPayReceipt.Text = string.Format("{0}{1:0.00}元({2:yyyy/MM/dd})", cashDirection == -1 ? LabelUtility.LAST_PAY : LabelUtility.LAST_RECEIPT, lastPayReceipt, dt);
            }

            Customer customer = CustomerDao.getInstance().FindByID(customerId);

            if (customer.arrear < 0)
            {
                ProductCirculation lastCir = cirDao.FindLastestAccReceiptZero(customerId);
                PayReceipt         lastPay = PayReceiptDao.getInstance().FindLastestAccReceiptZero(customerId);
                DateTime           lastDt;
                if (lastCir != null && lastPay != null)
                {
                    lastDt = lastCir.CirculationTime.CompareTo(lastPay.bill_time) < 0 ? lastCir.CirculationTime : lastPay.bill_time;
                }
                else if (lastCir == null && lastPay != null)
                {
                    lastDt = lastPay.bill_time;
                }
                else if (lastCir != null && lastPay == null)
                {
                    lastDt = lastCir.CirculationTime;
                }
                else
                {
                    return;
                }


                TimeSpan ts = DateTime.Now.Subtract(lastDt);
                label_lastPayReceipt.Text += string.Format("欠款{0}天", ts.Days);
            }
        }