/// <summary> /// 更新期初数 /// </summary> /// <param name="data"></param> /// <returns></returns> public string UpdBeginningBalance(string data) { string strFmt = "{{\"Result\":{0},\"Msg\":\"{1}\"}}"; string msg = string.Empty; List <T_BeginningBalance> beginningBalance = new JavaScriptSerializer().Deserialize <List <T_BeginningBalance> >(data); T_BeginningBalance currItem = new T_BeginningBalance(); while (beginningBalance.Any(i => i.children.Count > 0)) { currItem = beginningBalance.Where(i => i.children.Count > 0).FirstOrDefault(); beginningBalance.AddRange(currItem.children); currItem.children = new List <T_BeginningBalance>(); } bool result = false; if (true) { result = new ReportSvc().UpdBeginningBalance(beginningBalance, Session["CurrentCompanyGuid"].ToString()); msg = result ? General.Resource.Common.Success : General.Resource.Common.Failed; } else { msg = FMS.Resource.FinanceReport.FinanceReport.VaildError; } return(string.Format(strFmt, result.ToString().ToLower(), msg)); }
public bool InsInitialBalanceRecord(T_BeginningBalance balence) { DBHelper dh = new DBHelper(); dh.strCmd = "SP_InsInitialBalanceRecord"; dh.AddPare("@C_GUID", SqlDbType.NVarChar, 40, balence.C_GUID); dh.AddPare("@Money", SqlDbType.Decimal, 0, balence.Money); dh.AddPare("@InitialDate", SqlDbType.NVarChar, 40, balence.InitialDate); try { dh.NonQuery(); return(true); } catch { return(false); } }
public static List <T_Report <T> > GetReportDateList <T>(string companyId, string reportDate, string type) { DBHelper dh = new DBHelper(); dh = GetBeginingDate(companyId); T_BeginningBalance beginDate = dh.Reader <T_BeginningBalance>().FirstOrDefault(); Type typeClass = typeof(T); string strContent = string.Empty; switch (typeClass.Name) { case "T_BalanceSheetTemplate": strContent = "BS"; break; case "T_CashFlowItemTemplate": strContent = "CF"; break; case "T_IncomeStatementTemplate": strContent = "PL"; break; default: strContent = "BS"; break; } dh = GetReportDateList(companyId, strContent, reportDate, type); List <T_Report <T> > reps = dh.Reader <T_Report <T> >(); List <T_Report <T> > repsDetail = new List <T_Report <T> >(); DateTime dtNow = DateTime.Now; DateTime dtBeingin = new DateTime(); int length = 0; if (type == "month") { if (beginDate != null && beginDate.InitialDate != null) { dtBeingin = DateTime.Parse(beginDate.InitialDate); if (dtBeingin.Year == dtNow.Year) { length = dtNow.Month - dtBeingin.Month; } else { dtBeingin = DateTime.Parse(dtNow.ToString("yyyy") + "/01/01"); length = dtNow.Month - 1; } } else { length = dtNow.Month - 1; dtBeingin = DateTime.Parse(dtNow.ToString("yyyy") + "/01/01"); } for (int i = 0; i < length; i++) { T_Report <T> reportDetail = new T_Report <T>(); reportDetail.rep_date = dtBeingin.AddMonths(i).ToString("yyyy/M"); reportDetail.rep_status = "未结账"; reportDetail.Type = strContent; reportDetail.period_type = type; repsDetail.Add(reportDetail); } } if (type == "quarter") { if (beginDate != null && beginDate.InitialDate != null) { dtBeingin = DateTime.Parse(beginDate.InitialDate); dtBeingin = dtBeingin.AddMonths(0 - (dtBeingin.Month - 1) % 3).AddDays(1 - dtBeingin.Day); dtNow = dtNow.AddMonths(0 - (dtNow.Month - 1) % 3).AddDays(1 - dtNow.Day); if (dtBeingin.Year == dtNow.Year) { length = (dtNow.Month - dtBeingin.Month) / 3; } else { dtBeingin = DateTime.Parse(dtNow.ToString("yyyy") + "/01/01"); length = (dtNow.Month / 3); } } else { length = dtNow.Month; dtBeingin = DateTime.Parse(dtNow.ToString("yyyy") + "/01/01"); } for (int i = 0; i < length; i++) { T_Report <T> reportDetail = new T_Report <T>(); reportDetail.rep_date = dtBeingin.ToString("yyyy/") + (dtBeingin.AddMonths(i * 3).Month / 3 + 1); reportDetail.rep_status = "未结账"; reportDetail.Type = strContent; reportDetail.period_type = type; repsDetail.Add(reportDetail); } } if (type == "year") { if (beginDate != null && beginDate.InitialDate != null) { dtBeingin = DateTime.Parse(beginDate.InitialDate); if (dtBeingin.Year == dtNow.Year) { length = dtNow.Year - dtBeingin.Year; } else { length = dtNow.Year - dtBeingin.Year; length = length > 2 ? 2 : length; } } for (int i = length; i > 0; i--) { T_Report <T> reportDetail = new T_Report <T>(); reportDetail.rep_date = dtNow.AddYears(-i).ToString("yyyy"); reportDetail.rep_status = "未结账"; reportDetail.Type = strContent; reportDetail.period_type = type; repsDetail.Add(reportDetail); } } foreach (var item in repsDetail) { var query = reps.Where(p => p.rep_date == item.rep_date); if (!query.Any()) { reps.Add(item); } } return(reps.OrderByDescending(p => p.rep_date).ToList()); }