/// <summary> /// 修改币种期末汇率信息 /// </summary> /// <param name="ID">主键ID</param> /// <param name="EndRate">汇率</param> /// <returns>true 成功,false 失败</returns> public static bool UpdateEndRate(string ID, string EndRate) { bool result = false; try { //拆分主键ID string[] arrayID = ID.Split(','); //拆分期末利率 string[] arrayEndRate = EndRate.Split(','); if (arrayID.Length > 0 && arrayEndRate.Length > 0) { int j = 0; for (int i = 0; i < arrayID.Length; i++) { string _Id = arrayID[i].ToString(); decimal _Rate = Convert.ToDecimal(arrayEndRate[j]); result = CurrTypeSettingDBHelper.UpdateEndRate(_Id, _Rate); j++; } } return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 根据ID获取币种名称 /// </summary> /// <param name="ID"></param> /// <returns></returns> public static string GetCuerryTypeName(int ID) { try { return(CurrTypeSettingDBHelper.GetCuerryTypeName(ID)); } catch (Exception ex) { throw ex; } }
public static DataTable GetCurrencyRate(string ID) { try { return(CurrTypeSettingDBHelper.GetCurrencyRate(ID)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除币种信息操作 /// </summary> /// <param name="CompanyCD">公司编码</param> /// <param name="ID">主键标识ID</param> /// <returns>true 删除成功 : false 删除失败</returns> public static bool DeleteCurrTypeSetting(string CompanyCD, string ID) { bool isSucc = false; UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; if (string.IsNullOrEmpty(ID)) { return(false); } try { isSucc = CurrTypeSettingDBHelper.DeleteCurrTypeSetting(CompanyCD, ID); //定义变量 string remark; //成功时 if (isSucc) { //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_SUCCESS; } else { //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_FAILED; } string[] noList = ID.Split(','); for (int i = 0; i < noList.Length; i++) { //获取编号 string no = noList[i]; //替换两边的 ' no = no.Replace("'", string.Empty); //操作日志 LogInfoModel logModel = InitLogInfo(no); //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空 logModel.Element = ConstUtil.LOG_PROCESS_DELETE; //设置操作成功标识 logModel.Remark = remark; //登陆日志 LogDBHelper.InsertLog(logModel); } return(isSucc); } catch (Exception ex) { WriteSystemLog(userInfo, ex); throw ex; } }
/// <summary> /// 绑定币种 /// </summary> private void binddrpCurrencyType() { DataTable dt = CurrTypeSettingDBHelper.GetCurrenyType(); if (dt != null && dt.Rows.Count > 0) { drpCurrencyType.DataSource = dt; drpCurrencyType.DataTextField = "CurrencyName"; drpCurrencyType.DataValueField = "hhh"; drpCurrencyType.DataBind(); string aaa = drpCurrencyType.Value; CurrencyTypeID.Value = aaa.Split('_')[0]; txtRate.Text = aaa.Split('_')[1]; } }
/// <summary> /// 获取币种类别信息 /// </summary> /// <returns>DataTable</returns> public static DataTable GetUsedCurrTypeByCompanyCD() { string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; if (string.IsNullOrEmpty(CompanyCD)) { return(null); } try { return(CurrTypeSettingDBHelper.GetUsedCurrTypeByCompanyCD(CompanyCD)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判断币种名称或币种符是否重复 /// </summary> /// <param name="CurrencyName">币种名称</param> /// <param name="CurrencySymbol">币种符</param> /// <param name="ID">主键ID</param> /// <returns></returns> public static int IsSame(string CurrencyName, string CurrencySymbol, string ID) { string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; try { if (CompanyCD == null || CompanyCD == "") { return(-1); } else { return(CurrTypeSettingDBHelper.IsSame(CurrencyName, CurrencySymbol, CompanyCD, ID)); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 是否已存在本位币 /// </summary> /// <param name="CompanyCD">公司编码</param> /// <returns></returns> public static bool IsExitsMasterCurrency(string ID) { string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; try { if (CompanyCD == null || CompanyCD == "") { return(false); } else { return(CurrTypeSettingDBHelper.IsExitsMasterCurrency(CompanyCD, ID)); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新币种信息 /// </summary> /// <param name="Model"></param> /// <returns></returns> public static bool UpdateCurrTypeSetting(CurrencyTypeSettingModel Model) { UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; if (Model == null) { return(false); } if (Model.CompanyCD == null) { Model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; } try { bool succ = false; string loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID; LogInfoModel logModel = InitLogInfo(Model.ID.ToString()); logModel.Element = ConstUtil.LOG_PROCESS_UPDATE; succ = CurrTypeSettingDBHelper.UpdateCurrTypeSetting(Model); if (!succ) { logModel.Remark = ConstUtil.LOG_PROCESS_FAILED; } else { logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS; } LogDBHelper.InsertLog(logModel); return(succ); } catch (Exception ex) { WriteSystemLog(userInfo, ex); throw ex; } }
/// <summary> /// 获取本币的信息 /// </summary> /// <param name="CompanyCD">企业编码</param> /// <returns>DataTable</returns> public static DataTable GetMasterCurrency() { string CompanyCD = string.Empty; try { CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; } catch (Exception ext) { throw ext; } if (string.IsNullOrEmpty(CompanyCD)) { return(null); } try { return(CurrTypeSettingDBHelper.GetMasterCurrency(CompanyCD)); } catch (Exception ex) { throw ex; } }
public DataTable GetProfitProcessInfo(string DuringDate, string TypeID) { DataTable Profitdt = null; //定义利润表对象 #region 变量的定义 string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; //公司编码 string CurrentstartDate = string.Empty; //本期开始时间 string CurrentendDate = string.Empty; //本期结束时间 string BeforestartDate = string.Empty; //上期开始时间 string BeforeendDate = string.Empty; //上期结束时间 string CurrencyTypeID = string.Empty; //币种ID string DayEnd = string.Empty; //月末数 string _DayEnd = string.Empty; //月末数 decimal CurrBusinessProfit = 0; //本年营业利润 decimal BeforeBusinessProfit = 0; //上一年营业利润 #endregion try { if (TypeID == "0")//显示本年累计数、上年累计数 { //对输入的资料日期进行处理开始 int MothString = Convert.ToInt32(DuringDate.Split('-')[1].ToString()); int yearString = Convert.ToInt32(DuringDate.Split('-')[0].ToString()); int Year = Convert.ToInt32(DuringDate.Split('-')[0].ToString()); Year = Year - 1; if (MothString == 4 || MothString == 6 || MothString == 9 || MothString == 11) { DayEnd = "-30"; _DayEnd = "-30"; } else if (MothString == 2) { if (((yearString % 4 == 0 && yearString % 100 == 0)) || (yearString % 400 == 0)) { DayEnd = "-29"; } else { DayEnd = "-28"; } if (((Year % 4 == 0 && Year % 100 == 0)) || (Year % 400 == 0)) { _DayEnd = "-29"; } else { _DayEnd = "-28"; } } else { DayEnd = "-31"; _DayEnd = "-31"; } CurrentstartDate = yearString.ToString() + "-01-01"; CurrentendDate = DuringDate + DayEnd; BeforestartDate = Year.ToString() + "-01-01"; if (MothString.ToString().Length == 1) { BeforeendDate = Year.ToString() + "-" + "0" + MothString.ToString() + _DayEnd; } else { BeforeendDate = Year.ToString() + "-" + MothString.ToString() + _DayEnd; } //获取币种表币种ID DataTable Currencydt = CurrTypeSettingDBHelper.GetCurrTypeByCompanyCD(CompanyCD); if (Currencydt != null && Currencydt.Rows.Count > 0) { foreach (DataRow rows in Currencydt.Rows) { CurrencyTypeID += rows["ID"].ToString() + ","; } CurrencyTypeID = CurrencyTypeID.TrimEnd(new char[] { ',' });//所有币种ID集 } //获取公式项目信息 DataTable ForumlaItemDt = ProfitFormulaDBHelper.GetInstance().GetProfitFormulaInfo(); /* * Add by Moshenlin 去除统计期末处理损益结转生成的凭证登帐的账簿信息 */ string CurrNotIDS = VoucherDBHelper.GetProfitandLossAttestIDS(CurrentstartDate, CurrentendDate, CompanyCD); string BeforeNotIDS = VoucherDBHelper.GetProfitandLossAttestIDS(BeforestartDate, BeforeendDate, CompanyCD); string CQueryStr = string.Empty; string BQueryStr = string.Empty; if (CurrNotIDS.Trim().Length > 0) { CQueryStr = " and AttestBillID not in ( " + CurrNotIDS + " ) "; } if (BeforeNotIDS.Trim().Length > 0) { BQueryStr = " and AttestBillID not in ( " + BeforeNotIDS + " ) "; } //执行本期数SQL语句 string CurrSql = " VoucherDate>='" + CurrentstartDate + "' and VoucherDate<='" + CurrentendDate + "' and CompanyCD='" + CompanyCD + "' " + CQueryStr + " "; //执行上期数SQL语句 string BeforeSql = " VoucherDate>='" + BeforestartDate + "' and VoucherDate<='" + BeforeendDate + "' and CompanyCD='" + CompanyCD + "' " + BQueryStr + " "; if (ForumlaItemDt != null && ForumlaItemDt.Rows.Count > 0) { Profitdt = new DataTable();//构造利润表对象 Profitdt.Columns.Add("itemName"); Profitdt.Columns.Add("line"); Profitdt.Columns.Add("currMoney"); Profitdt.Columns.Add("agoMoney"); foreach (DataRow rows in ForumlaItemDt.Rows) { DataRow Newrows = Profitdt.NewRow(); Newrows["itemName"] = rows["Name"].ToString(); //项目名称 Newrows["line"] = rows["Line"].ToString(); //行号 if (Convert.ToInt32(rows["Line"]) != 10 && Convert.ToInt32(rows["Line"]) != 13 && Convert.ToInt32(rows["Line"]) != 15) { //获取本期数 Newrows["currMoney"] = Math.Round(GetAmount(Convert.ToInt32(rows["ID"]), CurrSql, rows["Line"].ToString(), CurrencyTypeID), 2).ToString("#,###0.#0"); //获取上期数 Newrows["agoMoney"] = Math.Round(GetAmount(Convert.ToInt32(rows["ID"]), BeforeSql, rows["Line"].ToString(), CurrencyTypeID), 2).ToString("#,###0.#0"); } //营业利润 if (Convert.ToInt32(rows["Line"]) == 10) { if (Profitdt != null && Profitdt.Rows.Count > 0) { for (int i = 0; i < Profitdt.Rows.Count; i++) { if (i == 0) { //获取当年营业利润 CurrBusinessProfit = Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //获取上一年营业利润 BeforeBusinessProfit = Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } else { if (i <= 6) { //减:当年营业成本 CurrBusinessProfit = CurrBusinessProfit - Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //减:上一年营业成本 BeforeBusinessProfit = BeforeBusinessProfit - Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } else { if (i == 7) { //加:当年 投资收益 CurrBusinessProfit = CurrBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //加:当年 投资收益 BeforeBusinessProfit = BeforeBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } if (i == 8) { //加: 投资收益 CurrBusinessProfit = CurrBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //加:上一年 投资收益 BeforeBusinessProfit = BeforeBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } } } } //当年本营业利润 Newrows["currMoney"] = Math.Round(CurrBusinessProfit, 2).ToString("#,###0.#0"); //上一年本营业利润 Newrows["agoMoney"] = Math.Round(BeforeBusinessProfit, 2).ToString("#,###0.#0"); } }//利润总额 else if (Convert.ToInt32(rows["Line"]) == 13) { if (Profitdt != null && Profitdt.Rows.Count > 0) { //当年利润总额 Newrows["currMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[9]["currMoney"]) + Convert.ToDecimal(Profitdt.Rows[10]["currMoney"]) - Convert.ToDecimal(Profitdt.Rows[11]["currMoney"]), 2).ToString("#,###0.#0"); //上一年利润总额 Newrows["agoMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[9]["agoMoney"]) + Convert.ToDecimal(Profitdt.Rows[10]["agoMoney"]) - Convert.ToDecimal(Profitdt.Rows[11]["agoMoney"]), 2).ToString("#,###0.#0"); } }//净利润 else if (Convert.ToInt32(rows["Line"]) == 15) { //当年净利润 Newrows["currMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[12]["currMoney"]) - Convert.ToDecimal(Profitdt.Rows[13]["currMoney"]), 2).ToString("#,###0.#0"); //上一年净利润 Newrows["agoMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[12]["agoMoney"]) - Convert.ToDecimal(Profitdt.Rows[13]["agoMoney"]), 2).ToString("#,###0.#0"); } Profitdt.Rows.Add(Newrows); } } } else if (TypeID == "1")//显示本期数、本年累计数 { //对输入的资料日期进行处理开始 int MothString = Convert.ToInt32(DuringDate.Split('-')[1].ToString()); int yearString = Convert.ToInt32(DuringDate.Split('-')[0].ToString()); if (MothString == 4 || MothString == 6 || MothString == 9 || MothString == 11) { DayEnd = "-30"; } else if (MothString == 2) { if (((yearString % 4 == 0 && yearString % 100 == 0)) || (yearString % 400 == 0)) { DayEnd = "-29"; } else { DayEnd = "-28"; } } else { DayEnd = "-31"; } if (MothString.ToString().Length == 1) { CurrentstartDate = yearString.ToString() + "-0" + MothString + "-01"; CurrentendDate = yearString.ToString() + "-0" + MothString + DayEnd; BeforeendDate = yearString.ToString() + "-0" + MothString + DayEnd; } else { CurrentstartDate = yearString.ToString() + MothString + "-01"; CurrentendDate = yearString.ToString() + MothString + DayEnd; BeforeendDate = yearString.ToString() + MothString + DayEnd; } BeforestartDate = yearString.ToString() + "-01-01"; //获取币种表币种ID DataTable Currencydt = CurrTypeSettingDBHelper.GetCurrTypeByCompanyCD(CompanyCD); if (Currencydt != null && Currencydt.Rows.Count > 0) { foreach (DataRow rows in Currencydt.Rows) { CurrencyTypeID += rows["ID"].ToString() + ","; } CurrencyTypeID = CurrencyTypeID.TrimEnd(new char[] { ',' });//所有币种ID集 } //获取公式项目信息 DataTable ForumlaItemDt = ProfitFormulaDBHelper.GetInstance().GetProfitFormulaInfo(); /* * Add by Moshenlin 去除统计期末处理损益结转生成的凭证登帐的账簿信息 */ string CurrNotIDS = VoucherDBHelper.GetProfitandLossAttestIDS(CurrentstartDate, CurrentendDate, CompanyCD); string BeforeNotIDS = VoucherDBHelper.GetProfitandLossAttestIDS(BeforestartDate, BeforeendDate, CompanyCD); string CQueryStr = string.Empty; string BQueryStr = string.Empty; if (CurrNotIDS.Trim().Length > 0) { CQueryStr = " and AttestBillID not in ( " + CurrNotIDS + " ) "; } if (BeforeNotIDS.Trim().Length > 0) { BQueryStr = " and AttestBillID not in ( " + BeforeNotIDS + " ) "; } //执行本期数SQL语句 string CurrSql = " VoucherDate>='" + CurrentstartDate + "' and VoucherDate<='" + CurrentendDate + "' and CompanyCD='" + CompanyCD + "' " + CQueryStr + " "; //执行本年累计数SQL语句 string BeforeSql = " VoucherDate>='" + BeforestartDate + "' and VoucherDate<='" + BeforeendDate + "' and CompanyCD='" + CompanyCD + "' " + BQueryStr + " "; if (ForumlaItemDt != null && ForumlaItemDt.Rows.Count > 0) { Profitdt = new DataTable();//构造利润表对象 Profitdt.Columns.Add("itemName"); Profitdt.Columns.Add("line"); Profitdt.Columns.Add("currMoney"); Profitdt.Columns.Add("agoMoney"); foreach (DataRow rows in ForumlaItemDt.Rows) { DataRow Newrows = Profitdt.NewRow(); Newrows["itemName"] = rows["Name"].ToString(); //项目名称 Newrows["line"] = rows["Line"].ToString(); //行号 if (Convert.ToInt32(rows["Line"]) != 10 && Convert.ToInt32(rows["Line"]) != 13 && Convert.ToInt32(rows["Line"]) != 15) { //获取本期数 Newrows["currMoney"] = Math.Round(GetAmount(Convert.ToInt32(rows["ID"]), CurrSql, rows["Line"].ToString(), CurrencyTypeID), 2).ToString("#,###0.#0"); //获取上期数 Newrows["agoMoney"] = Math.Round(GetAmount(Convert.ToInt32(rows["ID"]), BeforeSql, rows["Line"].ToString(), CurrencyTypeID), 2).ToString("#,###0.#0"); } //营业利润 if (Convert.ToInt32(rows["Line"]) == 10) { if (Profitdt != null && Profitdt.Rows.Count > 0) { for (int i = 0; i < Profitdt.Rows.Count; i++) { if (i == 0) { //获取当年营业利润 CurrBusinessProfit = Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //获取上一年营业利润 BeforeBusinessProfit = Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } else { if (i <= 6) { //减:当年营业成本 CurrBusinessProfit = CurrBusinessProfit - Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //减:上一年营业成本 BeforeBusinessProfit = BeforeBusinessProfit - Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } else { if (i == 7) { //加:当年 投资收益 CurrBusinessProfit = CurrBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //加:当年 投资收益 BeforeBusinessProfit = BeforeBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } if (i == 8) { //加: 投资收益 CurrBusinessProfit = CurrBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["currMoney"]); //加:上一年 投资收益 BeforeBusinessProfit = BeforeBusinessProfit + Convert.ToDecimal(Profitdt.Rows[i]["agoMoney"]); } } } } //当年本营业利润 Newrows["currMoney"] = Math.Round(CurrBusinessProfit, 2).ToString("#,###0.#0"); //上一年本营业利润 Newrows["agoMoney"] = Math.Round(BeforeBusinessProfit, 2).ToString("#,###0.#0"); } }//利润总额 else if (Convert.ToInt32(rows["Line"]) == 13) { if (Profitdt != null && Profitdt.Rows.Count > 0) { //当年利润总额 Newrows["currMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[9]["currMoney"]) + Convert.ToDecimal(Profitdt.Rows[10]["currMoney"]) - Convert.ToDecimal(Profitdt.Rows[11]["currMoney"]), 2).ToString("#,###0.#0"); //上一年利润总额 Newrows["agoMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[9]["agoMoney"]) + Convert.ToDecimal(Profitdt.Rows[10]["agoMoney"]) - Convert.ToDecimal(Profitdt.Rows[11]["agoMoney"]), 2).ToString("#,###0.#0"); } }//净利润 else if (Convert.ToInt32(rows["Line"]) == 15) { //当年净利润 Newrows["currMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[12]["currMoney"]) - Convert.ToDecimal(Profitdt.Rows[13]["currMoney"]), 2).ToString("#,###0.#0"); //上一年净利润 Newrows["agoMoney"] = Math.Round(Convert.ToDecimal(Profitdt.Rows[12]["agoMoney"]) - Convert.ToDecimal(Profitdt.Rows[13]["agoMoney"]), 2).ToString("#,###0.#0"); } Profitdt.Rows.Add(Newrows); } } } } catch (Exception ex) { throw ex; } return(Profitdt); }
public static bool CountFixAssetDepreciation(string ItemID, string PeriodNum, ref string getAttestNo, ref int AttestID) { //获取当前操作用户企业编码 bool result = false;//执行返回结果 try { int PeriodID = 0; string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; DataTable dt = FixAssetInfoDBHelper.GetAssetInfoByCompanyCD(CompanyCD, PeriodNum); if (dt != null && dt.Rows.Count > 0) { #region 固定资产计提折旧计算 //计算方法 string CountMethod = string.Empty; //预计使用年限 int EstimateUseYear; //预计净残值率 decimal EstiResiValue; //原值 decimal OriginalValue; //月折旧率 decimal MonthDeprRate; //期末净值 decimal EndNetValue; //本期净值 decimal CurrentNetValue; //本期减值准备 decimal CurrValueRe; //月折旧额 decimal MonthDeprPrice = 0; //累计月折旧额 decimal CountTotalDeprPrice = 0; ArrayList DeprDetailList = new ArrayList(); ArrayList DeprPeriodList = new ArrayList(); //计提前固定资产实体数组 ArrayList FixDeprAfterList = new ArrayList(); //定义固定资产计提明细实体 FixAssetDeprDetailModel DeprDetailmodel = null; //资产计提 FixAssetPeriodDeprModel DeprPeriodmodel = null; //资产计提前实体 FixAssetDeprAfterModel FixDeprAftermodel = null; foreach (DataRow rows in dt.Rows) { //读取期末净值 EndNetValue = Convert.ToDecimal(rows["EndNetValue"]); //读取计算方法 CountMethod = rows["CountMethod"].ToString(); //读取预计净残值率 EstiResiValue = Convert.ToDecimal(rows["EstiResiValue"]); //读取原价 OriginalValue = Convert.ToDecimal(rows["OriginalValue"]); //读取本期减值准备 CurrValueRe = Convert.ToDecimal(rows["CurrValueRe"]); //读取月折旧率 MonthDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]); //实例固定资产计提明细实体 DeprDetailmodel = new FixAssetDeprDetailModel(); #region 固定资产计提明细赋值 //给固定资产计提明细赋值 DeprDetailmodel.CompanyCD = CompanyCD; DeprDetailmodel.Creator = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID; //固定资产名称 DeprDetailmodel.FixName = rows["FixName"].ToString(); //固定资产编号 DeprDetailmodel.FixNo = rows["FixNo"].ToString(); //资产类别 DeprDetailmodel.FixType = Convert.ToInt32(rows["FixType"]); //资产数量 DeprDetailmodel.Number = Convert.ToInt32(rows["FixNumber"]); //资产原值 DeprDetailmodel.OriginalValue = Convert.ToDecimal(rows["OriginalValue"]); //使用日期 DeprDetailmodel.UsedDate = Convert.ToDateTime(rows["UseDate"]); //使用年限 DeprDetailmodel.UsedYears = Convert.ToDecimal(rows["UsedYear"]); //预计使用年限 DeprDetailmodel.EstimateUse = Convert.ToDecimal(rows["EstimateUse"]); //计算预计净残值 decimal Yjcz = OriginalValue * (EstiResiValue / 100); #endregion //判断期末净值大于计净残值则进行折旧处理 if (EndNetValue > Yjcz) { //年限平均法 if (CountMethod == ConstUtil.ASSETCOUNT_METHOD_NXPJF_CODE) { //读取期初减值准备 decimal ReduValueRe = Convert.ToDecimal(rows["ReduValueRe"]); //读取预计使用年限 EstimateUseYear = Convert.ToInt32(rows["EstimateUse"]); //MonthDeprPrice = Math.Round(MonthDeprRate * OriginalValue, 2);//计算月折旧额 //读取月折旧额 MonthDeprPrice = Convert.ToDecimal(rows["AmorDeprM"]); //计算本期期末净值 CurrentNetValue = EndNetValue - MonthDeprPrice - CurrValueRe; //本期期末净值 DeprDetailmodel.EndNetValue = CurrentNetValue; //月折旧额 DeprDetailmodel.MDeprPrice = MonthDeprPrice; //计算累计折旧额 CountTotalDeprPrice = Convert.ToDecimal(rows["TotalDeprPrice"]) + MonthDeprPrice; DeprDetailmodel.TotalDeprPrice = CountTotalDeprPrice; //累计减值 DeprDetailmodel.TotalImpairment = (ReduValueRe + CurrValueRe); //计算月折旧额 //如果本期净值大于净残值则更新 if (CurrentNetValue > Yjcz) { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Math.Round(CurrentNetValue, 2); DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = 0; DeprPeriodmodel.AmorDeprM = MonthDeprPrice; DeprPeriodmodel.TotalDeprPrice = CountTotalDeprPrice; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } else { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]); FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Yjcz; DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = 0; DeprPeriodmodel.AmorDeprM = MonthDeprPrice; DeprPeriodmodel.TotalDeprPrice = Convert.ToDecimal(rows["EndNetValue"]) - Yjcz; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } } //工作量法 else if (CountMethod == ConstUtil.ASSETCOUNT_METHOD_GZLF_CODE) { //读取月折旧额 MonthDeprPrice = Convert.ToDecimal(rows["AmorDeprM"]); //计算本期期末净值 CurrentNetValue = EndNetValue - MonthDeprPrice - CurrValueRe; //计算累计折旧额 CountTotalDeprPrice = Convert.ToDecimal(rows["TotalDeprPrice"]) + MonthDeprPrice; //如果本期净值大于原净值则不更新 if (CurrentNetValue > Yjcz) { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Math.Round(CurrentNetValue, 2); DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = 0; DeprPeriodmodel.AmorDeprM = MonthDeprPrice; DeprPeriodmodel.TotalDeprPrice = CountTotalDeprPrice; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } else { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Yjcz; DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = 0; DeprPeriodmodel.AmorDeprM = MonthDeprPrice; DeprPeriodmodel.TotalDeprPrice = Convert.ToDecimal(rows["EndNetValue"]) - Yjcz; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } }//年限总和法 else if (CountMethod == ConstUtil.ASSETCOUNT_METHOD_NXZHF_CODE) { //年折旧率 decimal YearDeprRate = 0; //读取预计使用年限 EstimateUseYear = Convert.ToInt32(rows["EstimateUse"]); //读取已使用年限 int UsedYears = Convert.ToInt32(rows["UsedYear"]); //计算年折旧率 YearDeprRate = Convert.ToDecimal((EstimateUseYear - UsedYears)) / (Convert.ToDecimal(EstimateUseYear) * (Convert.ToDecimal(EstimateUseYear + 1)) / 2) * (100 / 100); //计算月折旧率 MonthDeprRate = YearDeprRate / 12; //计算月折旧额 MonthDeprPrice = (OriginalValue - (OriginalValue * (EstiResiValue / 100))) * MonthDeprRate; //计算本期期末净值 CurrentNetValue = EndNetValue - MonthDeprPrice - CurrValueRe; //计算累计折旧额 CountTotalDeprPrice = Convert.ToDecimal(rows["TotalDeprPrice"]) + MonthDeprPrice; if (CurrentNetValue > Yjcz) { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Math.Round(CurrentNetValue, 2); DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = Math.Round(MonthDeprRate, 8); DeprPeriodmodel.AmorDeprM = Math.Round(MonthDeprPrice, 2); DeprPeriodmodel.TotalDeprPrice = CountTotalDeprPrice; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } else { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Yjcz; DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = Math.Round(MonthDeprRate, 8); DeprPeriodmodel.AmorDeprM = MonthDeprPrice; DeprPeriodmodel.TotalDeprPrice = Convert.ToDecimal(rows["EndNetValue"]) - Yjcz; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } }//双倍余额递减法 else if (CountMethod == ConstUtil.ASSETCOUNT_METHOD_SBYETJS_CODE) { //读取预计使用年限 EstimateUseYear = Convert.ToInt32(rows["EstimateUse"]); //年折旧率 decimal YearDeprRate = 0; //计算年折旧率 YearDeprRate = 2 / Convert.ToDecimal(EstimateUseYear) * (100 / 100); //计算月折旧率 MonthDeprRate = YearDeprRate / 12; //计算月折旧额 MonthDeprPrice = EndNetValue * MonthDeprRate; //计算本期期末净值 CurrentNetValue = EndNetValue - MonthDeprPrice - CurrValueRe; //计算累计折旧额 CountTotalDeprPrice = Convert.ToDecimal(rows["TotalDeprPrice"]) + MonthDeprPrice; if (CurrentNetValue > Yjcz) { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Math.Round(CurrentNetValue, 2); DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = Math.Round(MonthDeprRate, 8); DeprPeriodmodel.AmorDeprM = Math.Round(MonthDeprPrice, 2); DeprPeriodmodel.TotalDeprPrice = CountTotalDeprPrice; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } else { #region 添加固定资产折旧前信息实体 FixDeprAftermodel = new FixAssetDeprAfterModel(); FixDeprAftermodel.AmorDeprM = rows["AmorDeprM"] != DBNull.Value ? Convert.ToDecimal(rows["AmorDeprM"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.AmorDeprRate = Convert.ToDecimal(rows["AmorDeprRate"]);; FixDeprAftermodel.CompanyCD = CompanyCD; FixDeprAftermodel.EndNetValue = rows["EndNetValue"] != DBNull.Value ? Convert.ToDecimal(rows["EndNetValue"]) : Convert.ToDecimal(DBNull.Value); FixDeprAftermodel.FixNo = rows["FixNo"].ToString(); FixDeprAftermodel.PeriodNum = Convert.ToInt32(PeriodNum); FixDeprAftermodel.TotalDeprPrice = rows["TotalDeprPrice"] != DBNull.Value ? Convert.ToDecimal(rows["TotalDeprPrice"]) : Convert.ToDecimal(DBNull.Value); FixDeprAfterList.Add(FixDeprAftermodel); #endregion DeprPeriodmodel = new FixAssetPeriodDeprModel(); DeprPeriodmodel.CompanyCD = CompanyCD; DeprPeriodmodel.EndNetValue = Yjcz; DeprPeriodmodel.FixNo = rows["FixNo"].ToString(); DeprPeriodmodel.AmorDeprRate = Math.Round(MonthDeprRate, 8); DeprPeriodmodel.AmorDeprM = MonthDeprPrice; DeprPeriodmodel.TotalDeprPrice = Convert.ToDecimal(rows["EndNetValue"]) - Yjcz; DeprDetailList.Add(DeprDetailmodel); DeprPeriodList.Add(DeprPeriodmodel); } } } } #endregion //折旧固定资产明细 result = FixAssetInfoDBHelper.UpdateEndFixAssetInfo(DeprDetailList, DeprPeriodList, CompanyCD, PeriodNum, ItemID, ref PeriodID, FixDeprAfterList); } if (result) { #region 凭证单据明细实体 //凭证单据实体 AttestBillModel Attestmodel = new AttestBillModel(); //凭证明细实体定义 AttestBillDetailsModel Detailmodel = null; #endregion #region 凭证单据实体赋值 Attestmodel.CompanyCD = CompanyCD; Attestmodel.AttestNo = "记-" + VoucherDBHelper.GetMaxAttestNo(CompanyCD, DateTime.Now.ToString()); getAttestNo = Attestmodel.AttestNo; Attestmodel.AttestName = "记账凭证"; Attestmodel.Creator = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID; Attestmodel.status = 0; Attestmodel.FromTbale = "EndItemProcessedRecord,FixWithInfo,FixPeriodDeprDetails"; Attestmodel.FromValue = PeriodID.ToString() + "," + PeriodNum.ToString(); Attestmodel.VoucherDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); #endregion int ID; ArrayList modelList = new ArrayList();//定义数组存储实体对象 //添加凭证单据信息 result = FixAssetInfoDBHelper.BuildDepreAttestBill(Attestmodel, out ID, ItemID, PeriodNum); AttestID = ID; if (result && ID > 0) { //获取固定资产科目汇总金额信息 DataTable AttestDetail = FixAssetInfoDBHelper.GetBuildAttestInfo(CompanyCD); //获取折旧凭证摘要ID string AbstractID; AbstractID = ConstUtil.SUMMARY_ZCJZ_NAME; #endregion //获取本币币种ID int MasterCurrencyID = Convert.ToInt32(CurrTypeSettingDBHelper.GetMasterCurrency(CompanyCD).Rows[0]["ID"]); if (AttestDetail != null && AttestDetail.Rows.Count > 0) { foreach (DataRow drows in AttestDetail.Rows) { #region 凭证明细实体赋值 Detailmodel = new AttestBillDetailsModel(); Detailmodel.AttestBillID = ID; Detailmodel.Abstract = AbstractID; // 摘要 Detailmodel.SubjectsCD = drows["AccuDeprSubjeCD"].ToString(); //累计折旧科目 贷 Detailmodel.CreditAmount = Convert.ToDecimal(drows["CountSum"]); //贷方金额 Detailmodel.DebitAmount = 0; Detailmodel.OriginalAmount = Convert.ToDecimal(drows["CountSum"]); //外币金额 Detailmodel.CurrencyTypeID = MasterCurrencyID; //本币ID Detailmodel.ExchangeRate = 1; //本币汇率 modelList.Add(Detailmodel); Detailmodel = new AttestBillDetailsModel(); Detailmodel.AttestBillID = ID; Detailmodel.Abstract = AbstractID; // 摘要 Detailmodel.CreditAmount = 0; Detailmodel.SubjectsCD = drows["DeprCostSubjeCD"].ToString(); //折旧费用科目 借 Detailmodel.DebitAmount = Convert.ToDecimal(drows["CountSum"]); //借方金额 Detailmodel.OriginalAmount = Convert.ToDecimal(drows["CountSum"]); //外币金额 Detailmodel.CurrencyTypeID = MasterCurrencyID; //本币ID Detailmodel.ExchangeRate = 1; //本币汇率 modelList.Add(Detailmodel); #endregion } //凭证自动登帐及自动审核 result = FixAssetInfoDBHelper.BuildDepreDetailInfo(modelList); if (result) { VoucherBus.SetStatus(ID.ToString(), "1", "status", 0); VoucherBus.InsertAccount(AttestID); } } } } return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 绑定门店退货币种 /// </summary> /// <returns>DataTable</returns> public static DataTable GetCurrenyType() { DataTable dt = CurrTypeSettingDBHelper.GetCurrenyType(); return(dt); }