void ModifyLeaseItem() { LeaseItems tLeaseItems = new LeaseItems(); tLeaseItems = BLL.LeaseBLL.GetLeaseItem(i_ItemsID); tLeaseItems.MName = textBoxMName.Text; if (radioButton1.Checked) { tLeaseItems.LeaseClass = 0; } else { tLeaseItems.LeaseClass = 1; } tLeaseItems.LeaseUnit = textBoxLeaseUnit.Text; tLeaseItems.LeasePrice = Convert.ToDecimal(textBoxLeasePrice.Text); tLeaseItems.LoadingUnit = textBoxLoadingUnit.Text; tLeaseItems.LoadingFactor = Convert.ToDecimal(textBoxLoadingFactor.Text); tLeaseItems.LoadingPrice = Convert.ToDecimal(textBoxLoadingPrice.Text); tLeaseItems.RepairUnit = textBoxRepairUnit.Text; tLeaseItems.RepairFactor = Convert.ToDecimal(textBoxRepairFactor.Text); tLeaseItems.RepairPrice = Convert.ToDecimal(textBoxRepairPrice.Text); BLL.LeaseBLL.ModifyLeaseItem(tLeaseItems); }
void FormLeaseRecord1Load(object sender, EventArgs e) { //填充租赁项 ds1 = BLL.LeaseBLL.GetLeaseItemsByHTID(i_HTID); comboBoxItemsName.DataSource = ds1.Tables[0]; comboBoxItemsName.ValueMember = "ItemsID"; comboBoxItemsName.DisplayMember = "MName"; if (this.Text == "租赁记录-新增") { } else { LeaseRecord tRI = BLL.LeaseBLL.GetLeaseRecord(i_RID); LeaseItems tI = BLL.LeaseBLL.GetLeaseItem(tRI.ItemsID); comboBoxItemsName.SelectedValue = tI.ItemsID; textBoxLeaseUnit.Text = tI.LeaseUnit; dateTimePickerLeaseDate.Value = tRI.LeaseDate; textBoxQuality.Text = tRI.Quality.ToString(); textBoxHandler.Text = tRI.Handler; textBoxAbstract.Text = tRI.Abstract; } bindingFlag = true; }
// 修改租赁项信息 public static void ModifyLeaseItem(LeaseItems tLeaseItem) { ISession session = NHibernateHelper.OpenSession(); try { ITransaction tx = session.BeginTransaction(); LeaseItems t1 = session.Get <LeaseItems>(tLeaseItem.ItemsID); t1.HTID = tLeaseItem.HTID; t1.MName = tLeaseItem.MName; t1.LeaseClass = tLeaseItem.LeaseClass; t1.LeaseUnit = tLeaseItem.LeaseUnit; t1.LeasePrice = tLeaseItem.LeasePrice; t1.LoadingUnit = tLeaseItem.LoadingUnit; t1.LoadingFactor = tLeaseItem.LoadingFactor; t1.LoadingPrice = tLeaseItem.LoadingPrice; t1.RepairUnit = tLeaseItem.RepairUnit; t1.RepairFactor = tLeaseItem.RepairFactor; t1.RepairPrice = tLeaseItem.RepairPrice; t1.BalanceDate = tLeaseItem.BalanceDate; t1.CurLeaseQuality = tLeaseItem.CurLeaseQuality; tx.Commit(); } catch (Exception e) { Debug.Assert(false, e.Message); } session.Close(); }
void FormLeaseItemLoad(object sender, EventArgs e) { textBoxItemsID.Text = i_ItemsID.ToString(); textBoxHTID.Text = i_HTID.ToString(); if (this.Text == "租赁项信息-修改") { LeaseItems tLeaseItem = BLL.LeaseBLL.GetLeaseItem(i_ItemsID); textBoxMName.Text = tLeaseItem.MName; if (tLeaseItem.LeaseClass == 0) { radioButton1.Checked = true; } else { radioButton2.Checked = true; } textBoxLeaseUnit.Text = tLeaseItem.LeaseUnit; textBoxLeasePrice.Text = tLeaseItem.LeasePrice.ToString(); textBoxLoadingUnit.Text = tLeaseItem.LoadingUnit; textBoxLoadingFactor.Text = tLeaseItem.LoadingFactor.ToString(); textBoxLoadingPrice.Text = tLeaseItem.LoadingPrice.ToString(); textBoxRepairUnit.Text = tLeaseItem.RepairUnit; textBoxRepairFactor.Text = tLeaseItem.RepairFactor.ToString(); textBoxRepairPrice.Text = tLeaseItem.RepairPrice.ToString(); } }
void ComboBoxItemsNameSelectedIndexChanged(object sender, EventArgs e) { if (bindingFlag && Convert.ToInt32(comboBoxItemsName.SelectedValue) > 0) { //选择了 LeaseItems tI = BLL.LeaseBLL.GetLeaseItem(Convert.ToInt32(comboBoxItemsName.SelectedValue)); textBoxLeaseUnit.Text = tI.LeaseUnit; } }
//获取指定的租赁项信息 public static LeaseItems GetLeaseItem(int i_ItemsID) { ISession session = NHibernateHelper.OpenSession(); LeaseItems tClass = new LeaseItems(); try { tClass = session.Get <LeaseItems>(i_ItemsID); } catch (Exception e) { Debug.Assert(false, e.Message); } session.Close(); return(tClass); }
//添加租赁项信息 public static void AddLeaseItem(LeaseItems tLeaseItem) { //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory(); ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { session.Save(tLeaseItem); tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
//删除 public static void DelLeaseItem(int i_LeaseItem) { //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory(); ISession session = NHibernateHelper.OpenSession(); ITransaction tx = session.BeginTransaction(); LeaseItems toDelete = session.Get <LeaseItems>(i_LeaseItem); try { session.Delete(toDelete); tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
//添加租赁结算 public static void AddNewLeaseJS(int i_ProjectID, int i_CompanyID, string s_BillCycle, DateTime d_SDate, DateTime d_EDate, ToolStripLabel labelStatus) { labelStatus.Text = "现在开始把数据添加到数据库中..."; Application.DoEvents(); string[,] ALeaseAccountLeft = new string[50, 2]; //用于保存当前剩余租赁材料 ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { int i_SNumber = 1; //租赁结算顺序号 //1.先添加租赁结算单,以得到BillID labelStatus.Text = "现在开始添加租赁结算单..."; Application.DoEvents(); Projects tProject = BLL.ProjectsBLL.GetProject(i_ProjectID); Companies tCompany = BLL.CompanyBLL.GetCompany(i_CompanyID); LeaseHT tLeaseHT = BLL.LeaseBLL.GetLeaseHT(i_ProjectID, i_CompanyID); int i_IncludeSDate = tLeaseHT.IncludeSDate; //租金包含开始日 int i_IncludeEDate = tLeaseHT.IncludeEDate; //租金包含结束日 string s_CalMethod = ""; //计算方式 if (i_IncludeSDate == 0 && i_IncludeEDate == 0) { s_CalMethod = "倒扣计算法,头尾都不算"; } if (i_IncludeSDate == 1 && i_IncludeEDate == 0) { s_CalMethod = "倒扣计算法,算头不算尾"; } if (i_IncludeSDate == 1 && i_IncludeEDate == 1) { s_CalMethod = "倒扣计算法,既算头又算尾"; } if (i_IncludeSDate == 0 && i_IncludeEDate == 1) { s_CalMethod = "倒扣计算法,算尾不算头"; } TimeSpan tTS = d_EDate.Subtract(d_SDate); int i_Days = tTS.Days + 1; //结余时租赁天数 LeaseAccount newLeaseAccount = new LeaseAccount(); newLeaseAccount.ProjectID = i_ProjectID; newLeaseAccount.CompanyID = i_CompanyID; newLeaseAccount.BillCycle = s_BillCycle; newLeaseAccount.SDate = d_SDate; newLeaseAccount.EDate = d_EDate; newLeaseAccount.CalMethod = s_CalMethod; newLeaseAccount.ProjectName = tProject.ProjectName; newLeaseAccount.CompanyName = tCompany.CompanyName; newLeaseAccount.IncludeSDate = i_IncludeSDate; newLeaseAccount.IncludeEDate = i_IncludeEDate; session.Save(newLeaseAccount); StatementList newStatementList = new StatementList(); newStatementList.ProjectID = i_ProjectID; newStatementList.ProjectName = tProject.ProjectName; newStatementList.CompanyID = i_CompanyID; newStatementList.CompanyName = tCompany.CompanyName; newStatementList.MoneyTypeID = 10000; newStatementList.MoneyTypeName = "租赁结算自动生成"; newStatementList.StatementType = "租赁结算"; newStatementList.StatementMemo = "应付租金"; newStatementList.StatementCycle = s_BillCycle; newStatementList.StatementDate = DateTime.Now.Date; session.Save(newStatementList); decimal d_BillAmt = 0.0m; //2.添加租赁明细单,并计算金额合计,以便完成后填写到LeaseAccount表记录中 //把保存剩余租赁量的数组数据填好,全部是字符串 DataSet dsTmp = BLL.LeaseBLL.GetLeaseAccountLeft(tLeaseHT.HTID); foreach (DataRow dr in dsTmp.Tables[0].Rows) { string s_0 = dr["ItemsID"].ToString(); string s_1 = dr["QualityLeft"].ToString(); for (int j = 0; j < ALeaseAccountLeft.GetLength(0); j++) { string s0 = ALeaseAccountLeft[j, 0]; string s1 = ALeaseAccountLeft[j, 1]; if (ALeaseAccountLeft[j, 0] == null) { ALeaseAccountLeft[j, 0] = s_0; ALeaseAccountLeft[j, 1] = s_1; break; } } } //2.1添加结余租赁明细项目 dsTmp = BLL.LeaseBLL.GetLeaseItemsByHTID(tLeaseHT.HTID); foreach (DataRow dr in dsTmp.Tables[0].Rows) { LeaseAccountList newLeaseAccountList = new LeaseAccountList(); int i_ItemsID = Convert.ToInt32(dr["ItemsID"]); LeaseItems tLeaseItem = BLL.LeaseBLL.GetLeaseItem(i_ItemsID); LeaseAccountLeft tLeaseAccountLeft = BLL.LeaseBLL.GetLeaseAccountLeft(tLeaseHT.HTID, i_ItemsID); if (tLeaseAccountLeft == null) { continue; } newLeaseAccountList.SNumber = i_SNumber; newLeaseAccountList.BillID = newLeaseAccount.BillID; newLeaseAccountList.ItemsID = tLeaseItem.ItemsID; newLeaseAccountList.ItemsName = tLeaseItem.MName; newLeaseAccountList.LeaseClass = 3; //将结余类重设 newLeaseAccountList.Abstract = tLeaseItem.MName + " 上期结余"; newLeaseAccountList.SDate = d_SDate; newLeaseAccountList.EDate = d_EDate; newLeaseAccountList.LeaseUnit = tLeaseItem.LeaseUnit; newLeaseAccountList.LeaseQuality = tLeaseAccountLeft.QualityLeft; newLeaseAccountList.LeasePrice = tLeaseItem.LeasePrice; newLeaseAccountList.LeaseDays = i_Days; newLeaseAccountList.LeaseAmt = newLeaseAccountList.LeaseQuality * newLeaseAccountList.LeasePrice * i_Days; d_BillAmt += newLeaseAccountList.LeaseAmt; session.Save(newLeaseAccountList); i_SNumber++; } //2.2按照未结算租赁记录添加租赁结算明细项 dsTmp = BLL.LeaseBLL.GetLeaseRecord2(i_ProjectID, i_CompanyID); //未结算的记录 foreach (DataRow dr in dsTmp.Tables[0].Rows) { //检查租赁日期是否在结算日期范围 int i_RID = Convert.ToInt32(dr["RID"]); LeaseRecord tLeaseRecord = session.Get <LeaseRecord>(i_RID); if (tLeaseRecord.LeaseDate >= d_SDate && tLeaseRecord.LeaseDate <= d_EDate) { LeaseAccountList newLeaseAccountList = new LeaseAccountList(); int i_ItemsID = tLeaseRecord.ItemsID; LeaseItems tLeaseItem = session.Get <LeaseItems>(i_ItemsID); newLeaseAccountList.SNumber = i_SNumber; newLeaseAccountList.BillID = newLeaseAccount.BillID; newLeaseAccountList.ItemsID = tLeaseItem.ItemsID; newLeaseAccountList.ItemsName = tLeaseItem.MName; newLeaseAccountList.LeaseClass = tLeaseItem.LeaseClass; if (tLeaseRecord.Abstract.ToString().Length != 0) { newLeaseAccountList.Abstract = tLeaseItem.MName + "(" + tLeaseRecord.Abstract + ")"; } else { newLeaseAccountList.Abstract = tLeaseItem.MName; } DateTime dt1 = tLeaseRecord.LeaseDate; newLeaseAccountList.SDate = dt1; newLeaseAccountList.EDate = d_EDate; TimeSpan tTS1 = d_EDate.Subtract(dt1); int tDays = tTS1.Days; if (tLeaseRecord.Quality > 0) { if (i_IncludeSDate == 1) { tDays++; } } else { if (i_IncludeEDate != 1) { tDays++; } } if (tLeaseItem.LeaseClass == 0) { //租赁项 newLeaseAccountList.LeaseUnit = tLeaseItem.LeaseUnit; newLeaseAccountList.LeaseQuality = tLeaseRecord.Quality; newLeaseAccountList.LeasePrice = tLeaseItem.LeasePrice; newLeaseAccountList.LeaseDays = tDays; newLeaseAccountList.LeaseAmt = newLeaseAccountList.LeaseQuality * newLeaseAccountList.LeasePrice * tDays; d_BillAmt += newLeaseAccountList.LeaseAmt; newLeaseAccountList.LoadingUnit = tLeaseItem.LoadingUnit; newLeaseAccountList.LoadingFactor = Convert.ToDecimal(tLeaseItem.LoadingFactor); newLeaseAccountList.LoadingQuality = Math.Abs(newLeaseAccountList.LeaseQuality / newLeaseAccountList.LoadingFactor); newLeaseAccountList.LoadingPrice = Convert.ToDecimal(tLeaseItem.LoadingPrice); newLeaseAccountList.LoadingAmt = Math.Abs(newLeaseAccountList.LoadingPrice * newLeaseAccountList.LoadingQuality); d_BillAmt += newLeaseAccountList.LoadingAmt; if (tLeaseRecord.Quality < 0) { newLeaseAccountList.RepairUnit = tLeaseItem.RepairUnit; newLeaseAccountList.RepairFactor = Convert.ToDecimal(tLeaseItem.RepairFactor); newLeaseAccountList.RepairQuality = Math.Abs(newLeaseAccountList.LeaseQuality / newLeaseAccountList.RepairFactor); newLeaseAccountList.RepairPrice = Convert.ToDecimal(tLeaseItem.RepairPrice); newLeaseAccountList.RepairAmt = Math.Abs(newLeaseAccountList.RepairPrice * newLeaseAccountList.RepairQuality); d_BillAmt += newLeaseAccountList.RepairAmt; } //检查此租赁项是否存在,存在则更新LeaseAccountLeft,否则添加 string s_0 = tLeaseItem.ItemsID.ToString(); string s_1 = newLeaseAccountList.LeaseQuality.ToString(); for (int j = 0; j < ALeaseAccountLeft.GetLength(0); j++) { if (ALeaseAccountLeft[j, 0] == null) { ALeaseAccountLeft[j, 0] = s_0; ALeaseAccountLeft[j, 1] = s_1; break; } else { if (ALeaseAccountLeft[j, 0] == s_0) { //找到了 decimal d1 = Convert.ToDecimal(s_1) + Convert.ToDecimal(ALeaseAccountLeft[j, 1]); ALeaseAccountLeft[j, 1] = d1.ToString(); break; } //继续找 } } } else { //单独结算项 newLeaseAccountList.LeaseUnit = tLeaseItem.LeaseUnit; newLeaseAccountList.OtherUnit = tLeaseItem.LeaseUnit; newLeaseAccountList.OtherQuality = tLeaseRecord.Quality; newLeaseAccountList.OtherPrice = tLeaseItem.LeasePrice; newLeaseAccountList.OtherAmt = newLeaseAccountList.OtherPrice * newLeaseAccountList.OtherQuality; d_BillAmt += newLeaseAccountList.OtherAmt; } tLeaseRecord.LeaseStatus = "已结算"; tLeaseRecord.BalanceDate = DateTime.Now.Date; session.Update(tLeaseRecord); session.Save(newLeaseAccountList); i_SNumber++; } } newLeaseAccount.BillAmt = Convert.ToDecimal(d_BillAmt); newStatementList.BillYF = Convert.ToDecimal(d_BillAmt); //把LeaseAccountLeft更新 for (int j = 0; j < ALeaseAccountLeft.GetLength(0); j++) { if (ALeaseAccountLeft[j, 0] != null) { int iItem = Convert.ToInt32(ALeaseAccountLeft[j, 0]); LeaseAccountLeft tLeaseAccountLeft = BLL.LeaseBLL.GetLeaseAccountLeft(tLeaseHT.HTID, iItem); if (tLeaseAccountLeft == null) { tLeaseAccountLeft = new LeaseAccountLeft(); tLeaseAccountLeft.HTID = tLeaseHT.HTID; tLeaseAccountLeft.ItemsID = iItem; tLeaseAccountLeft.QualityLeft = Convert.ToDecimal(ALeaseAccountLeft[j, 1]); tLeaseAccountLeft.LastBillCycle = newLeaseAccount.BillCycle; tLeaseAccountLeft.LastEDate = DateTime.Now.Date; session.Save(tLeaseAccountLeft); } else { tLeaseAccountLeft.QualityLeft = Convert.ToDecimal(ALeaseAccountLeft[j, 1]); tLeaseAccountLeft.LastBillCycle = newLeaseAccount.BillCycle; tLeaseAccountLeft.LastEDate = DateTime.Now.Date; session.Update(tLeaseAccountLeft); } } else { break; } } tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } labelStatus.Text = "就绪"; }
//填数据 void FillReportData(DataSet FDataSet) { int i_ProjectID = Convert.ToInt32(comboBoxProject.SelectedValue.ToString()); int i_CompanyID = Convert.ToInt32(comboBoxCompany.SelectedValue.ToString()); int i_SNumber = 1; //租赁结算顺序号 DateTime dSDate = dateTimePickerSDate.Value.Date; DateTime dEDate = dateTimePickerEDate.Value.Date; TimeSpan tTS = dEDate.Subtract(dSDate); int i_Days = tTS.Days + 1; //结余时租赁天数 LeaseHT tLeaseHT = BLL.LeaseBLL.GetLeaseHT(i_ProjectID, i_CompanyID); int i_IncludeSDate = tLeaseHT.IncludeSDate; //租金包含开始日 int i_IncludeEDate = tLeaseHT.IncludeEDate; //租金包含结束日 string s_BillCycle = textBoxBillCycle.Text; //结算周期 string s_CalMethod = ""; //计算方式 if (i_IncludeSDate == 0 && i_IncludeEDate == 0) { s_CalMethod = "倒扣计算法,头尾都不算"; } if (i_IncludeSDate == 1 && i_IncludeEDate == 0) { s_CalMethod = "倒扣计算法,算头不算尾"; } if (i_IncludeSDate == 1 && i_IncludeEDate == 1) { s_CalMethod = "倒扣计算法,既算头又算尾"; } if (i_IncludeSDate == 0 && i_IncludeEDate == 1) { s_CalMethod = "倒扣计算法,算尾不算头"; } List <ItemsLeftStru> RemainKeyValue = new List <ItemsLeftStru>(); // myKV.ItemdID = 1; // myKV.ItemsName = "asdd"; // myKV.ItemsValue = 12.80; // RemainKeyValue.Add(myKV); //1.填LeaseAccount表 DataRow dr = FDataSet.Tables["LeaseAccount"].NewRow(); dr["BillID"] = 10000; dr["ProjectID"] = i_ProjectID; dr["ProjectName"] = comboBoxProject.Text; dr["CompanyID"] = i_CompanyID; dr["CompanyName"] = comboBoxCompany.Text; dr["BillCycle"] = s_BillCycle; dr["CalMethod"] = s_CalMethod; FDataSet.Tables["LeaseAccount"].Rows.Add(dr); //2.填LeaseAccountList表 //2.1填结余租赁项 DataSet tds = BLL.LeaseBLL.GetLeaseAccountLeft(tLeaseHT.HTID); foreach (DataRow drtmp in tds.Tables[0].Rows) { dr = FDataSet.Tables["LeaseAccountList"].NewRow(); int i_ItemsID = Convert.ToInt32(drtmp["ItemsID"]); LeaseItems tLeaseItem = BLL.LeaseBLL.GetLeaseItem(i_ItemsID); dr["ListID"] = i_SNumber; dr["SNumber"] = i_SNumber; dr["BillID"] = 10000; dr["Abstract"] = tLeaseItem.MName + " 上期结余"; dr["SDate"] = dSDate; dr["EDate"] = dEDate; dr["LeaseUnit"] = tLeaseItem.LeaseUnit; dr["LeaseQuality"] = drtmp["QualityLeft"]; dr["LeasePrice"] = tLeaseItem.LeasePrice; dr["LeaseDays"] = i_Days; dr["LeaseAmt"] = Convert.ToDecimal(dr["LeaseQuality"]) * Convert.ToDecimal(dr["LeasePrice"]) * i_Days; FDataSet.Tables["LeaseAccountList"].Rows.Add(dr); ItemsLeftStru myKV = new ItemsLeftStru(); myKV.ItemdID = tLeaseItem.ItemsID; myKV.ItemsName = tLeaseItem.MName; myKV.ItemsUnit = tLeaseItem.LeaseUnit; myKV.ItemsValue = Convert.ToDouble(dr["LeaseQuality"]); AddKeyValue(ref RemainKeyValue, myKV); i_SNumber++; } //2.2按照时间顺序计算各项租金 tds = BLL.LeaseBLL.GetLeaseRecord2(i_ProjectID, i_CompanyID); //未结算的记录 foreach (DataRow drtmp in tds.Tables[0].Rows) { //检查租赁日期是否在结算日期范围 DateTime tLeaseDate = Convert.ToDateTime(drtmp["LeaseDate"]); if (tLeaseDate >= dSDate && tLeaseDate <= dEDate) { dr = FDataSet.Tables["LeaseAccountList"].NewRow(); int i_ItemsID = Convert.ToInt32(drtmp["ItemsID"]); LeaseItems tLeaseItem = BLL.LeaseBLL.GetLeaseItem(i_ItemsID); dr["ListID"] = i_SNumber; dr["SNumber"] = i_SNumber; dr["BillID"] = 10000; if (drtmp["Abstract"].ToString().Length != 0) { dr["Abstract"] = tLeaseItem.MName + "(" + drtmp["Abstract"] + ")"; } else { dr["Abstract"] = tLeaseItem.MName; } DateTime dt1 = Convert.ToDateTime(drtmp["LeaseDate"]); dr["SDate"] = dt1; dr["EDate"] = dEDate; TimeSpan tTS1 = dEDate.Subtract(dt1); int tDays = tTS1.Days; if (Convert.ToDecimal(drtmp["Quality"]) > 0) { if (i_IncludeSDate == 1) { tDays++; } } else { if (i_IncludeEDate != 1) { tDays++; } } if (tLeaseItem.LeaseClass == 0) { //租赁项 dr["LeaseUnit"] = tLeaseItem.LeaseUnit; dr["LeaseQuality"] = drtmp["Quality"]; dr["LeasePrice"] = tLeaseItem.LeasePrice; dr["LeaseDays"] = tDays; dr["LeaseAmt"] = Convert.ToDecimal(dr["LeaseQuality"]) * Convert.ToDecimal(dr["LeasePrice"]) * tDays; dr["LoadingUnit"] = tLeaseItem.LoadingUnit; dr["LoadingFactor"] = tLeaseItem.LoadingFactor; dr["LoadingQuality"] = Math.Abs(Convert.ToDecimal(dr["LeaseQuality"]) / Convert.ToDecimal(dr["LoadingFactor"])); dr["LoadingPrice"] = tLeaseItem.LoadingPrice; dr["LoadingAmt"] = Math.Abs(Convert.ToDecimal(dr["LoadingPrice"]) * Convert.ToDecimal(dr["LoadingQuality"])); if (Convert.ToDecimal(drtmp["Quality"]) < 0) { dr["RepairUnit"] = tLeaseItem.RepairUnit; dr["RepairFactor"] = tLeaseItem.RepairFactor; dr["RepairQuality"] = Math.Abs(Convert.ToDecimal(dr["LeaseQuality"]) / Convert.ToDecimal(dr["RepairFactor"])); dr["RepairPrice"] = tLeaseItem.RepairPrice; dr["RepairAmt"] = Math.Abs(Convert.ToDecimal(dr["RepairPrice"]) * Convert.ToDecimal(dr["RepairQuality"])); } ItemsLeftStru myKV = new ItemsLeftStru(); myKV.ItemdID = tLeaseItem.ItemsID; myKV.ItemsName = tLeaseItem.MName; myKV.ItemsUnit = tLeaseItem.LeaseUnit; myKV.ItemsValue = Convert.ToDouble(dr["LeaseQuality"]); AddKeyValue(ref RemainKeyValue, myKV); } else { //单独结算项 dr["LeaseUnit"] = tLeaseItem.LeaseUnit; dr["OtherUnit"] = tLeaseItem.LeaseUnit; dr["OtherQuality"] = drtmp["Quality"]; dr["OtherPrice"] = tLeaseItem.LeasePrice; dr["OtherAmt"] = Convert.ToDecimal(dr["OtherPrice"]) * Convert.ToDecimal(dr["OtherQuality"]); } FDataSet.Tables["LeaseAccountList"].Rows.Add(dr); i_SNumber++; } } //2.3将计算出来的余量数据填写好 foreach (ItemsLeftStru itemLS in RemainKeyValue) { dr = FDataSet.Tables["LeaseAccountLeft"].NewRow(); dr["ItemsID"] = itemLS.ItemdID; dr["MName"] = itemLS.ItemsName; dr["LeaseUnit"] = itemLS.ItemsUnit; dr["QualityLeft"] = itemLS.ItemsValue; FDataSet.Tables["LeaseAccountLeft"].Rows.Add(dr); } }