public void btnAddOrUpdateDetailClick(object sender, EventArgs e) { bool IsNew = false; IndirectCostDetail oDetail = null; if (string.IsNullOrEmpty(hdDetailID.Value)) { oDetail = NewDetail(); oDetail.Master = CurMaster; CurMaster.Details.Add(oDetail); oDetail.Id = Guid.NewGuid().ToString(); IsNew = true; oDetail.CostType = GetEnumCostType(); oDetail.AccountSymbol = EnumAccountSymbol.其他; switch (oDetail.CostType) { case EnumCostType.管理费用: { this.gvManageCostSource.NewBillList.Add(oDetail); break; } //case EnumCostType.其他应付: { this.gvOtherPayoutSource.NewBillList.Add(oDetail); break; } //case EnumCostType.其他应收: { this.gvOtherReceiveSource.NewBillList.Add(oDetail); break; } } } else { oDetail = CurMaster.Details.OfType <IndirectCostDetail>().FirstOrDefault(item => item.Id == hdDetailID.Value); } if (!string.IsNullOrEmpty(hdAccountTitleID.Value) && (IsNew || oDetail.AccountTitle == null || (oDetail.AccountTitle != null && oDetail.AccountTitle.Id != hdAccountTitleID.Value))) { oDetail.AccountTitle = GetAccountTitleTree(hdAccountTitleID.Value);//需要查询 oDetail.AccountTitleCode = oDetail.AccountTitle == null ? "" : oDetail.AccountTitle.Code; oDetail.AccountTitleID = oDetail.AccountTitle == null ? "" : oDetail.AccountTitle.Id; oDetail.AccountTitleName = oDetail.AccountTitle == null ? "" : oDetail.AccountTitle.Name; } if (!string.IsNullOrEmpty(this.hdOrgID.Value) && (IsNew || oDetail.OrgInfo == null || (oDetail.OrgInfo != null && oDetail.OrgInfo.Id != hdOrgID.Value))) { oDetail.OrgInfo = GetOperationOrgInfo(this.hdOrgID.Value); oDetail.OrgInfoID = oDetail.OrgInfo == null ? "" : oDetail.OrgInfo.Id; oDetail.OrgInfoName = oDetail.OrgInfo == null ? "" : oDetail.OrgInfo.Name; oDetail.OrgInfoSysCode = oDetail.OrgInfo == null ? "" : oDetail.OrgInfo.SysCode; } oDetail.PartnerType = selPartnerType.SelectedValue; oDetail.Descript = txtDescript.Text; oDetail.Money = UtilClass.ToDecimal(txtMoney.Text); oDetail.BudgetMoney = UtilClass.ToDecimal(this.txtBudgetMoney.Text); ModelToView(); }
private void OpenExcel(string strFileName) { //IList<IndirectCostDetail> lstDetail = null; try { string sFlag = string.Empty; string sAccountTitleCode = string.Empty; string sOrgName = string.Empty; string sMoney = string.Empty; double dMoney = 0; IRow oRow = null; IList lstAccount = GlobalClass.AccountTitleTreeSvr.GetAccountTitleTreeByInstance(); using (ExcelHelper oExcelHelper = new ExcelHelper(strFileName)) { ISheet oSheet = oExcelHelper.GetSheet(""); //lstDetail = new List<IndirectCostDetail>(); IndirectCostDetail oDetail = null; for (int iStartRow = 10; iStartRow <= oSheet.LastRowNum; iStartRow++) { oRow = oSheet.GetRow(iStartRow); sFlag = oRow.GetCell(0).StringCellValue.Trim(); if (string.IsNullOrEmpty(sFlag)) { oDetail = new IndirectCostDetail(); oDetail.Master = CurMaster; oDetail.Id = Guid.NewGuid().ToString(); oDetail.CostType = EnumCostType.管理费用; oDetail.AccountSymbol = EnumAccountSymbol.其他; sAccountTitleCode = oRow.GetCell(1).StringCellValue; if (!string.IsNullOrEmpty(sAccountTitleCode) && sAccountTitleCode.IndexOf('\\') > 0) { sAccountTitleCode = sAccountTitleCode.Substring(0, sAccountTitleCode.IndexOf("\\")); oDetail.AccountTitle = GetAccountTitleTree(lstAccount, sAccountTitleCode); if (oDetail.AccountTitle != null) { oDetail.AccountTitleCode = oDetail.AccountTitle.Code; oDetail.AccountTitleID = oDetail.AccountTitle.Id; oDetail.AccountTitleName = oDetail.AccountTitle.Name; oDetail.AccountTitleSyscode = oDetail.AccountTitle.SysCode; } } else { sAccountTitleCode = string.Empty; } sOrgName = oRow.GetCell(3).StringCellValue.Trim(); dMoney = oRow.GetCell(6).NumericCellValue; oDetail.AccountTitleCode = sAccountTitleCode; oDetail.OrgInfoName = sOrgName; oDetail.Money = (decimal)dMoney; // lstDetail.Add(oDetail); CurMaster.Details.Add(oDetail); this.gvManageCostSource.NewBillList.Add(oDetail); } else { break; } } } } catch { } //return lstDetail; }
/// <summary> /// 新建明细 /// </summary> /// <returns></returns> public IndirectCostDetail NewDetail() { IndirectCostDetail oDetail = new IndirectCostDetail(); return(oDetail); }