private void InitGridSource() { m_GridTable.Rows.Clear(); Query query = new Query(DDPawnTicket.Schema); string strKey = "%" + this.tbxKeyWord.Text + "%"; query.AddWhere("TicketNumber", Comparison.Like, strKey); query.AddWhere("StatusID", Comparison.NotEquals, 6); DataTable dt = query.ExecuteDataSet().Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow drow = m_GridTable.NewRow(); drow["TicketID"] = dt.Rows[i]["TicketID"]; drow["TicketNumber"] = dt.Rows[i]["TicketNumber"]; drow["StartDate"] = dt.Rows[i]["StartDate"]; drow["EndDate"] = dt.Rows[i]["EndDate"]; drow["StatusID"] = dt.Rows[i]["StatusID"]; DDCustomerInfo customerInfo = new DDCustomerInfo("CustomerID", Convert.ToInt32(dt.Rows[i]["CustomerID"])); DDOperation operation = new DDOperation("TicketID", Convert.ToInt32(dt.Rows[i]["TicketID"])); drow["CustomerName"] = customerInfo.CustomerName; drow["OperaterName"] = operation.OperaterName; m_GridTable.Rows.Add(drow); } } }
private void UpdateCloseOperation() { 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); DataTable dtOperations = queryOperations.ExecuteDataSet().Tables[0]; if (dtOperations.Rows.Count > 0) { newTicket.StatusID = 4; 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 = 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 = strDate; newOperation.OperaterName = MainForm.AccountName; newOperation.PreOperationID = preOperationID; newOperation.NextOperationID = 0; newOperation.Save(); DDOperation oldOperation = new DDOperation("OperationID", preOperationID); oldOperation.NextOperationID = newOperation.OperationID; oldOperation.Save(); } InitGridSource(); dataGridView1.DataSource = m_GridTable; MessageBox.Show("绝当处理成功!", "绝当"); } } else { MessageBox.Show("该当票不能进行绝当操作!", "绝当"); } }
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; } }
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; } }
public void Update(int OperationID, int?TicketID, int?PawnageID, int?OperationType, string OperationNumber, string ServiceFee, string InterestFee, string ReturnFee, string OverdueFee, string Amount, string ReckonAmount, string OperationDate, string StartDate, string EndDate, string OperaterName, int?PreOperationID, int?NextOperationID, int?Deleted) { DDOperation item = new DDOperation(); item.MarkOld(); item.IsLoaded = true; item.OperationID = OperationID; item.TicketID = TicketID; item.PawnageID = PawnageID; item.OperationType = OperationType; item.OperationNumber = OperationNumber; item.ServiceFee = ServiceFee; item.InterestFee = InterestFee; item.ReturnFee = ReturnFee; item.OverdueFee = OverdueFee; item.Amount = Amount; item.ReckonAmount = ReckonAmount; item.OperationDate = OperationDate; item.StartDate = StartDate; item.EndDate = EndDate; item.OperaterName = OperaterName; item.PreOperationID = PreOperationID; item.NextOperationID = NextOperationID; item.Deleted = Deleted; item.Save(UserName); }
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; } }
private void InitGridSource() { m_GridTable.Rows.Clear(); Query query = new Query(DDPawnTicket.Schema); string strStatus = this.cbxSearchRange.Text; int intStatusID = Convert.ToInt32(this.cbxSearchRange.SelectedValue); if (cbxSearchOption.SelectedValue.ToString() == "TicketNumber") { string strOption = this.cbxSearchOption.SelectedValue.ToString(); string strKey = "%" + this.tbxKeyWord.Text + "%"; query.AddWhere(strOption, Comparison.Like, strKey); } if (cbxSearchOption.SelectedValue.ToString() == "CustomerName" || cbxSearchOption.SelectedValue.ToString() == "CertNumber") { string strOption = this.cbxSearchOption.SelectedValue.ToString(); string strKey = "%" + this.tbxKeyWord.Text + "%"; Query queryCumtomer = new Query(DDCustomerInfo.Schema); queryCumtomer.AddWhere(strOption, Comparison.Like, strKey); DataTable dtCustomer = queryCumtomer.ExecuteDataSet().Tables[0]; if (this.tbxKeyWord.Text.Length == 0) { } else if (dtCustomer.Rows.Count > 0) { query.AddWhere("CustomerID", dtCustomer.Rows[0]["CustomerID"]); } else { query.AddWhere("CustomerID", 0); } } if (strStatus == "过期") { query.AddWhere("StatusID", Comparison.In, new int[] { 1, 3 }); query.AddBetweenAnd("EndDate", Convert.ToDateTime("1900-1-1"), DateTime.Now); } else if (strStatus == "在库") { query.AddWhere("StatusID", Comparison.In, new int[] { 1, 3, 4, 5 }); } else if (strStatus != "全部") { query.AddWhere("StatusID", intStatusID); } else { query.AddWhere("StatusID", Comparison.NotEquals, 6); //6--已删除 } DataTable dt = query.ExecuteDataSet().Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { //查询当品总价值 double totalAmount = 0; Query queryOperation = new Query(DDOperation.Schema); queryOperation.AddWhere("TicketID", dt.Rows[i]["TicketID"]); queryOperation.AddWhere("NextOperationID", 0); queryOperation.AddWhere("OperationType", Comparison.NotEquals, 6); DataTable dtOperation = queryOperation.ExecuteDataSet().Tables[0]; for (int j = 0; j < dtOperation.Rows.Count; j++) { totalAmount += Convert.ToInt32(dtOperation.Rows[j]["Amount"].ToString()); } DataRow drow = m_GridTable.NewRow(); drow["TicketID"] = dt.Rows[i]["TicketID"]; drow["TicketNumber"] = dt.Rows[i]["TicketNumber"]; drow["StartDate"] = dt.Rows[i]["StartDate"]; drow["EndDate"] = dt.Rows[i]["EndDate"]; drow["TotalAmount"] = totalAmount; drow["StatusID"] = dt.Rows[i]["StatusID"]; DDCustomerInfo customerInfo = new DDCustomerInfo("CustomerID", Convert.ToInt32(dt.Rows[i]["CustomerID"])); DDOperation operation = new DDOperation("TicketID", Convert.ToInt32(dt.Rows[i]["TicketID"])); drow["CustomerName"] = customerInfo.CustomerName; drow["OperaterName"] = operation.OperaterName; m_GridTable.Rows.Add(drow); } } }
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; } }
private void LoadTemplate(int iTicketID, string strOperationNumber) { double TotalAmount = 0; double TotalServiceFee = 0; double TotalLastInterestFee = 0; double TotalReturnFee = 0; double TotalOverdueFee = 0; double FirstTotalServiceFee = 0; double FirstTotalAmount = 0; List <string> strList = new List <string>(); DDPawnTicket newTicket = new DDPawnTicket("TicketID", m_TicketID); DDCustomerInfo newCustomer = new DDCustomerInfo("CustomerID", newTicket.CustomerID); Query queryOperation = new Query(DDOperation.Schema); queryOperation.AddWhere("TicketID", m_TicketID); queryOperation.AddWhere("OperationNumber", strOperationNumber); queryOperation.AddWhere("OperationType", Comparison.NotEquals, 6); DataTable dtOperation = queryOperation.ExecuteDataSet().Tables[0]; for (int i = 0; i < dtOperation.Rows.Count; i++) { TotalAmount += Convert.ToDouble(dtOperation.Rows[i]["Amount"].ToString()); TotalServiceFee += Convert.ToDouble(dtOperation.Rows[i]["ServiceFee"].ToString()); TotalLastInterestFee += Convert.ToDouble(dtOperation.Rows[i]["InterestFee"].ToString()); TotalReturnFee += Convert.ToDouble(dtOperation.Rows[i]["ReturnFee"].ToString()); TotalOverdueFee += Convert.ToDouble(dtOperation.Rows[i]["OverdueFee"].ToString()); } TotalAmount = DianDangFunction.myRound(TotalAmount, MainForm.AmountAccuracy); TotalServiceFee = DianDangFunction.myRound(TotalServiceFee, MainForm.AmountAccuracy); TotalLastInterestFee = DianDangFunction.myRound(TotalLastInterestFee, MainForm.AmountAccuracy); TotalReturnFee = DianDangFunction.myRound(TotalReturnFee, MainForm.AmountAccuracy); TotalOverdueFee = DianDangFunction.myRound(TotalOverdueFee, MainForm.AmountAccuracy); queryOperation = new Query(DDOperation.Schema); queryOperation.AddWhere("TicketID", m_TicketID); queryOperation.AddWhere("PreOperationID", 0); queryOperation.AddWhere("OperationType", Comparison.NotEquals, 6); dtOperation = queryOperation.ExecuteDataSet().Tables[0]; for (int i = 0; i < dtOperation.Rows.Count; i++) { FirstTotalAmount += Convert.ToDouble(dtOperation.Rows[i]["Amount"].ToString()); FirstTotalServiceFee += Convert.ToDouble(dtOperation.Rows[i]["ServiceFee"].ToString()); } FirstTotalAmount = DianDangFunction.myRound(FirstTotalAmount, MainForm.AmountAccuracy); FirstTotalServiceFee = DianDangFunction.myRound(FirstTotalServiceFee, MainForm.AmountAccuracy); 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\RedeemTemplate_TongBao.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; DDCompanyInfo company = new DDCompanyInfo("CompanyID", 1); //r = ws.get_Range(("F" + 4), ("F" + 4)); r.Value2 = company.CompanyName; r = ws.get_Range(("K" + 5), ("K" + 5)); r.Value2 = newTicket.TicketNumber.ToString(); r = ws.get_Range(("D" + 5), ("D" + 5)); r.Value2 = newCustomer.CustomerName; //TotalAmount: string strTotalMount = TotalAmount.ToString("0.00"); r = ws.get_Range(("D" + 7), ("D" + 7)); r.Value2 = newChinese.toChineseChar(strTotalMount); r = ws.get_Range(("M" + 7), ("M" + 7)); r.Value2 = strTotalMount; //Fee string strFirstGive = (FirstTotalAmount - FirstTotalServiceFee).ToString("0.00"); r = ws.get_Range(("E" + 13), ("E" + 13)); r.Value2 = newChinese.toChineseChar(strFirstGive); r = ws.get_Range(("L" + 13), ("L" + 13)); r.Value2 = strFirstGive; string strFirstServiceFee = FirstTotalServiceFee.ToString("0.00"); r = ws.get_Range(("E" + 15), ("E" + 15)); r.Value2 = newChinese.toChineseChar(strFirstServiceFee); r = ws.get_Range(("L" + 15), ("L" + 15)); r.Value2 = strFirstServiceFee; string strOverdue = (Math.Abs(TotalLastInterestFee + TotalOverdueFee - TotalReturnFee + TotalServiceFee)).ToString("0.00"); r = ws.get_Range(("E" + 17), ("E" + 17)); r.Value2 = newChinese.toChineseChar(strOverdue); r = ws.get_Range(("L" + 17), ("L" + 17)); r.Value2 = strOverdue; string strAll = (TotalAmount + TotalLastInterestFee + TotalOverdueFee + TotalServiceFee - TotalReturnFee).ToString("0.00"); strList = newChinese.toStrList(strAll, 5, 2); r = ws.get_Range(("D" + 19), ("D" + 19)); r.Value2 = strList[0]; r = ws.get_Range(("E" + 19), ("E" + 19)); r.Value2 = strList[1]; r = ws.get_Range(("G" + 19), ("G" + 19)); r.Value2 = strList[2]; r = ws.get_Range(("H" + 19), ("H" + 19)); r.Value2 = strList[3]; r = ws.get_Range(("I" + 19), ("I" + 19)); r.Value2 = strList[4]; r = ws.get_Range(("J" + 19), ("J" + 19)); r.Value2 = strList[5]; r = ws.get_Range(("L" + 19), ("L" + 19)); r.Value2 = strList[6]; r = ws.get_Range(("N" + 19), ("N" + 19)); r.Value2 = strAll; //日期 DDOperation ThisOperation = new DDOperation("OperationNumber", strOperationNumber); DDOperation LastOperation = new DDOperation("OperationID", ThisOperation.PreOperationID); DateTime operationDate = Convert.ToDateTime(ThisOperation.OperationDate); DateTime lastStartDate = Convert.ToDateTime(LastOperation.StartDate); DateTime lastEndDate = Convert.ToDateTime(LastOperation.EndDate); r = ws.get_Range(("C" + 9), ("C" + 9)); r.Value2 = lastStartDate.Year.ToString(); r = ws.get_Range(("E" + 9), ("E" + 9)); r.Value2 = lastStartDate.Month.ToString(); r = ws.get_Range(("G" + 9), ("G" + 9)); r.Value2 = lastStartDate.Day.ToString(); r = ws.get_Range(("I" + 9), ("I" + 9)); r.Value2 = lastEndDate.Year.ToString(); r = ws.get_Range(("J" + 9), ("J" + 9)); r.Value2 = lastEndDate.Month.ToString(); r = ws.get_Range(("L" + 9), ("L" + 9)); r.Value2 = lastEndDate.Day.ToString(); r = ws.get_Range(("B" + 11), ("B" + 11)); r.Value2 = operationDate.Year.ToString(); r = ws.get_Range(("D" + 11), ("D" + 11)); r.Value2 = operationDate.Month.ToString(); r = ws.get_Range(("G" + 11), ("G" + 11)); r.Value2 = operationDate.Day.ToString(); r = ws.get_Range(("L" + 3), ("L" + 3)); r.Value2 = operationDate.Year.ToString(); r = ws.get_Range(("N" + 3), ("N" + 3)); r.Value2 = operationDate.Month.ToString(); r = ws.get_Range(("O" + 3), ("O" + 3)); r.Value2 = operationDate.Day.ToString(); //double serviceFeeRate = Convert.ToDouble(dtOperation.Rows[0]["ServiceFeeRate"].ToString()); //double interestRate = Convert.ToDouble(dtOperation.Rows[0]["InterestFeeRate"].ToString()); //r = ws.get_Range(("D" + 11), ("D" + 11)); r.Value2 = serviceFeeRate.ToString(); //r = ws.get_Range(("D" + 12), ("D" + 12)); r.Value2 = interestRate.ToString(); DDUser newUser = new DDUser("AccountName", MainForm.AccountName); r = ws.get_Range(("K" + 21), ("K" + 21)); r.Value2 = newUser.UserName; //WdSaveFormat为Excel文档的保存格式 object format = MSExcel.XlFileFormat.xlWorkbookNormal; //将excelDoc文档对象的内容保存为dd文档 //excelDoc.Save(); //excelDoc.SaveAs(path, format, Nothing, Nothing, Nothing, Nothing, MSExcel.ddaveAsAccessMode.xlExclusive, Nothing, Nothing, Nothing, Nothing, Nothing); excelDoc.PrintOut(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing); 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("生成成功"); //PrintReceipt(); }
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("删除成功!", "删除"); }
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("生成成功"); }
public bool Destroy(object OperationID) { return(DDOperation.Destroy(OperationID) == 1); }
public bool Delete(object OperationID) { return(DDOperation.Delete(OperationID) == 1); }
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); } } } }