Exemplo n.º 1
0
        public JsonResult ExportProduct(string userId, string startDate, string endDate, string type)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                TB_USERS user = new TB_USERS();
                user = User_Service.GetById(Int32.Parse(userId));
                string fileName = "\\Export\\HD" + user.UserFullName + "_" + startDate + "_" + endDate + ".xls";
                string filePath = HttpContext.Server.MapPath("~" + fileName);
                string err      = "";
                if (type.Equals("STUDIES"))
                {
                    err = BillExport(filePath, userId, startDate, endDate, type);
                }
                else
                {
                    err = User_Service.ReportSalaryTeacher(userId, startDate, endDate);
                    if (err.Equals("00"))
                    {
                        err = "";
                    }
                }

                if (string.IsNullOrEmpty(err))
                {
                    Result.Code   = 0;
                    Result.Result = fileName;
                }
                else
                {
                    Result.Code   = 999;
                    Result.Result = err;
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                IOHelper.WriteLog(StartUpPath, IpAddress, "Ajax::ExportProduct :", Ex.Message, Ex.ToString());
            }
            return(Json(Result));
        }