public ActionResult GetAllCustomerRevenueWeekly(DateTime startDate, DateTime endDate) { try { // Check autherization if (Session["User"] == null) { return RedirectToAction("Index", "Home"); } if (Session["UserRole"] != null && (int)Session["UserRole"] != 1) { return RedirectToAction("Index", "StoreInfor"); } ReportBusiness business = new ReportBusiness(); List<sp_GetAllCustomerRevenueWeekly_Result> result = business.GetAllCustomerRevenueWeekly(startDate, endDate); if (result.Count > 10) { ViewBag.Title = "Doanh thu theo khách hàng"; ViewBag.TreeView = "report"; ViewBag.TreeViewMenu = "customerRevenue"; return View(result); } else { return RedirectToAction("ReviewRevenueByProduct", "Report"); } } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult Top10ProductIncomeDetail(string query) { try { // Check autherization if (Session["User"] == null) { return RedirectToAction("Index", "Home"); } if ((int)Session["UserRole"] != 1) { return RedirectToAction("Index", "StoreInfor"); } if (!query.IsEmpty()) { ViewBag.Title = "Chi tiết lợi nhuận từ sản phẩm"; string[] tempStrings = query.Split(';'); int id = Convert.ToInt32(tempStrings[0].Trim()); if (tempStrings[1].Length == 23) { DateTime startDate = DateTime.ParseExact(tempStrings[1].Substring(0, 10), "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime endDate = DateTime.ParseExact(tempStrings[1].Substring(13, 10), "dd/MM/yyyy", CultureInfo.InvariantCulture); ReportBusiness business = new ReportBusiness(); ReportProductIncomeViewModel result = business.GetReportProductIncomeViewModel(id, startDate, endDate, null, null, null, null); ViewBag.Title = "Lợi nhuận theo sản phẩm"; ViewBag.TreeViewMenu = "incomeProduct"; ViewBag.TreeView = "report"; return View("Top10ProductIncomeWeeklyDetail", result); } else if (tempStrings[1].Length == 17) { DateTime startDate = DateTime.ParseExact(tempStrings[1].Substring(0, 7), "MM/yyyy", CultureInfo.InvariantCulture); DateTime endDate = DateTime.ParseExact(tempStrings[1].Substring(10, 7), "MM/yyyy", CultureInfo.InvariantCulture); ReportBusiness business = new ReportBusiness(); ReportProductIncomeViewModel result = business.GetReportProductIncomeViewModel(id, null, null, startDate.Month, startDate.Year, endDate.Month, endDate.Year); ViewBag.Title = "Lợi nhuận theo sản phẩm"; ViewBag.TreeViewMenu = "incomeProduct"; ViewBag.TreeView = "report"; return View("Top10ProductIncomeMonthlyDetail", result); } else if (tempStrings[1].Length == 11) { int startYear = Convert.ToInt32(tempStrings[1].Substring(0, 4)); int endYear = Convert.ToInt32(tempStrings[1].Substring(7, 4)); ReportBusiness business = new ReportBusiness(); ReportProductIncomeViewModel result = business.GetReportProductIncomeViewModel(id, null, null, null, startYear, null, endYear); ViewBag.Title = "Lợi nhuận theo sản phẩm"; ViewBag.TreeViewMenu = "incomeProduct"; ViewBag.TreeView = "report"; return View("Top10ProductIncomeYearlyDetail", result); } } return RedirectToAction("Index", "Home"); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult ReviewRevenuePerCustomerPartialView(string start, string end, int? type) { try { // Check autherization if (Session["User"] == null) { return null; } if (Session["UserRole"] != null && (int)Session["UserRole"] != 1) { return null; } ReportBusiness business = new ReportBusiness(); if (type == null) { type = 1; } if (type == 1) { DateTime startDate; DateTime endDate; if (start == null || end == null) { startDate = DateTime.Now.FirstDayOfWeek().AddDays(-21); endDate = DateTime.Now; } else { startDate = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture); endDate = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture); } List<sp_GetTop10CustomerRevenueWeekly_Result> result = business.GetTop10CustomerRevenueWeekly(startDate, endDate); return PartialView("Top10CustomerRevenueWeeklyPartialView", result); } else if (type == 2) { DateTime startDate = DateTime.ParseExact(start, "MM/yyyy", CultureInfo.InvariantCulture); DateTime endDate = DateTime.ParseExact(end, "MM/yyyy", CultureInfo.InvariantCulture); List<sp_GetTop10CustomerRevenueMonthly_Result> result = business.GetTop10CustomerRevenueMonthly(startDate, endDate); return PartialView("Top10CustomerRevenueMonthlyPartialView", result); } else if (type == 3) { DateTime startDate = DateTime.ParseExact(start, "yyyy", CultureInfo.InvariantCulture); DateTime endDate = DateTime.ParseExact(end, "yyyy", CultureInfo.InvariantCulture); List<sp_GetTop10CustomerRevenueYearly_Result> result = business.GetTop10CustomerRevenueYearly(startDate, endDate); return PartialView("Top10CustomerRevenueYearlyPartialView", result); } return null; } catch (Exception) { return null; } }
public ActionResult ReviewIncomeYearlyDetail(int year) { try { // Check autherization if (Session["User"] == null) { return RedirectToAction("Index", "Home"); } if ((int)Session["UserRole"] != 1) { return RedirectToAction("Index", "StoreInfor"); } ViewBag.Title = "Lợi nhuận năm " + year; ViewBag.TreeView = "report"; ViewBag.TreeViewMenu = "incomeReport"; ReportBusiness reportBusiness = new ReportBusiness(); ReportIncomeViewModel reportIncome = reportBusiness.ReviewIncomeYearlyDetail(year); return View(reportIncome); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult ReviewIncomeWeeklyDetail(DateTime startDate, DateTime endDate) { try { // Check autherization if (Session["User"] == null) { return RedirectToAction("Index", "Home"); } if ((int)Session["UserRole"] != 1) { return RedirectToAction("Index", "StoreInfor"); } ViewBag.Title = "Lợi nhuận từ " + startDate.ToString("dd/MM/yyyy") + " đến " + endDate.ToString("dd/MM/yyyy"); ViewBag.TreeView = "report"; ViewBag.TreeViewMenu = "incomeReport"; ReportBusiness reportBusiness = new ReportBusiness(); ReportIncomeViewModel reportIncome = reportBusiness.ReviewIncomeWeeklyDetail(startDate, endDate); return View(reportIncome); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult ReviewByTimePartialView(string start, string end, int? type) { try { if (Session["User"] == null) { return null; } if ((int)Session["UserRole"] != 1) { return null; } ReportBusiness business = new ReportBusiness(); if (type == null) { type = 1; } if (type == 1) { DateTime startDate; DateTime endDate; if (start == null || end == null) { startDate = DateTime.Now.FirstDayOfWeek().AddDays(-21); endDate = DateTime.Now.LastDayOfWeek(); } else { startDate = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture); endDate = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture); } List<sp_GetIncomeWeekly_Result> result = business.GetIncomeWeeklyStore(startDate, endDate); return PartialView("ReviewIncomeWeeklyPartialView", result); } if (type == 2) { DateTime startMonth = DateTime.ParseExact(start, "MM/yyyy", CultureInfo.InvariantCulture); DateTime endMonth = DateTime.ParseExact(end, "MM/yyyy", CultureInfo.InvariantCulture); List<sp_GetIncomeMonthly_Result> result = business.GetIncomeMonthlyStore(startMonth.Month, startMonth.Year, endMonth.Month, endMonth.Year); return PartialView("ReviewIncomeMonthlyPartialView", result); } if (type == 3) { int startYear = DateTime.ParseExact(start, "yyyy", CultureInfo.InvariantCulture).Year; int endYear = DateTime.ParseExact(end, "yyyy", CultureInfo.InvariantCulture).Year; List<sp_GetIncomeYearly_Result> result = business.GetIncomeYearlyStore(startYear, endYear); return PartialView("ReviewIncomeYearlyPartialView", result); } return null; } catch (Exception) { return null; } }
public ActionResult GetAllProductIncomeYearly(int startYear, int endYear) { try { // Check autherization if (Session["User"] == null) { return RedirectToAction("Index", "Home"); } if (Session["UserRole"] != null && (int)Session["UserRole"] != 1) { return RedirectToAction("Index", "StoreInfor"); } DateTime startDate = new DateTime(startYear, 1, 1); DateTime endDate = new DateTime(endYear, 1, 1); ReportBusiness business = new ReportBusiness(); List<sp_GetAllProductIncomeYearly_Result> result = business.GetAllProductIncomeYearly(startDate, endDate); if (result.Count > 10) { ViewBag.Title = "Lợi nhuận theo sản phẩm"; ViewBag.TreeViewMenu = "incomeProduct"; ViewBag.TreeView = "report"; return View(result); } else { return RedirectToAction("ReviewRevenueByProduct", "Report"); } } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public TndnTaxDeclaration GeTndnTaxDeclaration(int year) { TndnTaxDeclaration result = db.TndnTaxDeclarations.FirstOrDefault(m => m.Year == year); { if (result == null) { result = new TndnTaxDeclaration(); StoreInfo storeInfo = db.StoreInfoes.FirstOrDefault(); if (storeInfo != null) { result.StoreOwnerName = storeInfo.OwnerName; result.StoreTaxCode = storeInfo.TaxCode; result.StoreAddress = storeInfo.Address; result.StoreDistrict = storeInfo.District; result.StoreProvince = storeInfo.Province; result.StorePhone = storeInfo.Phonenumber; result.StoreFax = storeInfo.Fax; result.StoreEmail = storeInfo.Email; result.SignName = storeInfo.OwnerName; result.Year = year; } ReportBusiness business = new ReportBusiness(); List<sp_GetIncomeYearly_Result> incomeYearly = business.GetIncomeYearlyStore(year, year); var revenue = incomeYearly.ElementAt(0).Revenue; result.Value1 = revenue ?? 0; result.Value2 = 0; result.Value4 = 0; result.Value5 = 0; result.Value6 = 0; result.Value7 = 0; result.Value3 = result.Value4 + result.Value5 + result.Value6 + result.Value7; result.Value8 = 0; var materialExpense = incomeYearly.ElementAt(0).MaterialExpense; result.Value10 = materialExpense ?? 0; List<OtherExpense> value11List = db.OtherExpenses.Where(m => m.Type == 11 && m.OtherExpenseYearTime == year).ToList(); result.Value11 = 0; foreach (OtherExpense otherExpense in value11List) { result.Value11 += otherExpense.OtherExpenseAmount; } List<OtherExpense> value12List = db.OtherExpenses.Where(m => m.Type == 12 && m.OtherExpenseYearTime == year).ToList(); result.Value12 = 0; foreach (OtherExpense otherExpense in value12List) { result.Value12 += otherExpense.OtherExpenseAmount; } result.Value9 = result.Value10 + result.Value11 + result.Value12; result.Value13 = 0; result.Value14 = 0; result.Value15 = result.Value1 - result.Value3 + result.Value8 - result.Value9 - result.Value13; result.Value16 = 0; result.Value17 = 0; result.Value18 = result.Value16 - result.Value17; result.Value19 = result.Value15 + result.Value18; result.ValueA1 = result.Value19; result.ValueB1 = 0; result.ValueB2 = 0; result.ValueB3 = 0; result.ValueB4 = 0; result.ValueB5 = 0; result.ValueB6 = 0; result.ValueB7 = 0; result.ValueB8 = 0; result.ValueB9 = 0; result.ValueB10 = 0; result.ValueB11 = 0; result.ValueB12 = result.ValueA1; result.ValueB14 = 0; result.ValueB13 = result.ValueB12 - result.ValueB14; result.ValueC1 = result.ValueB13; result.ValueC2 = 0; result.ValueC3 = 0; result.ValueC3a = 0; result.ValueC3b = 0; result.ValueC4 = result.ValueC1; result.ValueC5 = 0; result.ValueC6 = result.ValueC4 - result.ValueC5; // Bug Hard code int tndnTaxRate = 0; TaxRate taxRate = db.TaxRates.FirstOrDefault(m => m.TaxRateId == 2); if (taxRate != null) { tndnTaxRate = taxRate.TaxRateValue; } if (tndnTaxRate == 22) { result.ValueC7 = result.ValueC4; } else { result.ValueC7 = 0; } if (tndnTaxRate == 20) { result.ValueC8 = result.ValueC4; } else { result.ValueC8 = 0; } if (tndnTaxRate != 22 && tndnTaxRate != 20) { result.ValueC9 = result.ValueC4; result.ValueC9a = tndnTaxRate; } else { result.ValueC9 = 0; result.ValueC9a = 0; } result.ValueC10 = (int)(result.ValueC7 / 5 + result.ValueC8 * 0.22 + result.ValueC9 * result.ValueC9a / 100); result.ValueC11 = 0; result.ValueC12 = 0; result.ValueC13 = 0; result.ValueC14 = 0; result.ValueC15 = 0; result.ValueC16 = result.ValueC10 - result.ValueC11 - result.ValueC12 - result.ValueC15; result.ValueD1 = result.ValueC16; result.ValueD2 = 0; result.ValueD3 = 0; result.ValueD = result.ValueD1 + result.ValueD2 + result.ValueD3; result.ValueE = 0; result.ValueE2 = 0; result.ValueE3 = 0; result.ValueE1 = 0; result.ValueG1 = result.ValueD1 - result.ValueE1; result.ValueG2 = result.ValueD2 - result.ValueE2; result.ValueG3 = result.ValueD3 - result.ValueE3; result.ValueG = result.ValueG1 + result.ValueG2 + result.ValueG3; result.ValueH = result.ValueD / 5; result.ValueI = result.ValueG - result.ValueH; result.ValueL1 = false; } } return result; }