/// <summary> /// 功能:根据公积金申报基数由规则得到公积金申报缴存额 /// 日期:2013-03-25 /// </summary> /// <param name="gjjBase">公积申报基数</param> /// <returns>公积金申报缴存额</returns> /// 公积金缴存额计算规则:公积金基数乘以12%后四舍五入到整数,再乘以2,生成缴存额。计算的缴存额不允许超过上限,不能小于0 public static int GetGjjFeeByBase(decimal gjjBase) { decimal dRate = DecimalHelper.ToDecimal(WebConfigHelper.GetConfigurationApp("GjjFeeCalculator"));//0.12 decimal decRate = decimal.Parse(dRate.ToString()); decimal decData = gjjBase * decRate; int iR = Convert.ToInt32(MathRound(decData, 2)); return(iR * 2); }
public static ImportResultEntity GetExcelData(HttpPostedFileBase fileBase) { HttpPostedFile file = HttpContext.Current.Request.Files["Files"]; ImportResultEntity model = new ImportResultEntity(); string fileName = Path.GetFileName(file.FileName); int fileSize = file.ContentLength; //获取上传文件的大小单位为字节byte string fileEx = System.IO.Path.GetExtension(fileName); //获取上传文件的扩展名 string NoFileName = System.IO.Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名 int maxSize = 5000 * 1024; //定义上传文件的最大空间大小为5M if (!string.IsNullOrEmpty(WebConfigHelper.GetConfigurationApp("importFileMaxSize"))) { maxSize = Int32Helper.ToInt32(WebConfigHelper.GetConfigurationApp("importFileMaxSize")) * 1024 * 1000; } string FileType = ".xls,.xlsx";//定义上传文件的类型字符串 fileName = NoFileName + "_" + Guid.NewGuid().ToString().Replace("-", "") + fileEx; if (!FileType.Contains(fileEx)) { model.Status = 1; model.Message = "导入的文件必须是Excel文件。"; return(model); } if (fileSize > maxSize) { model.Status = 1; model.Message = "导入的文件Excel大小不能超过" + (maxSize / 1000 / 1024) + "MB."; return(model); } string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/EXCEL/" + DateTime.Now.ToString("yyyyMMdd"); if (!System.IO.File.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string savePath = Path.Combine(path, fileName); file.SaveAs(savePath); model.Status = 2; model.FileName = fileName; model.Message = "您的文件已上传成功。"; return(model); }