//建立預算下載表格 public string exportExcel(ContractModels _constract) { //1.讀取費用表格檔案 InitializeWorkbook(expenseFile); if (null != _constract) { constract = _constract; lstSheetName.Add("費用表"); sheet = (XSSFSheet)hssfworkbook.GetSheet("費用表"); writeHead(); //寫入估驗明細資料 writeEstimateItem(); //寫入憑證明細資料 writeInvoiceData(); //寫入總計資料 writeSumData(); //4.另存新檔至專案所屬目錄 (增加Temp for zip 打包使用 string fileLocation = null; fileLocation = outputPath + "\\" + constract.project.PROJECT_ID + "\\" + constract.project.PROJECT_ID + "_" + constract.planEST.EST_FORM_ID + "_費用表.xlsx"; var file = new FileStream(fileLocation, FileMode.Create); log.Info("new file name =" + file.Name + ",path=" + file.Position); hssfworkbook.Write(file); file.Close(); return(fileLocation); } return(null); }
/// <summary> /// 取得估驗單資料 /// </summary> public ContractModels getEstimationOrder(string formId) { ContractModels c = new ContractModels(); //3.取得估驗單資料 c.planEST = getForm(formId); //1.取得專案資料 c.project = getProjectById(c.planEST.PROJECT_ID); //2.合約資料 PurchaseFormService s = new PurchaseFormService(); s.getInqueryForm(c.planEST.CONTRACT_ID); c.supContract = s.formInquiry; c.supContractItems = s.formInquiryItem; c.contractPaymentTerms = getPaymentTerm(c.planEST.CONTRACT_ID, formId);//付款條件 //4.取得估驗明細資料 c.EstimationItems = getItems(c.planEST.EST_FORM_ID); //5.取得供應商資料 c.supplier = getSupplierInfo(c.planEST.PAYEE); //5.1 取得憑證資料 c.EstimationInvoices = getEstimationInvoice(c.planEST.EST_FORM_ID); //6.取得代付支出 c.EstimationHoldPayments = getHoldPayment(formId); //7.取得代扣支出 c.Hold4DeductForm = getPaymentTransfer(formId); //8.取得任務清單 Flow4EstimationForm wkservice = new Flow4EstimationForm(); wkservice.getTask(formId); c.task = wkservice.task.task; return(c); }
//TODO 取得點工相關資料 for 估驗單 public ContractModels getContract4TempWork(string projectId, string rptStartId, string rtpEndId, string supplierId, string chargeId) { ContractModels c = new ContractModels(); PLAN_ESTIMATION_FORM form = new PLAN_ESTIMATION_FORM(); c.planEST = form; //1.取得專案資料 logger.Debug("get project by project_id=" + projectId); c.project = getProjectById(projectId); //2.取得合約資料?? 需要點工的單價資料 logger.Debug("get getContract4TempWork by project_id=" + projectId + "," + rptStartId + "," + rtpEndId); c.EstimationItems = getEstimationList4TempWorker(projectId, rptStartId, rtpEndId, supplierId, chargeId); //3.取得供應商資料 logger.Debug("get Supplier by SUPPLIER_ID=" + c.EstimationItems.First().SUPPLIER_ID); c.supplier = getSupplierInfo(supplierId.Substring(0, 8)); //4.補上代扣資料 List <PLAN_ESTIMATION_HOLDPAYMENT> holdPayment = new List <PLAN_ESTIMATION_HOLDPAYMENT>(); PLAN_ESTIMATION_HOLDPAYMENT p = new PLAN_ESTIMATION_HOLDPAYMENT(); p.SUPPLIER_ID = chargeId; //p.HOLD_AMOUNT = 0; p.REMARK = "點工"; holdPayment.Add(p); c.EstimationHoldPayments = holdPayment; return(c); }
public ContractModels getContract(string projectId, string contractid, string prid_s, string prid_e, string isWage) { ContractModels c = new ContractModels(); PLAN_ESTIMATION_FORM form = new PLAN_ESTIMATION_FORM(); c.planEST = form; //1.取得專案資料 logger.Debug("get project by project_id=" + projectId); c.project = getProjectById(projectId); //2.取得估驗明細資料 logger.Debug("get EstimationOrder4Expense by project_id=" + contractid + "," + prid_s + "," + prid_e); switch (isWage) { case "Y": c.EstimationItems = getEstimationListByDailyReport(projectId, DateTime.Parse(prid_s), DateTime.Parse(prid_e), isWage); break; case "N": c.EstimationItems = getEstimationListByDailyReport(projectId, DateTime.Parse(prid_s), DateTime.Parse(prid_e), isWage); break; default: c.EstimationItems = getEstimationOrder4Expense(projectId, contractid, prid_s, prid_e); break; } //3.取得供應商資料 logger.Debug("get Supplier by SUPPLIER_ID=" + c.EstimationItems.First().SUPPLIER_ID); c.supplier = getSupplierInfo(c.EstimationItems.First().SUPPLIER_ID); //4.取得代扣資料 logger.Debug("get Hold4DeductForm by SUPPLIER_ID=" + c.supplier.SUPPLIER_ID); c.Hold4DeductForm = getPaymentTransfer(projectId, c.supplier.SUPPLIER_ID); return(c); }
public void downLoadExpenseForm() { string formid = Request["formid"]; log.Debug("download Excel:" + formid); EstimationService service = new EstimationService(); ContractModels constract = service.getEstimationOrder(formid); if (null != constract) { PaymentExpenseFormToExcel poi = new PaymentExpenseFormToExcel(); //檔案位置 string fileLocation = poi.exportExcel(constract); //檔案名稱 HttpUtility.UrlEncode預設會以UTF8的編碼系統進行QP(Quoted-Printable)編碼,可以直接顯示的7 Bit字元(ASCII)就不用特別轉換。 string filename = HttpUtility.UrlEncode(Path.GetFileName(fileLocation)); Response.Clear(); Response.Charset = "utf-8"; Response.ContentType = "text/xls"; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", filename)); ///"\\" + form.PROJECT_ID + "\\" + ContextService.quotesFolder + "\\" + form.FORM_ID + ".xlsx" Response.WriteFile(fileLocation); Response.End(); } }
//依據合約內容計算:預付款 扣回、其他扣款尚未計算 private void caluateSumByContract(ContractModels contract) { //contract contractPaymentTerms PaymentTermsFunction payCond = contract.contractPaymentTerms; //RETENTION_PAYMENT = 0,--保留款(需另外計算) //OTHER_PAYMENT = 0, --其他扣款(需另外計算) //PREPAY_AMOUNT = 0, --預付款(需另外計算) //FOREIGN_PAYMENT = 0--外勞款(尚無資料) //PLAN_ESTIMATION_FORM contract.planEST //估驗請款 if (payCond.PAYMENT_TYPE == "P") { // if (contract.planEST.INDIRECT_COST_TYPE == "預付款") { logger.Info("process for prepay info :"); } else { //預付款攤還金額計算 if (payCond.PAYMENT_ADVANCE_RATIO != null && payCond.PAYMENT_ADVANCE_RATIO != 0) { //預付款 } } //保留款資訊 double retention_payment = 0;//保留款 } //階段付款 -- 先不時做 if (payCond.PAYMENT_TYPE == "S") { } }