Пример #1
0
        public string CreateBalanceSheet(string repDate, string type, List <T_BalanceSheetTemplate> lstBanlance)
        {
            ExceResult res    = new ExceResult();
            string     result = "";

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            {
                string strReportID = Guid.NewGuid().ToString();
                string strRepNo    = "BS";
                string strStart    = string.Empty;
                string strEnd      = string.Empty;
                Common.Function.Common.GetReportDateAndRepNo(repDate, type, ref strRepNo, ref strStart, ref strEnd);

                result = new ReportSvc().CreateReportInfo(CompanyId(), repDate, type, strReportID, strRepNo + repDate);
                if (string.IsNullOrEmpty(result))
                {
                    T_ReportDetails report     = new T_ReportDetails();
                    DataTable       dtBanlance = Common.Function.Common.GetTableByEntity <T_ReportDetails>(report);
                    foreach (var item in lstBanlance)
                    {
                        //result = new ReportSvc().CreateReportDetailByBanlance(item, strReportID);
                        //if (!string.IsNullOrEmpty(result))
                        //{
                        //    break;
                        //}
                        addDataToTableByEntity(item, dtBanlance, strReportID);
                    }
                    result = new ReportSvc().CreateReportDetailByBanlance(dtBanlance, typeof(T_ReportDetails).Name);
                }
                if (string.IsNullOrEmpty(result))
                {
                    scope.Complete();
                }
            }
            //string result = new ReportSvc().UpdBalanceSheet(CompanyId(), repDate,type,lstBanlance);

            if (string.IsNullOrEmpty(result))
            {
                res.success = true;
            }
            else
            {
                res.success = false;
                res.msg     = result;
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(res));
        }
Пример #2
0
        /// <summary>
        /// 结账功能
        /// </summary>
        /// <param name="id"></param>
        /// <param name="repDate"></param>
        /// <param name="type"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public string UpdBalance(string id, string repDate, string type, string status)
        {
            ExceResult res    = new ExceResult();
            string     result = "";
            ReportSvc  svc    = new ReportSvc();

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            {
                if (status == "已结账")
                {
                    T_ReportDetails report     = new T_ReportDetails();
                    DataTable       dtBanlance = Common.Function.Common.GetTableByEntity <T_ReportDetails>(report);
                    List <T_BalanceSheetTemplate> lstBanlance = new List <T_BalanceSheetTemplate>();
                    lstBanlance = GetBanlance(id, repDate, type, "未结账", "");

                    //执行创建资产负债表操作
                    string strReportID = Guid.NewGuid().ToString();
                    string strRepNo    = "BS";
                    string strStart    = string.Empty;
                    string strEnd      = string.Empty;
                    Common.Function.Common.GetReportDateAndRepNo(repDate, type, ref strRepNo, ref strStart, ref strEnd);
                    if (string.IsNullOrEmpty(id))
                    {
                        result = new ReportSvc().CreateReportInfo(CompanyId(), repDate, type, strReportID, strRepNo + repDate);
                        id     = strReportID;
                    }
                    else
                    {
                        result = svc.DeleteReportDetail(id);
                    }

                    if (string.IsNullOrEmpty(result))
                    {
                        foreach (var item in lstBanlance)
                        {
                            addDataToTableByEntity(item, dtBanlance, id);
                        }

                        result = new ReportSvc().CreateReportDetailByBanlance(dtBanlance, typeof(T_ReportDetails).Name);
                    }

                    if (type == "month")
                    {
                        DateTime dtRep = DateTime.Parse(repDate + "/01");
                        //if (dtRep.Month == 6)
                        if (dtRep.Month == 12)
                        {
                            if (!svc.CreateHisBeginBalance(CompanyId(), dtRep.ToString("yyyy/MM/dd")))
                            {
                                result = "科目初始值更新失败!";
                            }
                        }
                    }
                }
                else
                {
                    if (type == "month")
                    {
                        DateTime dtRep = DateTime.Parse(repDate + "/01");
                        //if (dtRep.Month == 6)
                        if (dtRep.Month == 12)
                        {
                            if (!svc.UpdateHisToBeginBalance(CompanyId(), dtRep.ToString("yyyy/MM/dd")))
                            {
                                result = "科目初始值撤销失败!";
                            }
                        }
                    }
                }

                if (svc.settled(id, status))
                {
                    scope.Complete();
                }
                else
                {
                    result = "状态修改失败";
                }
            }
            //string result = new ReportSvc().UpdBalanceSheet(CompanyId(), repDate,type,lstBanlance);

            if (string.IsNullOrEmpty(result))
            {
                res.success = true;
            }
            else
            {
                res.success = false;
                res.msg     = result;
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(res));
        }