Example #1
0
        private void LoadPawnageInfo(int intTicketID)
        {
            m_TicketID = intTicketID;
            DDPawnTicket newTicket = new DDPawnTicket("TicketID", intTicketID);

            Query query = new Query(DDOperation.Schema);

            query.AddWhere("TicketID", intTicketID);
            query.AddWhere("OperationType", 4);
            query.AddWhere("NextOperationID", 0);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.dataGridView1.Rows.Add(1);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["PawnageID"].Value   = dt.Rows[i]["PawnageID"];
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["OperationID"].Value = dt.Rows[i]["OperationID"];
                DDPawnageInfo pawnageInfo = new DDPawnageInfo("PawnageID", dt.Rows[i]["PawnageID"]);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["TicketNumber"].Value = newTicket.TicketNumber;
                DDPawnageClass newClass = new DDPawnageClass("ClassID", pawnageInfo.ClassID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ClassName"].Value    = newClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["CloseDate"].Value    = dt.Rows[i]["OperationDate"];
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Amount"].Value       = dt.Rows[i]["Amount"];
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ReckonAmount"].Value = dt.Rows[i]["Amount"];
            }
        }
Example #2
0
        public void Insert(int?ClassID, int?ParentID, int?StatusID, string CountNumber, string Weight, string Price, string FeeRate, string InterestRate, string DiscountPercent, string Description, string Remark, string StartDate, string EndDate, string PhotoPath)
        {
            DDPawnageInfo item = new DDPawnageInfo();

            item.ClassID = ClassID;

            item.ParentID = ParentID;

            item.StatusID = StatusID;

            item.CountNumber = CountNumber;

            item.Weight = Weight;

            item.Price = Price;

            item.FeeRate = FeeRate;

            item.InterestRate = InterestRate;

            item.DiscountPercent = DiscountPercent;

            item.Description = Description;

            item.Remark = Remark;

            item.StartDate = StartDate;

            item.EndDate = EndDate;

            item.PhotoPath = PhotoPath;


            item.Save(UserName);
        }
Example #3
0
        private void LoadTicketInfo(int intTicketID)
        {
            m_TicketID = intTicketID;
            double       TotalLastInterestFee = 0;
            double       LastInterestFee      = 0;
            DDPawnTicket newTicket            = new DDPawnTicket("TicketID", intTicketID);

            this.lblOldTicketNum.Text = newTicket.TicketNumber;
            this.tbxStartDate.Text    = newTicket.EndDate;
            this.tbxEndDate.Text      = newTicket.EndDate;
            m_EndDate = newTicket.EndDate;
            DateTime operationDate = DateTime.Now;

            this.tbxOperationDate.Text = operationDate.Year.ToString() + "-" + operationDate.Month.ToString() + "-" + operationDate.Day.ToString();

            Query query = new Query(DDOperation.Schema);

            query.AddWhere("TicketID", intTicketID);
            query.AddWhere("NextOperationID", 0);
            query.AddWhere("OperationType", Comparison.NotEquals, 6);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DDPawnageInfo pawnageInfo = new DDPawnageInfo("PawnageID", dt.Rows[i]["PawnageID"]);
                this.dataGridView1.Rows.Add(1);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["OperationID"].Value   = dt.Rows[i]["OperationID"];
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["PawnageID"].Value     = pawnageInfo.PawnageID;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ParentClassID"].Value = pawnageInfo.ParentID;
                DDPawnageClass parentClass = new DDPawnageClass("ClassID", pawnageInfo.ParentID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ParentClass"].Value  = parentClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ChildClassID"].Value = pawnageInfo.ClassID;
                DDPawnageClass childClass = new DDPawnageClass("ClassID", pawnageInfo.ClassID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ChildClass"].Value      = childClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["FeeRate"].Value         = dt.Rows[i]["ServiceFeeRate"].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["InterestRate"].Value    = dt.Rows[i]["InterestFeeRate"].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Description"].Value     = pawnageInfo.Description;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["CountNumber"].Value     = pawnageInfo.CountNumber;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Weight"].Value          = pawnageInfo.Weight;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["DiscountPercent"].Value = pawnageInfo.DiscountPercent;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Amount"].Value          = dt.Rows[i]["Amount"];
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Remark"].Value          = pawnageInfo.Remark;

                //计算上期利息
                DateTime StartDate        = DateTime.Parse(dt.Rows[i]["StartDate"].ToString());
                DateTime EndDate          = DateTime.Parse(dt.Rows[i]["EndDate"].ToString());
                PawnSpan LastInterestSpan = DianDangFunction.GetPawnSpan(StartDate, EndDate, FeeType.InterestFee, PeridType.Within);

                LastInterestFee = (LastInterestSpan.Months + LastInterestSpan.CountDays / 30) * Convert.ToDouble(dt.Rows[i]["InterestFeeRate"].ToString()) * Convert.ToDouble(dt.Rows[i]["Amount"].ToString()) / 100;
                LastInterestFee = DianDangFunction.myRound(LastInterestFee, MainForm.AmountAccuracy);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["InterestFee"].Value = LastInterestFee;
                TotalLastInterestFee += LastInterestFee;
            }
            CaculateAmount();

            this.tbxLastInterestFee.Text = TotalLastInterestFee.ToString();
            this.lblLastInterestFee.Text = newChinese.toChineseChar(Convert.ToDecimal(TotalLastInterestFee));
        }
Example #4
0
        private void LoadTicketInfo(int intTicketID)
        {
            m_TicketID = intTicketID;
            DDPawnTicket newTicket = new DDPawnTicket("TicketID", intTicketID);

            this.tbxTicketNumber.Text = newTicket.TicketNumber;
            this.tbxStartDate.Text    = newTicket.StartDate;
            this.tbxEndDate.Text      = newTicket.EndDate;
            DateTime operationDate = DateTime.Now;

            LoadCustomerInfo(Convert.ToInt32(newTicket.CustomerID));
            Query query = new Query(DDOperation.Schema);

            query.AddWhere("TicketID", intTicketID);
            query.AddWhere("OperationType", 1);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            double totalServiceFee  = 0;
            double totalAmount      = 0;
            double totalInterestFee = 0;
            double paidFee          = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DDPawnageInfo pawnageInfo = new DDPawnageInfo("PawnageID", dt.Rows[i]["PawnageID"]);
                this.dataGridView1.Rows.Add(1);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ParentClassID"].Value = pawnageInfo.ParentID;
                DDPawnageClass parentClass = new DDPawnageClass("ClassID", pawnageInfo.ParentID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ParentClass"].Value  = parentClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ChildClassID"].Value = pawnageInfo.ClassID;
                DDPawnageClass childClass = new DDPawnageClass("ClassID", pawnageInfo.ClassID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ChildClass"].Value      = childClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["FeeRate"].Value         = pawnageInfo.FeeRate;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["InterestRate"].Value    = pawnageInfo.InterestRate;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Description"].Value     = pawnageInfo.Description;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["CountNumber"].Value     = pawnageInfo.CountNumber;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Weight"].Value          = pawnageInfo.Weight;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["DiscountPercent"].Value = pawnageInfo.DiscountPercent;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Amount"].Value          = dt.Rows[i]["Amount"];
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["PawnageID"].Value       = dt.Rows[i]["PawnageID"].ToString();
                totalAmount      += Convert.ToDouble(dt.Rows[i]["Amount"]);
                totalServiceFee  += Convert.ToDouble(dt.Rows[i]["ServiceFee"]);
                totalInterestFee += Convert.ToDouble(dt.Rows[i]["InterestFee"]);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Remark"].Value = pawnageInfo.Remark;
            }
            this.tbxTotalAmount.Text = totalAmount.ToString();
            this.lblTotalAmount.Text = newChinese.toChineseChar(Convert.ToDecimal(totalAmount));
            this.tbxServiceFee.Text  = totalServiceFee.ToString();
            this.lblServiceFee.Text  = newChinese.toChineseChar(Convert.ToDecimal(totalServiceFee));;
            this.tbxInterestFee.Text = totalInterestFee.ToString();
            this.lblInterestFee.Text = newChinese.toChineseChar(Convert.ToDecimal(totalInterestFee));
            paidFee = totalAmount - totalServiceFee;
            this.tbxPaidFee.Text = paidFee.ToString();
            this.lblPaidFee.Text = newChinese.toChineseChar(Convert.ToDecimal(paidFee));
        }
Example #5
0
        private void UpdateOperation(int iTicketID)
        {
            try
            {
                Query query = new Query(DDOperation.Schema);
                query.AddWhere("TicketID", iTicketID);
                query.AddWhere("OperationType", Comparison.In, new int[] { 1, 3 });
                query.AddWhere("NextOperationID", 0);
                query.AddWhere("OperationType", Comparison.NotEquals, 6);
                DataTable dt = query.ExecuteDataSet().Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DDOperation oldOperation = new DDOperation("OperationID", Convert.ToInt32(dt.Rows[i]["OperationID"].ToString()));
                    DDOperation newOperation = new DDOperation();
                    int         dataGridRow  = 0;
                    for (int j = 0; j < dataGridView1.Rows.Count; j++)
                    {
                        if (dataGridView1.Rows[j].Cells["PawnageID"].Value.ToString() == oldOperation.PawnageID.ToString())
                        {
                            dataGridRow = j;
                        }
                    }
                    newOperation.TicketID        = m_TicketID;
                    newOperation.PawnageID       = Convert.ToInt32(dataGridView1.Rows[dataGridRow].Cells["PawnageID"].Value.ToString());
                    newOperation.OperationType   = 2;
                    newOperation.OperationNumber = m_OperationNumber;
                    newOperation.ServiceFee      = "0";
                    newOperation.InterestFee     = (Convert.ToDouble(dataGridView1.Rows[dataGridRow].Cells["PaidInterestFee"].Value.ToString()) - Convert.ToDouble(dataGridView1.Rows[dataGridRow].Cells["ReturnInterestFee"].Value.ToString())).ToString();
                    newOperation.ReturnFee       = dataGridView1.Rows[dataGridRow].Cells["ReturnFee"].Value.ToString();
                    newOperation.OverdueFee      = dataGridView1.Rows[dataGridRow].Cells["OverdueFee"].Value.ToString();
                    newOperation.Amount          = dataGridView1.Rows[dataGridRow].Cells["Amount"].Value.ToString();
                    newOperation.ReckonAmount    = "0";
                    newOperation.ServiceFeeRate  = dataGridView1.Rows[dataGridRow].Cells["ServiceFeeRate"].Value.ToString();
                    newOperation.InterestFeeRate = dataGridView1.Rows[dataGridRow].Cells["InterestFeeRate"].Value.ToString();
                    newOperation.OperationDate   = tbxOperationDate.Text;
                    DDUser newUser = new DDUser("AccountName", MainForm.AccountName);
                    newOperation.OperaterName    = newUser.UserName;
                    newOperation.PreOperationID  = oldOperation.OperationID;
                    newOperation.NextOperationID = 0;
                    newOperation.Save();

                    oldOperation.NextOperationID = newOperation.OperationID;
                    oldOperation.Save();

                    DDPawnageInfo newInfo = new DDPawnageInfo("PawnageID", Convert.ToInt32(dataGridView1.Rows[dataGridRow].Cells["PawnageID"].Value.ToString()));
                    newInfo.StatusID = 2;  //赎当
                    newInfo.Save();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
        private void UpdateOperation()
        {
            try
            {
                if (dataGridView1.Rows.Count > 0)
                {
                    DateTime operateDate = DateTime.Now;
                    string   strDate     = operateDate.Year.ToString() + "-" + operateDate.Month.ToString() + "-" + operateDate.Day.ToString();

                    int iPawnageID     = 0;
                    int preOperationID = 0;
                    for (int i = dataGridView1.Rows.Count - 1; i > -1; i--)
                    {
                        DataGridViewRow dgr = dataGridView1.Rows[i];

                        iPawnageID     = Convert.ToInt32(dgr.Cells["PawnageID"].Value);
                        preOperationID = Convert.ToInt32(dgr.Cells["OperationID"].Value);
                        DDOperation newOperation = new DDOperation();
                        newOperation.TicketID        = m_TicketID;
                        newOperation.PawnageID       = iPawnageID;
                        newOperation.OperationType   = 7; //7:清算
                        newOperation.OperationNumber = m_OperationNumber;
                        newOperation.ServiceFee      = "0";
                        newOperation.InterestFee     = "0";
                        newOperation.ReturnFee       = "0";
                        newOperation.OverdueFee      = "0";
                        newOperation.Amount          = dgr.Cells["Amount"].Value.ToString();
                        newOperation.ReckonAmount    = dgr.Cells["ReckonAmount"].Value.ToString();
                        newOperation.OperationDate   = strDate;
                        newOperation.OperaterName    = MainForm.AccountName;
                        newOperation.PreOperationID  = preOperationID;
                        newOperation.NextOperationID = 0;
                        newOperation.Deleted         = 0;
                        newOperation.Save();

                        DDOperation oldOperation = new DDOperation("OperationID", preOperationID);
                        oldOperation.NextOperationID = newOperation.OperationID;
                        oldOperation.Save();

                        DDPawnageInfo newInfo = new DDPawnageInfo("PawnageID", iPawnageID);
                        newInfo.StatusID = 7;
                        newInfo.Save();
                    }
                    DDPawnTicket newTicket = new DDPawnTicket("TicketID", m_TicketID);
                    newTicket.StatusID = 7;  //7:清算
                    newTicket.Save();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        private void InitGridTable(int iTicketID)
        {
            m_GridTable.Columns.Add("TicketNumber", typeof(System.String));
            m_GridTable.Columns.Add("PawnageClass", typeof(System.String));
            m_GridTable.Columns.Add("OperationDate", typeof(System.String));
            m_GridTable.Columns.Add("OperationType", typeof(System.Int32));
            m_GridTable.Columns.Add("Operater", typeof(System.String));
            m_GridTable.Columns.Add("OperationNumber", typeof(String));
            m_GridTable.Columns.Add("StartDate", typeof(System.String));
            m_GridTable.Columns.Add("EndDate", typeof(System.String));
            m_GridTable.Columns.Add("ServiceFee", typeof(System.String));
            m_GridTable.Columns.Add("InterestFee", typeof(System.String));
            m_GridTable.Columns.Add("ReturnServiceFee", typeof(System.String));
            m_GridTable.Columns.Add("OverdueServiceFee", typeof(System.String));


            DDPawnTicket newTicket = new DDPawnTicket("TicketID", iTicketID);

            Query query = new Query(DDOperation.Schema);

            query.AddWhere("TicketID", iTicketID);
            query.AddWhere("OperationType", Comparison.NotEquals, 6);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string Item = dt.Rows[i]["OperationNumber"].ToString();
                    if (!isInSearchStatusList(Item))
                    {
                        DataRow drow = m_GridTable.NewRow();
                        drow["TicketNumber"] = newTicket.TicketNumber;
                        DDPawnageInfo  newInfo  = new DDPawnageInfo("PawnageID", Convert.ToInt32(dt.Rows[i]["PawnageID"]));
                        DDPawnageClass newClass = new DDPawnageClass("ClassID", newInfo.ClassID);
                        drow["PawnageClass"]      = newClass.ClassName;
                        drow["OperationDate"]     = dt.Rows[i]["OperationDate"];
                        drow["OperationType"]     = dt.Rows[i]["OperationType"];
                        drow["Operater"]          = dt.Rows[i]["OperaterName"];
                        drow["OperationNumber"]   = dt.Rows[i]["OperationNumber"];
                        drow["StartDate"]         = dt.Rows[i]["StartDate"];
                        drow["EndDate"]           = dt.Rows[i]["EndDate"];
                        drow["ServiceFee"]        = dt.Rows[i]["ServiceFee"];
                        drow["InterestFee"]       = dt.Rows[i]["InterestFee"];
                        drow["ReturnServiceFee"]  = dt.Rows[i]["ReturnFee"];
                        drow["OverdueServiceFee"] = dt.Rows[i]["OverdueFee"];
                        m_GridTable.Rows.Add(drow);
                        SearchStatus.Add(Item);
                    }
                }
            }
            this.dataGridView1.DataSource = m_GridTable;
        }
Example #8
0
        private void UpdatePawages(int intTicketID)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                double serviceFee  = 0;
                double interestFee = 0;
                for (int i = dataGridView1.Rows.Count - 1; i > -1; i--)
                {
                    DataGridViewRow dgr = dataGridView1.Rows[i];

                    try
                    {
                        DDPawnageInfo newInfo = new DDPawnageInfo();
                        newInfo.ClassID         = Convert.ToInt32(dgr.Cells["ChildClassID"].Value);
                        newInfo.ParentID        = Convert.ToInt32(dgr.Cells["ParentClassID"].Value);
                        newInfo.StatusID        = 3;
                        newInfo.CountNumber     = dgr.Cells["CountNumber"].Value.ToString();
                        newInfo.Weight          = dgr.Cells["Weight"].Value.ToString();
                        newInfo.DiscountPercent = dgr.Cells["DiscountPercent"].Value.ToString();
                        newInfo.Amount          = dgr.Cells["Amount"].Value.ToString();
                        newInfo.ReckonAmount    = "0";
                        serviceFee            = Convert.ToDouble(dgr.Cells["Amount"].Value) * Convert.ToInt32(this.tbxPawnTerm.Text) * Convert.ToDouble(dgr.Cells["FeeRate"].Value) / 100;
                        newInfo.ServiceFee    = serviceFee.ToString();
                        interestFee           = Convert.ToDouble(dgr.Cells["Amount"].Value) * Convert.ToInt32(this.tbxPawnTerm.Text) * Convert.ToDouble(dgr.Cells["InterestRate"].Value) / 100;
                        newInfo.InterestFee   = interestFee.ToString();
                        newInfo.ReturnFee     = "0";
                        newInfo.OverdueFee    = "0";
                        newInfo.Description   = dgr.Cells["Description"].Value.ToString();
                        newInfo.IsReif        = 0;
                        newInfo.StartDate     = this.tbxStartDate.Text;
                        newInfo.EndDate       = this.tbxEndDate.Text;
                        newInfo.OperationDate = this.tbxStartDate.Text;
                        newInfo.Remark        = this.tbxRemark.Text;
                        newInfo.Save();

                        DDTicketPawnage newTicketPawnage = new DDTicketPawnage();
                        newTicketPawnage.TicketID  = intTicketID;
                        newTicketPawnage.PawnageID = newInfo.PawnageID;
                        newTicketPawnage.Save();
                    }
                    catch
                    {
                        MessageBox.Show(this, "数据更新失败,请检查数据库是否连接正确!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Example #9
0
        private void LoadOldTicketInfo(int intTicketID)
        {
            DDPawnTicket newTicket = new DDPawnTicket("TicketID", intTicketID);

            this.lblOldTicketNum.Text = newTicket.TicketNumber;
            this.tbxStartDate.Text    = newTicket.StartDate;
            this.tbxPawnTerm.Text     = "1";
            DateTime endDate = DateTime.Now.AddMonths(1);

            this.tbxEndDate.Text = endDate.Year.ToString() + "-" + endDate.Month.ToString() + "-" + endDate.Day.ToString();

            Query query = new Query(DDTicketPawnage.Schema);

            query.AddWhere("TicketID", intTicketID);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DDPawnageInfo pawnageInfo = new DDPawnageInfo("PawnageID", dt.Rows[i]["PawnageID"]);
                this.dataGridView1.Rows.Add(1);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ParentClassID"].Value = pawnageInfo.ParentID;
                DDPawnageClass parentClass = new DDPawnageClass("ClassID", pawnageInfo.ParentID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ParentClass"].Value  = parentClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ChildClassID"].Value = pawnageInfo.ClassID;
                DDPawnageClass childClass = new DDPawnageClass("ClassID", pawnageInfo.ClassID);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["ChildClass"].Value      = childClass.ClassName;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["FeeRate"].Value         = childClass.MonthFeeRate;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["InterestRate"].Value    = childClass.InterestRate;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Description"].Value     = pawnageInfo.Description;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["CountNumber"].Value     = pawnageInfo.CountNumber;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Weight"].Value          = pawnageInfo.Weight;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["DiscountPercent"].Value = pawnageInfo.DiscountPercent;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Amount"].Value          = pawnageInfo.Amount;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Remark"].Value          = pawnageInfo.Remark;
            }
            CaculateAmount();
        }
        private void LoadTicketInfo()
        {
            this.m_GridTable.Rows.Clear();

            DDPawnTicket newTicket = new DDPawnTicket("TicketID", m_TicketID);

            Query queryOperations = new Query(DDOperation.Schema);

            queryOperations.AddWhere("TicketID", m_TicketID);
            queryOperations.AddWhere("OperationType", Comparison.In, new int[] { 1, 3 });
            queryOperations.AddWhere("OperationType", Comparison.NotEquals, 6);
            queryOperations.AddWhere("NextOperationID", 0);

            DataTable dtOperations = queryOperations.ExecuteDataSet().Tables[0];

            m_StartDate = Convert.ToDateTime(newTicket.StartDate);
            m_EndDate   = Convert.ToDateTime(newTicket.EndDate);
            try
            {
                m_OperationDate = Convert.ToDateTime(this.tbxOperationDate.Text.Trim());
            }
            catch
            {
                MessageBox.Show("请输入正确的日期", "提示信息");
            }

            if (dtOperations.Rows.Count > 0)
            {
                for (int i = 0; i < dtOperations.Rows.Count; i++)
                {
                    double amount = 0;
                    double serviceFee = 0, interestFee = 0, paidInterestFee = 0;
                    double chargedServiceFee = 0, chargedInterestFee = 0;
                    double singleChargedServiceFee = 0, singleChargedInterestFee = 0;
                    double returnServiceFee = 0, returnInterestFee = 0;
                    double singleReturnServiceFee = 0, singleReturnInterestFee = 0;
                    double serviceFeeRate = 0, interestFeeRate = 0;

                    double overdueFee = 0;
                    amount = Convert.ToDouble(dtOperations.Rows[i]["Amount"]);
                    #region 原先错误的算法

                    /*
                     * Query queryRenewPawn = new Query(DDOperation.Schema);
                     * queryRenewPawn.AddWhere("TicketID",m_TicketID);
                     * queryRenewPawn.AddWhere("PawnageID",Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]));
                     * queryRenewPawn.AddWhere("OperationType",3);
                     * DataTable dtRenewPawn = queryRenewPawn.ExecuteDataSet().Tables[0];
                     * if (dtRenewPawn.Rows.Count > 0)
                     * {
                     *  for (int j = 0; j < dtRenewPawn.Rows.Count; j++)
                     *  {
                     *      serviceFee += Convert.ToDouble(dtRenewPawn.Rows[j]["ServiceFee"]);
                     *      interestFee += Convert.ToDouble(dtRenewPawn.Rows[j]["InterestFee"]);
                     *  }
                     * }
                     *
                     * totalServiceFee += serviceFee;
                     * totalInterestFee += interestFee;
                     * //overdueFee = CaculateOverdueFee(amount, Convert.ToDouble(pawnageInfo.FeeRate), Convert.ToDouble(pawnageInfo.InterestRate))
                     * //returnFee = serviceFee + interestFee - CaculatePaidFee(amount, Convert.ToDouble(pawnageInfo.FeeRate), Convert.ToDouble(pawnageInfo.InterestRate));
                     * //returnFee = CaculateReturnFee(amount, Convert.ToDouble(pawnageInfo.FeeRate), Convert.ToDouble(pawnageInfo.InterestRate));
                     * if (returnFee < 0)
                     * {
                     *  returnFee = 0;
                     * }
                     * totalOverdueFee += overdueFee;
                     * totalReturnFee += returnFee;
                     */
                    #endregion

                    DDPawnageInfo pawnageInfo = new DDPawnageInfo("PawnageID", Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]));

                    #region 费用计算
                    //判断当票状态
                    int PawnTicketStatus = 0;  //0:正好,1:提前,2:过期

                    //DDPawnTicket theTicket = new DDPawnTicket("TicketID", m_TicketID);
                    if (m_OperationDate <= DateTime.Parse(dtOperations.Rows[i]["EndDate"].ToString()))
                    {
                        PawnSpan Span     = DianDangFunction.GetPawnSpan(m_OperationDate, DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()));
                        PawnSpan LastSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()), DateTime.Parse(dtOperations.Rows[i]["EndDate"].ToString()));
                        if (Span.Months == LastSpan.Months && Span.CountDays == LastSpan.CountDays && m_OperationDate >= DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()))
                        {
                            PawnTicketStatus = 0;
                        }
                        else
                        {
                            PawnTicketStatus = 1;
                        }
                    }
                    else
                    {
                        PawnTicketStatus = 2;
                    }


                    if (DateTime.Parse(newTicket.StartDate) == m_OperationDate)//当天建当,当天还
                    {
                        int ifReturn = 0;

                        double InOperationServiceFee = 0, InOperationInterestFee = 0;
                        double InOPerationChargedServiceFee = 0, InOperationChargedInterestFee = 0;

                        //总计征收的费用
                        Query queryPaidOperation = new Query(DDOperation.Schema);
                        queryPaidOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                        queryPaidOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                        queryPaidOperation.AddWhere("Deleted", 0);
                        DataTable dtPaidOperation = queryPaidOperation.ExecuteDataSet().Tables[0];
                        for (int j = 0; j < dtPaidOperation.Rows.Count; j++)
                        {
                            singleChargedServiceFee  = Convert.ToDouble(dtPaidOperation.Rows[j]["ServiceFee"].ToString());
                            singleChargedServiceFee  = DianDangFunction.myRound(singleChargedServiceFee, MainForm.AmountAccuracy);
                            chargedServiceFee       += singleChargedServiceFee;
                            singleChargedInterestFee = Convert.ToDouble(dtPaidOperation.Rows[j]["InterestFee"].ToString());
                            singleChargedInterestFee = DianDangFunction.myRound(singleChargedInterestFee, MainForm.AmountAccuracy);
                            chargedInterestFee      += singleChargedInterestFee;
                        }

                        //计算争议的服务费
                        Query queryInOperation = new Query(DDOperation.Schema);
                        queryInOperation.AddBetweenAnd("EndDate", m_OperationDate, new DateTime(9998, 12, 31));
                        queryInOperation.AddBetweenAnd("StartDate", new DateTime(1755, 1, 1), m_OperationDate);
                        queryInOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                        queryInOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                        queryInOperation.AddWhere("Deleted", 0);
                        DataTable dtInOperation = queryInOperation.ExecuteDataSet().Tables[0];
                        if (dtInOperation.Rows.Count > 0)
                        {
                            InOPerationChargedServiceFee = Convert.ToDouble(dtInOperation.Rows[0]["ServiceFee"].ToString());

                            PawnSpan OperationSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), DateTime.Parse(dtInOperation.Rows[0]["EndDate"].ToString()));
                            PawnSpan Span          = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), m_OperationDate);
                            double   DayFeeRate    = InOPerationChargedServiceFee / OperationSpan.CountDaysAll / amount * 100;

                            if (Span.CountDaysAll > OperationSpan.CountDaysAll)
                            {
                                Span.CountDaysAll = OperationSpan.CountDaysAll;
                            }
                            InOperationServiceFee = (Span.CountDaysAll) * amount * DayFeeRate / 100;
                            InOperationServiceFee = DianDangFunction.myRound(InOperationServiceFee, MainForm.AmountAccuracy);
                        }

                        //计算肯定要返还的费用
                        Query queryReturnOperation = new Query(DDOperation.Schema);
                        queryReturnOperation.AddBetweenAnd("StartDate", m_OperationDate.AddDays(1), new DateTime(9998, 12, 31));
                        queryReturnOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                        queryReturnOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                        queryReturnOperation.AddWhere("Deleted", 0);
                        DataTable dtReturnOperation = queryReturnOperation.ExecuteDataSet().Tables[0];
                        for (int j = 0; j < dtReturnOperation.Rows.Count; j++)
                        {
                            //计算争议的利息费,因为本次收取的利息为上月利息,即为争议利息
                            if (j == 0 && dtInOperation.Rows.Count > 0)
                            {
                                InOperationChargedInterestFee = Convert.ToDouble(dtReturnOperation.Rows[0]["InterestFee"].ToString());
                                PawnSpan OperationSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), DateTime.Parse(dtInOperation.Rows[0]["EndDate"].ToString()));
                                PawnSpan Span          = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), m_OperationDate);

                                double DayInterestFeeRate = InOperationChargedInterestFee / OperationSpan.CountDaysAll / amount * 100;
                                if (Span.CountDaysAll > OperationSpan.CountDaysAll)
                                {
                                    Span.CountDaysAll = OperationSpan.CountDaysAll;
                                }
                                InOperationInterestFee = (Span.CountDaysAll) * amount * DayInterestFeeRate / 100;
                                InOperationInterestFee = DianDangFunction.myRound(InOperationInterestFee, MainForm.AmountAccuracy);
                            }


                            ifReturn++;
                            singleReturnServiceFee = Convert.ToDouble(dtReturnOperation.Rows[j]["ServiceFee"].ToString());
                            singleReturnServiceFee = DianDangFunction.myRound(singleReturnServiceFee, MainForm.AmountAccuracy);
                            returnServiceFee      += singleReturnServiceFee;
                            if (j != 0 || dtInOperation.Rows.Count == 0)
                            {
                                singleReturnInterestFee = Convert.ToDouble(dtReturnOperation.Rows[j]["InterestFee"].ToString());
                                singleReturnInterestFee = DianDangFunction.myRound(singleReturnInterestFee, MainForm.AmountAccuracy);
                                returnInterestFee      += singleReturnInterestFee;
                            }
                        }



                        if (m_OperationDate > DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString())) //操作日期大于最后一次操作开始日期,则收取利息
                        {
                            PawnSpan Span = DianDangFunction.GetPawnSpan(DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()), m_OperationDate);
                            paidInterestFee = 0;
                            paidInterestFee = (Span.Months + Span.Days / 30) * Convert.ToDouble(dtOperations.Rows[i]["InterestFeeRate"].ToString()) * amount / 100;
                            paidInterestFee = DianDangFunction.myRound(paidInterestFee, MainForm.AmountAccuracy);
                        }



                        returnServiceFee  = returnServiceFee + InOPerationChargedServiceFee - InOperationServiceFee;
                        returnServiceFee  = DianDangFunction.myRound(returnServiceFee, MainForm.AmountAccuracy);
                        returnInterestFee = returnInterestFee + InOperationChargedInterestFee - InOperationInterestFee;
                        returnInterestFee = DianDangFunction.myRound(returnInterestFee, MainForm.AmountAccuracy);


                        serviceFee  = chargedServiceFee - returnServiceFee;
                        serviceFee  = DianDangFunction.myRound(serviceFee, MainForm.AmountAccuracy);
                        interestFee = chargedInterestFee + paidInterestFee - returnInterestFee;
                        interestFee = DianDangFunction.myRound(interestFee, MainForm.AmountAccuracy);
                    }

                    else
                    {
                        if (PawnTicketStatus == 0)  //收取上期服务费
                        {
                            //计算上期利息
                            PawnSpan LastSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()), DateTime.Parse(dtOperations.Rows[i]["EndDate"].ToString()));
                            paidInterestFee = (LastSpan.Months + LastSpan.CountDays / 30) * amount * Convert.ToDouble(dtOperations.Rows[i]["InterestFeeRate"].ToString()) / 100;
                            paidInterestFee = DianDangFunction.myRound(paidInterestFee, MainForm.AmountAccuracy);

                            //计算已经付出的服务费和利息
                            Query queryPaidOperation = new Query(DDOperation.Schema);
                            queryPaidOperation.AddWhere("TicketID", m_TicketID);
                            queryPaidOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                            queryPaidOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                            queryPaidOperation.AddWhere("Deleted", 0);
                            DataTable dtPaidOperation = queryPaidOperation.ExecuteDataSet().Tables[0];
                            if (dtPaidOperation.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtPaidOperation.Rows.Count; j++)
                                {
                                    singleChargedServiceFee  = Convert.ToDouble(dtPaidOperation.Rows[j]["ServiceFee"].ToString());
                                    singleChargedServiceFee  = DianDangFunction.myRound(singleChargedServiceFee, MainForm.AmountAccuracy);
                                    chargedServiceFee       += singleChargedServiceFee;
                                    singleChargedInterestFee = Convert.ToDouble(dtPaidOperation.Rows[j]["InterestFee"].ToString());
                                    singleChargedInterestFee = DianDangFunction.myRound(singleChargedInterestFee, MainForm.AmountAccuracy);
                                    chargedInterestFee      += singleChargedInterestFee;
                                }
                            }

                            //当品应收的利息等于之前收过的利息+上期利息
                            interestFee = chargedInterestFee + paidInterestFee;
                            serviceFee  = chargedServiceFee;
                        }
                        else if (PawnTicketStatus == 2)  //过期状态,收取
                        {
                            //计算上期利息+过期利息,计算过期服务费
                            PawnSpan LastSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()), m_OperationDate);
                            paidInterestFee = (LastSpan.Months + LastSpan.CountDays / 30) * amount * Convert.ToDouble(dtOperations.Rows[i]["InterestFeeRate"].ToString()) / 100;
                            paidInterestFee = DianDangFunction.myRound(paidInterestFee, MainForm.AmountAccuracy);

                            PawnSpan OverdueSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtOperations.Rows[i]["EndDate"].ToString()), m_OperationDate);
                            overdueFee = (OverdueSpan.Months + OverdueSpan.CountDays / 30) * amount * Convert.ToDouble(dtOperations.Rows[i]["ServiceFeeRate"].ToString()) / 100;
                            overdueFee = DianDangFunction.myRound(overdueFee, MainForm.AmountAccuracy);


                            //计算已经付出的服务费和利息
                            Query queryPaidOperation = new Query(DDOperation.Schema);
                            queryPaidOperation.AddWhere("TicketID", m_TicketID);
                            queryPaidOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                            queryPaidOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                            queryPaidOperation.AddWhere("Deleted", 0);
                            DataTable dtPaidOperation = queryPaidOperation.ExecuteDataSet().Tables[0];
                            if (dtPaidOperation.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtPaidOperation.Rows.Count; j++)
                                {
                                    singleChargedServiceFee  = Convert.ToDouble(dtPaidOperation.Rows[j]["ServiceFee"].ToString());
                                    singleChargedServiceFee  = DianDangFunction.myRound(singleChargedServiceFee, MainForm.AmountAccuracy);
                                    chargedServiceFee       += singleChargedServiceFee;
                                    singleChargedInterestFee = Convert.ToDouble(dtPaidOperation.Rows[j]["InterestFee"].ToString());
                                    singleChargedInterestFee = DianDangFunction.myRound(singleChargedInterestFee, MainForm.AmountAccuracy);
                                    chargedInterestFee      += singleChargedInterestFee;
                                }
                            }

                            //当品应收的利息等于之前收过的利息+应付利息
                            interestFee = chargedInterestFee + paidInterestFee;
                            //服务费应该等于所有已经收取的服务费+过期服务费
                            serviceFee = chargedServiceFee + overdueFee;
                        }
                        else if (PawnTicketStatus == 1)  //提前赎当
                        {
                            int ifReturn = 0;

                            double InOperationServiceFee = 0, InOperationInterestFee = 0;
                            double InOPerationChargedServiceFee = 0, InOperationChargedInterestFee = 0;

                            //总计征收的费用
                            Query queryPaidOperation = new Query(DDOperation.Schema);
                            queryPaidOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                            queryPaidOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                            queryPaidOperation.AddWhere("Deleted", 0);
                            DataTable dtPaidOperation = queryPaidOperation.ExecuteDataSet().Tables[0];
                            for (int j = 0; j < dtPaidOperation.Rows.Count; j++)
                            {
                                singleChargedServiceFee  = Convert.ToDouble(dtPaidOperation.Rows[j]["ServiceFee"].ToString());
                                singleChargedServiceFee  = DianDangFunction.myRound(singleChargedServiceFee, MainForm.AmountAccuracy);
                                chargedServiceFee       += singleChargedServiceFee;
                                singleChargedInterestFee = Convert.ToDouble(dtPaidOperation.Rows[j]["InterestFee"].ToString());
                                singleChargedInterestFee = DianDangFunction.myRound(singleChargedInterestFee, MainForm.AmountAccuracy);
                                chargedInterestFee      += singleChargedInterestFee;
                            }

                            //计算争议的服务费
                            Query queryInOperation = new Query(DDOperation.Schema);
                            queryInOperation.AddBetweenAnd("EndDate", m_OperationDate.AddDays(1), new DateTime(9998, 12, 31));
                            queryInOperation.AddBetweenAnd("StartDate", new DateTime(1755, 1, 1), m_OperationDate.AddDays(-1));
                            queryInOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                            queryInOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                            queryInOperation.AddWhere("Deleted", 0);
                            DataTable dtInOperation = queryInOperation.ExecuteDataSet().Tables[0];
                            if (dtInOperation.Rows.Count > 0)
                            {
                                InOPerationChargedServiceFee = Convert.ToDouble(dtInOperation.Rows[0]["ServiceFee"].ToString());

                                PawnSpan OperationSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), DateTime.Parse(dtInOperation.Rows[0]["EndDate"].ToString()));
                                PawnSpan Span          = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), m_OperationDate);
                                double   DayFeeRate    = InOPerationChargedServiceFee / OperationSpan.CountDaysAll / amount * 100;

                                if (Span.CountDaysAll > OperationSpan.CountDaysAll)
                                {
                                    Span.CountDaysAll = OperationSpan.CountDaysAll;
                                }
                                InOperationServiceFee = (Span.CountDaysAll) * amount * DayFeeRate / 100;
                                InOperationServiceFee = DianDangFunction.myRound(InOperationServiceFee, MainForm.AmountAccuracy);
                            }

                            //计算肯定要返还的费用
                            Query queryReturnOperation = new Query(DDOperation.Schema);
                            queryReturnOperation.AddBetweenAnd("StartDate", m_OperationDate, new DateTime(9998, 12, 31));
                            queryReturnOperation.AddWhere("PawnageID", pawnageInfo.PawnageID);
                            queryReturnOperation.AddWhere("OperationType", Comparison.NotEquals, 6);
                            queryReturnOperation.AddWhere("Deleted", 0);
                            DataTable dtReturnOperation = queryReturnOperation.ExecuteDataSet().Tables[0];
                            for (int j = 0; j < dtReturnOperation.Rows.Count; j++)
                            {
                                //计算争议的利息费,因为本次收取的利息为上月利息,即为争议利息
                                if (j == 0 && dtInOperation.Rows.Count > 0)
                                {
                                    InOperationChargedInterestFee = Convert.ToDouble(dtReturnOperation.Rows[0]["InterestFee"].ToString());
                                    PawnSpan OperationSpan = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), DateTime.Parse(dtInOperation.Rows[0]["EndDate"].ToString()));
                                    PawnSpan Span          = DianDangFunction.GetPawnSpan(DateTime.Parse(dtInOperation.Rows[0]["StartDate"].ToString()), m_OperationDate);

                                    double DayInterestFeeRate = InOperationChargedInterestFee / OperationSpan.CountDaysAll / amount * 100;
                                    if (Span.CountDaysAll > OperationSpan.CountDaysAll)
                                    {
                                        Span.CountDaysAll = OperationSpan.CountDaysAll;
                                    }
                                    InOperationInterestFee = (Span.CountDaysAll) * amount * DayInterestFeeRate / 100;
                                    InOperationInterestFee = DianDangFunction.myRound(InOperationInterestFee, MainForm.AmountAccuracy);
                                }


                                ifReturn++;
                                singleReturnServiceFee = Convert.ToDouble(dtReturnOperation.Rows[j]["ServiceFee"].ToString());
                                singleReturnServiceFee = DianDangFunction.myRound(singleReturnServiceFee, MainForm.AmountAccuracy);
                                returnServiceFee      += singleReturnServiceFee;
                                if (j != 0 || dtInOperation.Rows.Count == 0)
                                {
                                    singleReturnInterestFee = Convert.ToDouble(dtReturnOperation.Rows[j]["InterestFee"].ToString());
                                    singleReturnInterestFee = DianDangFunction.myRound(singleReturnInterestFee, MainForm.AmountAccuracy);
                                    returnInterestFee      += singleReturnInterestFee;
                                }
                            }



                            if (m_OperationDate > DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString())) //操作日期大于最后一次操作开始日期,则收取利息
                            {
                                PawnSpan Span = DianDangFunction.GetPawnSpan(DateTime.Parse(dtOperations.Rows[i]["StartDate"].ToString()), m_OperationDate);
                                paidInterestFee = 0;
                                paidInterestFee = (Span.Months + Span.Days / 30) * Convert.ToDouble(dtOperations.Rows[i]["InterestFeeRate"].ToString()) * amount / 100;
                                paidInterestFee = DianDangFunction.myRound(paidInterestFee, MainForm.AmountAccuracy);
                            }



                            returnServiceFee  = returnServiceFee + InOPerationChargedServiceFee - InOperationServiceFee;
                            returnServiceFee  = DianDangFunction.myRound(returnServiceFee, MainForm.AmountAccuracy);
                            returnInterestFee = returnInterestFee + InOperationChargedInterestFee - InOperationInterestFee;
                            returnInterestFee = DianDangFunction.myRound(returnInterestFee, MainForm.AmountAccuracy);


                            serviceFee  = chargedServiceFee - returnServiceFee;
                            serviceFee  = DianDangFunction.myRound(serviceFee, MainForm.AmountAccuracy);
                            interestFee = chargedInterestFee + paidInterestFee - returnInterestFee;
                            interestFee = DianDangFunction.myRound(interestFee, MainForm.AmountAccuracy);
                        }
                    }



                    //Query queryOperation = new Query(DDOperation.Schema);
                    //queryOperations.AddWhere("TicketID", m_TicketID);

                    #endregion

                    serviceFeeRate  = Convert.ToDouble(dtOperations.Rows[i]["ServiceFeeRate"].ToString());
                    interestFeeRate = Convert.ToDouble(dtOperations.Rows[i]["InterestFeeRate"].ToString());

                    interestFee        = DianDangFunction.myRound(interestFee, MainForm.AmountAccuracy);
                    serviceFee         = DianDangFunction.myRound(serviceFee, MainForm.AmountAccuracy);
                    amount             = DianDangFunction.myRound(amount, MainForm.AmountAccuracy);
                    returnServiceFee   = DianDangFunction.myRound(returnServiceFee, MainForm.AmountAccuracy);
                    returnInterestFee  = DianDangFunction.myRound(returnInterestFee, MainForm.AmountAccuracy);
                    overdueFee         = DianDangFunction.myRound(overdueFee, MainForm.AmountAccuracy);
                    paidInterestFee    = DianDangFunction.myRound(paidInterestFee, MainForm.AmountAccuracy);
                    chargedServiceFee  = DianDangFunction.myRound(chargedServiceFee, MainForm.AmountAccuracy);
                    chargedInterestFee = DianDangFunction.myRound(chargedInterestFee, MainForm.AmountAccuracy);


                    DataRow        drow         = m_GridTable.NewRow();
                    DDPawnageClass pawnageClass = new DDPawnageClass("ClassID", pawnageInfo.ClassID);
                    drow["ClassName"]          = pawnageClass.ClassName;
                    drow["Amount"]             = amount;
                    drow["ServiceFee"]         = serviceFee;
                    drow["InterestFee"]        = interestFee;
                    drow["ReturnFee"]          = returnServiceFee;
                    drow["ReturnInterestFee"]  = returnInterestFee;
                    drow["OverdueFee"]         = overdueFee;
                    drow["PaidInterestFee"]    = paidInterestFee;
                    drow["ChargedServiceFee"]  = chargedServiceFee;
                    drow["ChargedInterestFee"] = chargedInterestFee;
                    drow["PawnageID"]          = dtOperations.Rows[i]["PawnageID"].ToString();
                    drow["ServiceFeeRate"]     = serviceFeeRate;
                    drow["InterestFeeRate"]    = interestFeeRate;
                    m_GridTable.Rows.Add(drow);
                }
            }


            this.dataGridView1.DataSource = m_GridTable;
            CaculateDatagridAmount();
        }
Example #11
0
        private void DeleteOperation()
        {
            DataGridViewRow dgr         = dataGridView1.CurrentRow;
            int             intTicketID = Convert.ToInt32(dgr.Cells["TicketID"].Value);

            DDPawnTicket newTicket = new DDPawnTicket("TicketID", intTicketID);

            Query query = new Query(DDOperation.Schema);

            query.AddWhere("TicketID", intTicketID);
            query.AddWhere("NextOperationID", 0);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            if (dt.Rows.Count > 0)
            {
                DateTime operateDate = DateTime.Now;
                string   strDate     = operateDate.Year.ToString() + "-" + operateDate.Month.ToString() + "-" + operateDate.Day.ToString();

                //DDOperation newOperation = new DDOperation();
                //newOperation.TicketID = operation.TicketID;
                //newOperation.PawnageID = operation.PawnageID;
                //newOperation.OperationType = 6;
                //newOperation.OperationNumber = operation.OperationNumber;
                //newOperation.OperationDate = strDate;
                //newOperation.OperaterName = MainForm.AccountName;
                //newOperation.PreOperationID = operation.OperationID;
                //newOperation.NextOperationID = 0;
                //newOperation.Save();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DDPawnageInfo newInfo      = new DDPawnageInfo("PawnageID", Convert.ToInt32(dt.Rows[i]["PawnageID"]));
                    DDOperation   newOperation = new DDOperation("OperationID", Convert.ToInt32(dt.Rows[i]["OperationID"]));

                    if (newOperation.PreOperationID != 0)
                    {
                        DDOperation preOperation = new DDOperation("OperationID", newOperation.PreOperationID);
                        preOperation.NextOperationID = 0;
                        preOperation.Save();
                        newTicket.StatusID = preOperation.OperationType;
                        newInfo.StatusID   = preOperation.OperationType;
                        if (newOperation.OperationType == 3)
                        {
                            newTicket.EndDate = preOperation.EndDate;
                        }
                    }
                    else
                    {
                        newTicket.StatusID = 6;
                        newInfo.StatusID   = 6;
                    }
                    newOperation.OperationType   = 6;//6:删除
                    newOperation.NextOperationID = -1;
                    newOperation.OperationDate   = strDate;
                    newOperation.Deleted         = 1;
                    newOperation.Save();
                    newInfo.Save();
                }
            }

            newTicket.Save();

            InitGridSource();
            dataGridView1.DataSource = m_GridTable;
            SetForGridViewPage();
            MessageBox.Show("删除成功!", "删除");
        }
Example #12
0
        private void UpdateOperation()
        {
            try
            {
                DataGridViewRow dgr         = dataGridView1.CurrentRow;
                int             intStatusID = Convert.ToInt32(dgr.Cells["StatusID"].Value);

                if (intStatusID == 1 || intStatusID == 3)
                {
                    int          iTicketID = Convert.ToInt32(dgr.Cells["TicketID"].Value);
                    DDPawnTicket newTicket = new DDPawnTicket("TicketID", iTicketID);

                    Query queryOperations = new Query(DDOperation.Schema);
                    queryOperations.AddWhere("TicketID", iTicketID);
                    queryOperations.AddWhere("NextOperationID", 0);
                    queryOperations.AddWhere("OperationType", Comparison.NotEquals, 6);
                    DataTable dtOperations = queryOperations.ExecuteDataSet().Tables[0];
                    if (dtOperations.Rows.Count > 0)
                    {
                        newTicket.StatusID = 4;
                        newTicket.Save();
                        int preOperationID = 0;

                        for (int i = 0; i < dtOperations.Rows.Count; i++)
                        {
                            DDOperation newOperation = new DDOperation();
                            preOperationID               = Convert.ToInt32(dtOperations.Rows[i]["OperationID"]);
                            newOperation.TicketID        = iTicketID;
                            newOperation.PawnageID       = Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]);
                            newOperation.OperationType   = 4; //4 :绝当
                            newOperation.OperationNumber = m_OperationNumber;
                            newOperation.ServiceFee      = "0";
                            newOperation.InterestFee     = "0";
                            newOperation.ReturnFee       = "0";
                            newOperation.OverdueFee      = "0";
                            newOperation.Amount          = dtOperations.Rows[i]["Amount"].ToString();
                            newOperation.ReckonAmount    = "0";
                            newOperation.OperationDate   = dgr.Cells["OperationDate"].Value.ToString();
                            newOperation.OperaterName    = MainForm.AccountName;
                            newOperation.PreOperationID  = preOperationID;
                            newOperation.NextOperationID = 0;
                            newOperation.Deleted         = 0;
                            newOperation.Save();

                            DDOperation oldOperation = new DDOperation("OperationID", preOperationID);
                            oldOperation.NextOperationID = newOperation.OperationID;
                            oldOperation.Save();


                            //更新当品信息与当票信息
                            DDPawnageInfo newPawn = new DDPawnageInfo("PawnageID", dtOperations.Rows[i]["PawnageID"]);
                            newPawn.StatusID = 4;  //绝当
                            newPawn.Save();
                        }

                        InitGridSource();
                        dataGridView1.DataSource = m_GridTable;
                        MessageBox.Show("绝当处理成功!", "绝当");
                    }
                }
                else
                {
                    MessageBox.Show("该当票不能进行绝当操作!", "绝当");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
        private void OperationCount()
        {
            try
            {
                DateTime startDate = Convert.ToDateTime(this.tbxStartDate.Text.Trim());
                DateTime endDate   = Convert.ToDateTime(this.tbxEndDate.Text.Trim());

                int newPawnCount         = 0;
                int closeOfNewCount      = 0;
                int redeemPawnCount      = 0;
                int renewPawnCount       = 0;
                int closePawnCount       = 0;
                int goldOfClosePawnCount = 0;

                int operationType = 0;

                string    selectList      = string.Format("{0},{1},{2},{3},{4}", DDOperation.OperationNumberColumn.ColumnName, DDOperation.OperationTypeColumn.ColumnName, DDOperation.PawnageIDColumn.ColumnName, DDOperation.TicketIDColumn.ColumnName, DDOperation.OperationDateColumn.ColumnName);
                Query     queryOperations = new Query(DDOperation.Schema).SetSelectList(selectList).AddBetweenAnd("OperationDate", startDate, endDate).ORDER_BY(DDOperation.OperationNumberColumn.ColumnName);
                DataTable dtOperations    = queryOperations.ExecuteDataSet().Tables[0];
                if (dtOperations.Rows.Count > 0)
                {
                    string operationNumber    = "0";
                    string preOperationNumber = "0";
                    for (int i = 0; i < dtOperations.Rows.Count; i++)
                    {
                        operationNumber = dtOperations.Rows[i]["OperationNumber"].ToString();

                        if (operationNumber != preOperationNumber)
                        {
                            operationType = Convert.ToInt32(dtOperations.Rows[i]["OperationType"]);
                            switch (operationType)
                            {
                            case 1:
                                newPawnCount++;
                                DDPawnTicket newTicket = new DDPawnTicket("TicketID", Convert.ToInt32(dtOperations.Rows[i]["TicketID"]));
                                if (newTicket.StatusID == 4 || newTicket.StatusID == 7)
                                {
                                    closeOfNewCount++;
                                }
                                break;

                            case 2:
                                redeemPawnCount++;
                                break;

                            case 3:
                                renewPawnCount++;
                                break;

                            case 4:
                                closePawnCount++;
                                DDPawnageInfo newPawnage = new DDPawnageInfo("PawnageID", Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]));
                                if (newPawnage.ParentID == 2)      //109:黄金类ClassID
                                {
                                    goldOfClosePawnCount++;
                                }
                                break;

                            default:
                                break;
                            }
                            preOperationNumber = operationNumber;
                        }
                    }
                }

                double allNewPawnCount = 0;
                //double closeOfAllNewPawnCount = 0;
                double allRedeemPawnCount = 0;
                double allClosePawnCount  = 0;

                DDCompanyInfo company            = new DDCompanyInfo("CompanyID", 1);
                DateTime      setupDate          = Convert.ToDateTime(company.SetupDate);
                Query         queryAllOperations = new Query(DDOperation.Schema).SetSelectList(selectList).DISTINCT().ORDER_BY(DDOperation.OperationNumberColumn.ColumnName);
                queryAllOperations.AddBetweenAnd("OperationDate", setupDate, endDate);  //所有的操作记录
                DataTable dtAllOperations = queryAllOperations.ExecuteDataSet().Tables[0];
                if (dtAllOperations.Rows.Count > 0)
                {
                    string operationNumber    = "0";
                    string preOperationNumber = "0";

                    for (int j = 0; j < dtAllOperations.Rows.Count; j++)
                    {
                        operationNumber = dtAllOperations.Rows[j]["OperationNumber"].ToString();
                        if (operationNumber != preOperationNumber)
                        {
                            operationType = Convert.ToInt32(dtAllOperations.Rows[j]["OperationType"]);
                            if (operationType == 1)
                            {
                                allNewPawnCount++;
                                //    DDPawnTicket newTicket = new DDPawnTicket("TicketID", Convert.ToInt32(dtAllOperations.Rows[j]["TicketID"]));
                                //    if (newTicket.StatusID == 4 || newTicket.StatusID == 7)
                                //    {
                                //        closeOfAllNewPawnCount++;
                                //    }
                            }
                            if (operationType == 2)
                            {
                                allRedeemPawnCount++;
                            }
                            if (operationType == 4)
                            {
                                allClosePawnCount++;
                            }
                            preOperationNumber = operationNumber;
                        }
                    }
                }

                double startTotalCount = 0;
                double endTotalCount   = 0;
                double increCount      = 0;
                endTotalCount   = allNewPawnCount - allRedeemPawnCount - allClosePawnCount;
                increCount      = newPawnCount - redeemPawnCount - closePawnCount;
                startTotalCount = endTotalCount - increCount;

                this.lblNewPawnCount.Text     = newPawnCount.ToString();
                this.lblCloseOfNewCount.Text  = closeOfNewCount.ToString();
                this.lblRenewPawnCount.Text   = renewPawnCount.ToString();
                this.lblSalesCount.Text       = (newPawnCount + renewPawnCount).ToString();
                this.lblRedeemPawnCount.Text  = redeemPawnCount.ToString();
                this.lblClosePawnCount.Text   = closePawnCount.ToString();
                this.lblGoldOfCloseCount.Text = goldOfClosePawnCount.ToString();

                this.lblStartTotalCount.Text = startTotalCount.ToString();
                this.lblEndTotalCount.Text   = endTotalCount.ToString();
                this.lblIncreCount.Text      = increCount.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #14
0
        private void OperationAmount()
        {
            DateTime startDate = Convert.ToDateTime(this.tbxStartDate.Text.Trim());
            DateTime endDate   = Convert.ToDateTime(this.tbxEndDate.Text.Trim());

            double newPawnAmount         = 0;
            double closeOfNewAmount      = 0;
            double redeemPawnAmount      = 0;
            double renewPawnAmount       = 0;
            double closePawnAmount       = 0;
            double goldOfClosePawnAmount = 0;
            double clearPawnAmount       = 0;
            double clearPawnReckonAmount = 0;
            double reckoningPL           = 0; //清算盈亏
            double unclearPawnAmount     = 0;
            double newPawnServiceFee     = 0; //建当服务费
            double renewPawnServiceFee   = 0; //续当服务费
            double interestFee           = 0; //典当利息
            double overDueFee            = 0; //逾期服务费
            double returnFee             = 0; //返回服务费
            double totalFee = 0;              //总计营收

            int    operationType = 0;
            double amount        = 0;

            Query queryOperations = new Query(DDOperation.Schema);

            queryOperations.AddBetweenAnd("OperationDate", startDate, endDate);
            DataTable dtOperations = queryOperations.ExecuteDataSet().Tables[0];

            if (dtOperations.Rows.Count > 0)
            {
                for (int i = 0; i < dtOperations.Rows.Count; i++)
                {
                    operationType = Convert.ToInt32(dtOperations.Rows[i]["OperationType"]);
                    amount        = Convert.ToDouble(dtOperations.Rows[i]["Amount"]);

                    switch (operationType)
                    {
                    case 1:
                        newPawnAmount += amount;
                        DDPawnTicket newTicket = new DDPawnTicket("TicketID", Convert.ToInt32(dtOperations.Rows[i]["TicketID"]));
                        if (newTicket.StatusID == 4 || newTicket.StatusID == 7)
                        {
                            closeOfNewAmount += amount;
                        }
                        newPawnServiceFee += Convert.ToDouble(dtOperations.Rows[i]["ServiceFee"]);
                        interestFee       += Convert.ToDouble(dtOperations.Rows[i]["InterestFee"]);
                        break;

                    case 2:
                        redeemPawnAmount += amount;
                        overDueFee       += Convert.ToDouble(dtOperations.Rows[i]["OverdueFee"]);
                        returnFee        += Convert.ToDouble(dtOperations.Rows[i]["ReturnFee"]);
                        interestFee      += Convert.ToDouble(dtOperations.Rows[i]["InterestFee"]);
                        break;

                    case 3:
                        renewPawnAmount     += amount;
                        renewPawnServiceFee += Convert.ToDouble(dtOperations.Rows[i]["ServiceFee"]);
                        interestFee         += Convert.ToDouble(dtOperations.Rows[i]["InterestFee"]);
                        break;

                    case 4:
                        closePawnAmount += amount;
                        DDPawnageInfo newPawnage = new DDPawnageInfo("PawnageID", Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]));
                        if (newPawnage.ParentID == 2)      //2:黄金类ClassID
                        {
                            goldOfClosePawnAmount += amount;
                        }
                        break;

                    case 7:
                        clearPawnAmount       += amount;
                        clearPawnReckonAmount += Convert.ToDouble(dtOperations.Rows[i]["ReckonAmount"]);
                        break;

                    default:
                        break;
                    }
                }
                reckoningPL       = clearPawnReckonAmount - clearPawnAmount; //清算盈亏
                unclearPawnAmount = closePawnAmount - clearPawnAmount;       //未清算金额
                totalFee          = newPawnServiceFee + renewPawnServiceFee + interestFee + overDueFee - returnFee;
            }

            double allNewPawnAmount = 0;
            //double closeOfAllNewPawnAmount = 0;
            double allRedeemPawnAmount = 0;
            double allClosePawnAmount  = 0;

            DDCompanyInfo company            = new DDCompanyInfo("CompanyID", 1);
            DateTime      setupDate          = Convert.ToDateTime(company.SetupDate);
            Query         queryAllOperations = new Query(DDOperation.Schema);

            queryAllOperations.AddBetweenAnd("OperationDate", setupDate, endDate);  //所有的操作记录
            DataTable dtAllOperations = queryAllOperations.ExecuteDataSet().Tables[0];

            if (dtAllOperations.Rows.Count > 0)
            {
                for (int j = 0; j < dtAllOperations.Rows.Count; j++)
                {
                    operationType = Convert.ToInt32(dtAllOperations.Rows[j]["OperationType"]);
                    amount        = Convert.ToDouble(dtAllOperations.Rows[j]["Amount"]);
                    if (operationType == 1)
                    {
                        allNewPawnAmount += amount;
                        //DDPawnTicket newTicket = new DDPawnTicket("TicketID", Convert.ToInt32(dtAllOperations.Rows[j]["TicketID"]));
                        //if (newTicket.StatusID == 4 || newTicket.StatusID == 7)
                        //{
                        //    closeOfAllNewPawnAmount += amount;
                        //}
                    }
                    if (operationType == 2)
                    {
                        allRedeemPawnAmount += amount;
                    }
                    if (operationType == 4)
                    {
                        allClosePawnAmount += amount;
                    }
                }
            }
            double startTotalAmount = 0;
            double endTotalAmount   = 0;
            double increAmount      = 0;
            double totalAmount      = 0;

            endTotalAmount   = allNewPawnAmount - allClosePawnAmount - allRedeemPawnAmount;
            increAmount      = newPawnAmount - closePawnAmount - redeemPawnAmount;
            startTotalAmount = endTotalAmount - increAmount;
            totalAmount      = endTotalAmount + unclearPawnAmount;

            double percentCloseOfNewPawn             = 0;
            double percentIncreOfStart               = 0;
            double percentIncreOfEnd                 = 0;
            double percentNewPawnServiceFeeOfTotal   = 0;
            double percentRenewPawnServiceFeeOfTotal = 0;
            double percentInterestFeeOfTotal         = 0;
            double percentRetureFeeOfTotal           = 0;
            double percentOverdueFeeOfTotal          = 0;

            if (newPawnAmount != 0)
            {
                percentCloseOfNewPawn = closeOfNewAmount * 100 / newPawnAmount;
                percentCloseOfNewPawn = DianDangFunction.myRound(percentCloseOfNewPawn, MainForm.AmountAccuracy);
            }

            if (startTotalAmount != 0)
            {
                percentIncreOfStart = increAmount * 100 / startTotalAmount;
                percentIncreOfStart = DianDangFunction.myRound(percentIncreOfStart, MainForm.AmountAccuracy);
            }

            if (endTotalAmount != 0)
            {
                percentIncreOfEnd = increAmount * 100 / endTotalAmount;
                percentIncreOfEnd = DianDangFunction.myRound(percentIncreOfEnd, MainForm.AmountAccuracy);
            }

            if (totalFee != 0)
            {
                percentNewPawnServiceFeeOfTotal   = newPawnServiceFee * 100 / totalFee;
                percentNewPawnServiceFeeOfTotal   = DianDangFunction.myRound(percentNewPawnServiceFeeOfTotal, MainForm.AmountAccuracy);
                percentRenewPawnServiceFeeOfTotal = renewPawnServiceFee * 100 / totalFee;
                percentRenewPawnServiceFeeOfTotal = DianDangFunction.myRound(percentRenewPawnServiceFeeOfTotal, MainForm.AmountAccuracy);
                percentInterestFeeOfTotal         = interestFee * 100 / totalFee;
                percentInterestFeeOfTotal         = DianDangFunction.myRound(percentInterestFeeOfTotal, MainForm.AmountAccuracy);
                percentRetureFeeOfTotal           = returnFee * 100 / totalFee;
                percentRetureFeeOfTotal           = DianDangFunction.myRound(percentRetureFeeOfTotal, MainForm.AmountAccuracy);
                percentOverdueFeeOfTotal          = overDueFee * 100 / totalFee;
                percentOverdueFeeOfTotal          = DianDangFunction.myRound(percentOverdueFeeOfTotal, MainForm.AmountAccuracy);
            }

            this.lblNewPawnAmount.Text     = newPawnAmount.ToString();
            this.lblCloseOfNewAmount.Text  = closeOfNewAmount.ToString();
            this.lblRenewPawnAmount.Text   = renewPawnAmount.ToString();
            this.lblSalesSize.Text         = (newPawnAmount + renewPawnAmount).ToString();
            this.lblRedeemPawnAmount.Text  = redeemPawnAmount.ToString();
            this.lblClosePawnAmount.Text   = closePawnAmount.ToString();
            this.lblGoldOfCloseAmount.Text = goldOfClosePawnAmount.ToString();
            this.lblStartTotalAmount.Text  = startTotalAmount.ToString();
            this.lblEndTotalAmount.Text    = endTotalAmount.ToString();
            this.lblIncreAmount.Text       = increAmount.ToString();
            this.lblTotalFee.Text          = totalFee.ToString();
            newPawnServiceFee = DianDangFunction.myRound(newPawnServiceFee, MainForm.AmountAccuracy);
            this.lblNewPawnServiceFee.Text   = newPawnServiceFee.ToString();
            this.lblRenewPawnServiceFee.Text = renewPawnServiceFee.ToString();
            this.lblInterestFee.Text         = interestFee.ToString();
            this.lblOverDueFee.Text          = overDueFee.ToString();
            this.lblReturnFee.Text           = returnFee.ToString();
            this.lblCloseClearAmount.Text    = clearPawnAmount.ToString();       //绝当处理金额
            this.lblClearAmount.Text         = clearPawnReckonAmount.ToString(); //清算金额
            this.lblReckoningPL.Text         = reckoningPL.ToString();
            this.lblUnclearAmount.Text       = unclearPawnAmount.ToString();
            this.lblTotalAmount.Text         = totalAmount.ToString();
            //总收入
            this.lblTotalIncommingAmount.Text = (totalFee + redeemPawnAmount).ToString();
            //总支出
            this.lblTotalOutAmount.Text = newPawnAmount.ToString();
            //收支余额
            this.lblTotalBalance.Text = (totalFee + redeemPawnAmount - newPawnAmount).ToString("0.00");

            this.lblCloseOfNewPercent.Text      = percentCloseOfNewPawn.ToString();
            this.lblIncreOfStartPercent.Text    = percentIncreOfStart.ToString();
            this.lblIncreOfEndPercent.Text      = percentIncreOfEnd.ToString();
            this.lblNewServiceFeeOfTotal.Text   = percentNewPawnServiceFeeOfTotal.ToString();
            this.lblRenewServiceFeeOfTotal.Text = percentRenewPawnServiceFeeOfTotal.ToString();
            this.lblInterestFeeOfTotal.Text     = percentInterestFeeOfTotal.ToString();
            this.lblReturnfeeOfTotal.Text       = percentRetureFeeOfTotal.ToString();
            this.lblOverdueFeeOfTotal.Text      = percentOverdueFeeOfTotal.ToString();
        }
Example #15
0
        private void UpdateOperation()
        {
            try
            {
                if (dataGridView1.Rows.Count > 0)
                {
                    DDPawnTicket newTicket = new DDPawnTicket("TicketID", m_TicketID);

                    newTicket.StatusID = 3;  //3:续当
                    newTicket.EndDate  = this.tbxEndDate.Text;
                    newTicket.Save();

                    int iPawnageID     = 0;
                    int preOperationID = 0;

                    for (int i = dataGridView1.Rows.Count - 1; i > -1; i--)
                    {
                        DataGridViewRow dgr = dataGridView1.Rows[i];
                        iPawnageID = Convert.ToInt32(dgr.Cells["PawnageID"].Value);
                        DDPawnageInfo newInfo = new DDPawnageInfo("PawnageID", iPawnageID);


                        preOperationID = Convert.ToInt32(dgr.Cells["OperationID"].Value);
                        DDOperation newOperation = new DDOperation();
                        newOperation.TicketID        = m_TicketID;
                        newOperation.PawnageID       = iPawnageID;
                        newOperation.OperationType   = 3; //3 :续当
                        newOperation.OperationNumber = m_OperationNumber;
                        newOperation.ServiceFee      = dataGridView1.Rows[i].Cells["ServiceFee"].Value.ToString();
                        newOperation.InterestFee     = dataGridView1.Rows[i].Cells["InterestFee"].Value.ToString();
                        newOperation.ReturnFee       = "0";
                        newOperation.OverdueFee      = "0";
                        newOperation.Amount          = dgr.Cells["Amount"].Value.ToString();
                        newOperation.ReckonAmount    = "0";
                        newOperation.OperationDate   = this.tbxOperationDate.Text;
                        newOperation.StartDate       = this.tbxStartDate.Text;
                        newOperation.EndDate         = this.tbxEndDate.Text;
                        DDUser newOperater = new DDUser("AccountName", MainForm.AccountName);
                        newOperation.OperaterName    = newOperater.UserName;
                        newOperation.PreOperationID  = preOperationID;
                        newOperation.ServiceFeeRate  = dgr.Cells["FeeRate"].Value.ToString();
                        newOperation.InterestFeeRate = dgr.Cells["InterestRate"].Value.ToString();
                        newOperation.NextOperationID = 0;
                        newOperation.Deleted         = 0;
                        newOperation.Save();

                        DDOperation oldOperation = new DDOperation("OperationID", preOperationID);
                        oldOperation.NextOperationID = newOperation.OperationID;
                        oldOperation.Save();

                        newInfo.FeeRate      = dgr.Cells["FeeRate"].Value.ToString();
                        newInfo.InterestRate = dgr.Cells["InterestRate"].Value.ToString();
                        newInfo.EndDate      = this.tbxEndDate.Text;
                        newInfo.StatusID     = 3; //续当
                        newInfo.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #16
0
 private void UpdatePawages(int ticketID)
 {
     if (tbxCount1.Text != "0")
     {
         try
         {
             DDPawnageInfo newInfo = new DDPawnageInfo();
             newInfo.ClassID         = Convert.ToInt32(this.cbxChildClass1.SelectedValue);
             newInfo.ParentID        = Convert.ToInt32(this.cbxParentClass1.SelectedValue);
             newInfo.CountNumber     = this.tbxCount1.Text;
             newInfo.Price           = this.tbxPrice1.Text;
             newInfo.DiscountPercent = this.tbxPercent1.Text;
             newInfo.Amount          = this.tbxPawnageAmount1.Text;
             newInfo.Description     = this.tbxDescr1.Text;
             newInfo.TicketID        = ticketID;
             newInfo.IsReif          = 0;
             newInfo.Save();
         }
         catch
         {
             MessageBox.Show("当品添加失败,请检查数据库连接状态!");
         }
     }
     if (tbxCount2.Text != "0")
     {
         try
         {
             DDPawnageInfo newInfo = new DDPawnageInfo();
             newInfo.ClassID         = Convert.ToInt32(this.cbxChildClass2.SelectedValue);
             newInfo.ParentID        = Convert.ToInt32(this.cbxParentClass2.SelectedValue);
             newInfo.CountNumber     = this.tbxCount2.Text;
             newInfo.Price           = this.tbxPrice2.Text;
             newInfo.DiscountPercent = this.tbxPercent2.Text;
             newInfo.Amount          = this.tbxPawnageAmount2.Text;
             newInfo.Description     = this.tbxDescr2.Text;
             newInfo.TicketID        = ticketID;
             newInfo.IsReif          = 0;
             newInfo.Save();
         }
         catch
         {
             MessageBox.Show("当品添加失败,请检查数据库连接状态!");
         }
     }
     if (tbxCount3.Text != "0")
     {
         try
         {
             DDPawnageInfo newInfo = new DDPawnageInfo();
             newInfo.ClassID         = Convert.ToInt32(this.cbxChildClass3.SelectedValue);
             newInfo.ParentID        = Convert.ToInt32(this.cbxParentClass3.SelectedValue);
             newInfo.CountNumber     = this.tbxCount3.Text;
             newInfo.Price           = this.tbxPrice3.Text;
             newInfo.DiscountPercent = this.tbxPercent3.Text;
             newInfo.Amount          = this.tbxPawnageAmount3.Text;
             newInfo.Description     = this.tbxDescr3.Text;
             newInfo.TicketID        = ticketID;
             newInfo.IsReif          = 0;
             newInfo.Save();
         }
         catch
         {
             MessageBox.Show("当品添加失败,请检查数据库连接状态!");
         }
     }
 }
        private void LoadTemplate(int iTicketID, string strOperationNumber)
        {
            string thePrice;

            MSExcel.Application excelApp;              //Excel应用程序变量
            MSExcel.Workbook    excelDoc;              //Excel文档变量
            excelApp = new MSExcel.ApplicationClass(); //初始化
            //由于使用的是COM库,因此有许多变量需要用Nothing代替
            Object Nothing = Missing.Value;

            excelDoc = excelApp.Workbooks._Open(Application.StartupPath + @"\Pram\ReceiptTemplate.dd", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

            //使用第一个工作表作为插入数据的工作表
            MSExcel.Worksheet ws = (MSExcel.Worksheet)excelDoc.Sheets[1];

            //声明一个MSExcel.Range 类型的变量r
            MSExcel.Range r;

            DDPawnTicket newTicket = new DDPawnTicket("TicketID", iTicketID);

            switch (newTicket.StatusID)
            {
            case 1:
                r = ws.get_Range(("B" + 3), ("B" + 3)); r.Value2 = "新当";
                break;

            case 2:
                r = ws.get_Range(("B" + 3), ("B" + 3)); r.Value2 = "赎当";
                break;

            case 3:
                r = ws.get_Range(("B" + 3), ("B" + 3)); r.Value2 = "续当";
                break;

            default:
                break;
            }
            r = ws.get_Range(("C" + 4), ("C" + 4)); r.Value2 = newTicket.TicketNumber;
            //this.lblTicketNumber.Text = newTicket.TicketNumber;

            DateTime currentDate = DateTime.Now;
            string   strYear     = currentDate.Year.ToString();
            string   strMonth    = currentDate.Month.ToString();
            string   strDay      = currentDate.Day.ToString();

            //this.lblYear.Text = strYear;
            //this.lblMonth.Text = strMonth;
            //this.lblDay.Text = strDay;
            r = ws.get_Range(("V" + 4), ("V" + 4)); r.Value2 = strYear;
            r = ws.get_Range(("X" + 4), ("X" + 4)); r.Value2 = strMonth;
            r = ws.get_Range(("Z" + 4), ("Z" + 4)); r.Value2 = strDay;

            double totalAmount = 0;
            string strItem     = "";
            Query  query       = new Query(DDOperation.Schema);

            query.AddWhere("TicketID", iTicketID);
            query.AddWhere("OperationType", 1);
            DataTable dt = query.ExecuteDataSet().Tables[0];

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DDPawnageInfo  newInfo  = new DDPawnageInfo("PawnageID", Convert.ToInt32(dt.Rows[i]["PawnageID"]));
                    DDPawnageClass newClass = new DDPawnageClass("ClassID", newInfo.ClassID);
                    switch (i)
                    {
                    case 0:
                        //this.lblPawnageInfo1.Text = newClass.ClassName + dt.Rows[i]["Amount"].ToString();
                        strItem = newClass.ClassName;
                        //r = ws.get_Range(("J" + 6), ("J" + 6)); r.Value2 = newClass.ClassName + dt.Rows[i]["Amount"].ToString();
                        break;

                    case 1:
                        //this.lblPawnageInfo2.Text = newClass.ClassName + dt.Rows[i]["Amount"].ToString();
                        //r = ws.get_Range(("C" + 7), ("C" + 7)); r.Value2 = newClass.ClassName + dt.Rows[i]["Amount"].ToString();
                        strItem = strItem + "等";
                        break;

                    case 2:
                        //this.lblPawnageInfo3.Text = newClass.ClassName + dt.Rows[i]["Amount"].ToString();
                        //r = ws.get_Range(("C" + 8), ("C" + 8)); r.Value2 = newClass.ClassName + dt.Rows[i]["Amount"].ToString();
                        break;

                    default:
                        break;
                    }
                    totalAmount += Convert.ToDouble(dt.Rows[i]["Amount"]);
                }

                r = ws.get_Range(("C" + 6), ("C" + 6)); r.Value2 = strItem + " " + totalAmount;
            }

            Query queryCurrentOperation = new Query(DDOperation.Schema);

            queryCurrentOperation.AddWhere("OperationNumber", strOperationNumber);
            DataTable dtCurrentOperation   = queryCurrentOperation.ExecuteDataSet().Tables[0];
            int       currentOperationType = Convert.ToInt32(dtCurrentOperation.Rows[0]["OperationType"]);

            double overdueFee      = 0;
            double returnFee       = 0;
            double serviceFee      = 0;
            double interestFee     = 0;
            string serviceFeeRate  = "";
            string interestFeeRate = "";
            int    preOperationID  = 0;

            if (dtCurrentOperation.Rows.Count > 0)
            {
                serviceFeeRate = dtCurrentOperation.Rows[0]["ServiceFeeRate"].ToString();
                preOperationID = Convert.ToInt32(dtCurrentOperation.Rows[0]["PreOperationID"]);
                if (preOperationID != 0)
                {
                    DDOperation preOperation = new DDOperation("OperationID", preOperationID);
                    //interestFee += Convert.ToDouble(preOperation.InterestFee);
                    interestFeeRate = preOperation.InterestFeeRate;
                }
                for (int i = 0; i < dtCurrentOperation.Rows.Count; i++)
                {
                    overdueFee  += Convert.ToDouble(dtCurrentOperation.Rows[i]["OverdueFee"]);
                    returnFee   += Convert.ToDouble(dtCurrentOperation.Rows[i]["ReturnFee"]);
                    serviceFee  += Convert.ToDouble(dtCurrentOperation.Rows[i]["ServiceFee"]);
                    interestFee += Convert.ToDouble(dtCurrentOperation.Rows[i]["interestFee"]);
                }
            }

            if (currentOperationType != 1)
            {
                r = ws.get_Range(("H" + 8), ("H" + 8)); r.Value2 = "上期利息: " + interestFeeRate.ToString() + "%";
                //r = ws.get_Range(("I" + 8), ("I" + 8)); r.Value2 = "%";
                if (interestFee != 0)
                {
                    thePrice = interestFee.ToString("0.00");
                    thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);
                }
                else
                {
                    thePrice = "000";
                }

                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 8), ("M" + 8)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 8), ("N" + 8)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 8), ("O" + 8)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 8), ("P" + 8)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 8), ("Q" + 8)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 8), ("R" + 8)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 8), ("S" + 8)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 8), ("T" + 8)); r.Value2 = thePrice.Substring(7, 1);
            }



            double paidFee = 0;

            if (currentOperationType != 2)
            {
                if (currentOperationType == 1)
                {
                    r       = ws.get_Range(("H" + 10), ("H" + 10)); r.Value2 = "新当服务费: " + serviceFee.ToString("0.00");
                    paidFee = serviceFee;
                }
                else
                {
                    r       = ws.get_Range(("H" + 10), ("H" + 10)); r.Value2 = "续当服务费: " + serviceFee.ToString("0.00");
                    paidFee = serviceFee + interestFee;
                }
                //r = ws.get_Range(("H" + 12), ("H" + 12)); r.Value2 ="收:"+ newChinese.toChineseChar(Convert.ToDecimal(serviceFee));
                r = ws.get_Range(("H" + 12), ("H" + 12)); r.Value2 = "" + newChinese.toChineseChar(Convert.ToDecimal(paidFee));
                if (serviceFee != 0)
                {
                    thePrice = serviceFee.ToString("0.00");
                    thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);
                }
                else
                {
                    thePrice = "000";
                }

                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 10), ("M" + 10)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 10), ("N" + 10)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 10), ("O" + 10)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 10), ("P" + 10)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 10), ("Q" + 10)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 10), ("R" + 10)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 10), ("S" + 10)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 10), ("T" + 10)); r.Value2 = thePrice.Substring(7, 1);


                if (paidFee != 0)
                {
                    thePrice = paidFee.ToString("0.00");
                    thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);
                }
                else
                {
                    thePrice = "000";
                }

                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 12), ("M" + 12)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 12), ("N" + 12)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 12), ("O" + 12)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 12), ("P" + 12)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 12), ("Q" + 12)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 12), ("R" + 12)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 12), ("S" + 12)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 12), ("T" + 12)); r.Value2 = thePrice.Substring(7, 1);
            }

            if (overdueFee > 0)
            {
                //this.lblFee.Text = "逾期服务费" + overdueFee.ToString();
                //this.lblTotalFee.Text = "收:" + newChinese.toChineseChar(Convert.ToDecimal(overdueFee));
                //this.lblTotalFeeNumber.Text = FormatString(overdueFee.ToString("0.00"));
                //this.lblFeeNumber.Text = FormatString(overdueFee.ToString("0.00"));

                r = ws.get_Range(("H" + 10), ("H" + 10)); r.Value2 = "逾期服务费: " + overdueFee.ToString("0.00");
                //r = ws.get_Range(("H" + 12), ("H" + 12)); r.Value2 = "收:" + newChinese.toChineseChar(Convert.ToDecimal(overdueFee));
                paidFee  = overdueFee + interestFee;
                r        = ws.get_Range(("H" + 12), ("H" + 12)); r.Value2 = newChinese.toChineseChar(Convert.ToDecimal(paidFee));
                thePrice = overdueFee.ToString("0.00");
                thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);

                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 10), ("M" + 10)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 10), ("N" + 10)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 10), ("O" + 10)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 10), ("P" + 10)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 10), ("Q" + 10)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 10), ("R" + 10)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 10), ("S" + 10)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 10), ("T" + 10)); r.Value2 = thePrice.Substring(7, 1);

                thePrice = paidFee.ToString("0.00");
                thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);

                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 12), ("M" + 12)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 12), ("N" + 12)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 12), ("O" + 12)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 12), ("P" + 12)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 12), ("Q" + 12)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 12), ("R" + 12)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 12), ("S" + 12)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 12), ("T" + 12)); r.Value2 = thePrice.Substring(7, 1);
            }
            if (returnFee > 0)
            {
                //this.lblFee.Text = "返回服务费" + returnFee.ToString();
                //this.lblTotalFee.Text = "退:" + newChinese.toChineseChar(Convert.ToDecimal(returnFee));
                //this.lblTotalFeeNumber.Text = FormatString(returnFee.ToString("0.00"));
                //this.lblFeeNumber.Text = FormatString(returnFee.ToString("0.00"));
                r        = ws.get_Range(("H" + 10), ("H" + 10)); r.Value2 = "返回服务费: " + returnFee.ToString("0.00");
                paidFee  = interestFee - returnFee;
                r        = ws.get_Range(("H" + 12), ("H" + 12)); r.Value2 = "退: " + newChinese.toChineseChar(Convert.ToDecimal(paidFee));
                thePrice = returnFee.ToString("0.00");
                thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);
                thePrice = "-" + thePrice;
                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 10), ("M" + 10)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 10), ("N" + 10)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 10), ("O" + 10)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 10), ("P" + 10)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 10), ("Q" + 10)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 10), ("R" + 10)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 10), ("S" + 10)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 10), ("T" + 10)); r.Value2 = thePrice.Substring(7, 1);

                thePrice = paidFee.ToString("0.00");
                thePrice = thePrice.Substring(0, thePrice.Length - 3) + thePrice.Substring(thePrice.Length - 2);
                if (thePrice.Length < 8)
                {
                    for (int j = (8 - thePrice.Length); j > 0; j--)
                    {
                        thePrice = " " + thePrice;
                    }
                }
                r = ws.get_Range(("M" + 12), ("M" + 12)); r.Value2 = thePrice.Substring(0, 1);
                r = ws.get_Range(("N" + 12), ("N" + 12)); r.Value2 = thePrice.Substring(1, 1);
                r = ws.get_Range(("O" + 12), ("O" + 12)); r.Value2 = thePrice.Substring(2, 1);
                r = ws.get_Range(("P" + 12), ("P" + 12)); r.Value2 = thePrice.Substring(3, 1);
                r = ws.get_Range(("Q" + 12), ("Q" + 12)); r.Value2 = thePrice.Substring(4, 1);
                r = ws.get_Range(("R" + 12), ("R" + 12)); r.Value2 = thePrice.Substring(5, 1);
                r = ws.get_Range(("S" + 12), ("S" + 12)); r.Value2 = thePrice.Substring(6, 1);
                r = ws.get_Range(("T" + 12), ("T" + 12)); r.Value2 = thePrice.Substring(7, 1);
            }

            Query queryAll = new Query(DDOperation.Schema);

            queryAll.AddWhere("TicketID", iTicketID);
            queryAll.AddWhere("NextOperationID", 0);
            queryAll.AddWhere("OperationType", Comparison.In, new int[] { 1, 2, 3 });
            DataTable dtAll = queryAll.ExecuteDataSet().Tables[0];

            double totalOverdueFee  = 0;
            double totalReturnFee   = 0;
            double totalServiceFee  = 0;
            double totalInterestFee = 0;

            if (dtAll.Rows.Count > 0)
            {
                for (int i = 0; i < dtAll.Rows.Count; i++)
                {
                    totalOverdueFee  += Convert.ToDouble(dtAll.Rows[i]["OverdueFee"]);
                    totalReturnFee   += Convert.ToDouble(dtAll.Rows[i]["ReturnFee"]);
                    totalServiceFee  += Convert.ToDouble(dtAll.Rows[i]["ServiceFee"]);
                    totalInterestFee += Convert.ToDouble(dtAll.Rows[i]["InterestFee"]);
                }
            }

            if (currentOperationType == 2)
            {
                totalAmount = totalAmount + totalOverdueFee + totalInterestFee - totalReturnFee;
                r           = ws.get_Range(("C" + 11), ("C" + 11)); r.Value2 = "总计交收金额: " + totalAmount.ToString("0.00");
            }

            DDUser newUser = new DDUser("AccountName", MainForm.AccountName);

            //r = ws.get_Range(("F" + 14), ("F" + 14)); r.Value2 = newUser.UserName;
            r = ws.get_Range(("F" + 14), ("F" + 14)); r.Value2 = dtAll.Rows[dtAll.Rows.Count - 1]["OperaterName"].ToString();
            //this.lblTotalAmount.Text = totalAmount.ToString();
            //this.lblOperater.Text = MainForm.AccountName;

            //WdSaveFormat为Excel文档的保存格式
            object format = MSExcel.XlFileFormat.xlWorkbookNormal;

            //打印文档
            excelDoc.PrintOut(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing);


            //将excelDoc文档对象的内容保存为dd文档
            //excelDoc.Save();
            if (File.Exists(Application.StartupPath + @"\Pram\dump.dd"))
            {
                try
                {
                    File.Delete(Application.StartupPath + @"\Pram\dump.dd");
                }
                catch (FieldAccessException e)
                {
                    MessageBox.Show("记录文件正在被使用,请退出Excel\n" + e.ToString());
                }
            }
            excelDoc.SaveAs(Application.StartupPath + @"\Pram\dump.dd", format, Nothing, Nothing, Nothing, Nothing, MSExcel.XlSaveAsAccessMode.xlExclusive, Nothing, Nothing, Nothing, Nothing, Nothing);

            //关闭excelDoc文档对象
            excelDoc.Close(Nothing, Nothing, Nothing);

            //关闭excelApp组件对象
            excelApp.Quit();
            //MessageBox.Show("生成成功");
        }
Example #18
0
 public bool Delete(object PawnageID)
 {
     return(DDPawnageInfo.Delete(PawnageID) == 1);
 }
Example #19
0
 public bool Destroy(object PawnageID)
 {
     return(DDPawnageInfo.Destroy(PawnageID) == 1);
 }
Example #20
0
        private void UpdateOperation()
        {
            try
            {
                DataGridViewRow dgr         = dataGridView1.CurrentRow;
                int             intStatusID = Convert.ToInt32(dgr.Cells["StatusID"].Value);

                if (intStatusID != 6)
                {
                    int          iTicketID = Convert.ToInt32(dgr.Cells["TicketID"].Value);
                    DDPawnTicket newTicket = new DDPawnTicket("TicketID", iTicketID);

                    Query queryOperations = new Query(DDOperation.Schema);
                    queryOperations.AddWhere("TicketID", iTicketID);
                    //queryOperations.AddWhere("OperationType", 1);
                    queryOperations.AddWhere("NextOperationID", 0);
                    DataTable dtOperations = queryOperations.ExecuteDataSet().Tables[0];
                    if (dtOperations.Rows.Count > 0)
                    {
                        newTicket.StatusID = 5;
                        newTicket.Save();
                        DateTime operateDate    = DateTime.Now;
                        string   strDate        = operateDate.Year.ToString() + "-" + operateDate.Month.ToString() + "-" + operateDate.Day.ToString();
                        int      preOperationID = 0;

                        for (int i = 0; i < dtOperations.Rows.Count; i++)
                        {
                            DDOperation newOperation = new DDOperation();
                            preOperationID               = Convert.ToInt32(dtOperations.Rows[i]["OperationID"]);
                            newOperation.TicketID        = iTicketID;
                            newOperation.PawnageID       = Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]);
                            newOperation.OperationType   = 5; //5 :冻结
                            newOperation.OperationNumber = m_OperationNumber;
                            newOperation.ServiceFee      = "0";
                            newOperation.InterestFee     = "0";
                            newOperation.ReturnFee       = "0";
                            newOperation.OverdueFee      = "0";
                            newOperation.Amount          = dtOperations.Rows[i]["Amount"].ToString();
                            newOperation.ReckonAmount    = "0";
                            newOperation.OperationDate   = strDate;
                            newOperation.OperaterName    = MainForm.AccountName;
                            newOperation.PreOperationID  = preOperationID;
                            newOperation.NextOperationID = 0;
                            newOperation.Deleted         = 0;
                            newOperation.Save();

                            DDOperation oldOperation = new DDOperation("OperationID", preOperationID);
                            oldOperation.NextOperationID = newOperation.OperationID;
                            oldOperation.Save();

                            //更新当品信息
                            DDPawnageInfo newInfo = new DDPawnageInfo("PawnageID", Convert.ToInt32(dtOperations.Rows[i]["PawnageID"]));
                            newInfo.StatusID = 5;
                            newInfo.Save();
                        }

                        InitGridSource();
                        dataGridView1.DataSource = m_GridTable;
                        MessageBox.Show("冻结处理成功!", "冻结");
                    }
                }
                else
                {
                    MessageBox.Show("该当票不能进行冻结操作!", "冻结");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #21
0
        private void UpdateOperation()
        {
            if (dataGridView1.Rows.Count > 0)
            {
                DDPawnTicket newTicket = new DDPawnTicket("TicketID", m_TicketID);

                newTicket.StatusID = 3;  //3:续当
                newTicket.EndDate  = this.tbxEndDate.Text;
                newTicket.Save();

                int iPawnageID     = 0;
                int preOperationID = 0;

                PawnSpan Span = new PawnSpan();
                Span = DianDangFunction.GetPawnSpan(DateTime.Parse(tbxStartDate.Text), DateTime.Parse(tbxEndDate.Text));

                for (int i = dataGridView1.Rows.Count - 1; i > -1; i--)
                {
                    DataGridViewRow dgr = dataGridView1.Rows[i];
                    try
                    {
                        iPawnageID = Convert.ToInt32(dgr.Cells["PawnageID"].Value);
                        DDPawnageInfo newInfo = new DDPawnageInfo("PawnageID", iPawnageID);


                        preOperationID = Convert.ToInt32(dgr.Cells["OperationID"].Value);
                        DDOperation newOperation = new DDOperation();
                        newOperation.TicketID        = m_TicketID;
                        newOperation.PawnageID       = iPawnageID;
                        newOperation.OperationType   = 3; //3 :续当
                        newOperation.OperationNumber = m_OperationNumber;
                        newOperation.ServiceFee      = dataGridView1.Rows[i].Cells["ServiceFee"].Value.ToString();
                        newOperation.InterestFee     = dataGridView1.Rows[i].Cells["InterestFee"].Value.ToString();
                        newOperation.ReturnFee       = "0";
                        newOperation.OverdueFee      = "0";
                        newOperation.Amount          = dgr.Cells["Amount"].Value.ToString();
                        newOperation.ReckonAmount    = "0";
                        newOperation.OperationDate   = this.tbxOperationDate.Text;
                        newOperation.StartDate       = this.tbxStartDate.Text;
                        newOperation.EndDate         = this.tbxEndDate.Text;
                        DDUser newOperater = new DDUser("AccountName", MainForm.AccountName);
                        newOperation.OperaterName    = newOperater.UserName;
                        newOperation.PreOperationID  = preOperationID;
                        newOperation.ServiceFeeRate  = dgr.Cells["FeeRate"].Value.ToString();
                        newOperation.InterestFeeRate = dgr.Cells["InterestRate"].Value.ToString();
                        newOperation.NextOperationID = 0;
                        newOperation.Deleted         = 0;
                        newOperation.Save();

                        DDOperation oldOperation = new DDOperation("OperationID", preOperationID);
                        oldOperation.NextOperationID = newOperation.OperationID;
                        oldOperation.Save();

                        newInfo.FeeRate      = dgr.Cells["FeeRate"].Value.ToString();
                        newInfo.InterestRate = dgr.Cells["InterestRate"].Value.ToString();
                        newInfo.EndDate      = this.tbxEndDate.Text;
                        newInfo.StatusID     = 3; //续当
                        newInfo.Save();
                    }
                    catch
                    {
                        MessageBox.Show(this, "续当操作失败,请检查数据库是否连接正确!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }