public void LoadData() { var cate = CategoryController.API_GetAllCategory(); ltrList.Text = ""; double totalCost = 0; int totalProduct = 0; if (cate.Count > 0) { foreach (var item in cate) { ltrList.Text += "<tr>"; int quantity = 0; double totalprice = 0; var list = ProductController.GetProductReport(item.ID); { foreach (var temp in list) { quantity += Convert.ToInt32(temp.TotalProductInstockQuantityLeft); totalprice += temp.CostOfGood * temp.TotalProductInstockQuantityLeft; } } totalProduct += quantity; totalCost += totalprice; ltrList.Text += "<td>" + item.CategoryName + ": " + quantity + " cái" + "</td>"; ltrList.Text += "<td>Tổng vốn: " + item.CategoryName + ": " + string.Format("{0:N0}", totalprice) + " VNĐ" + "</td>"; ltrList.Text += "</tr>"; } } ltrTotalCost.Text = "<p>Tổng vốn: " + string.Format("{0:N0}", totalCost) + " VNĐ</p>"; ltrTotalProduct.Text = "<p>Tổng số lượng: " + string.Format("{0:N0}", totalProduct) + " cái</p>"; }
public void GetAllCategory(string username, string password) { var rs = new ResponseClass(); if (Login(username, password)) { var category = CategoryController.API_GetAllCategory(); if (category.Count > 0) { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS); rs.Status = APIUtils.ResponseMessage.Success.ToString(); rs.Category = category; } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound); rs.Status = APIUtils.ResponseMessage.Error.ToString(); rs.Message = APIUtils.OBJ_DNTEXIST; } } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.FAILED); rs.Status = APIUtils.ResponseMessage.Fail.ToString(); } Context.Response.ContentType = "application/json"; Context.Response.Write(JsonConvert.SerializeObject(rs, Formatting.Indented)); Context.Response.Flush(); Context.Response.End(); }