public string loadBill(string branchType, string branchId, string fromdate, string todate) { string result = ""; int i = 1; string fDate = "", tDate = ""; if (fromdate.Trim() != "") { fDate = cl.returnDatetime(fromdate.Trim()); } if (todate.Trim() != "") { tDate = cl.returnDatetime(todate.Trim()); } if (fDate == "" || tDate == "") { fDate = ""; tDate = ""; } //var m = db.sp_web_loadBill(branchType, branchId, fDate, tDate, outputType); var m = db.sp_web_baocaoxuathang(branchType.Trim(), branchId.Trim(), fDate, tDate, int.Parse(rdPaymentType.SelectedValue)); double total_revenue = 0; int count = 0; string code = ""; var tmp1 = new Dictionary <string, double>(); foreach (var item in m.ToList()) { if (code != item.StockCode) { count++; code = item.StockCode; } result += "<tr class='detail-rows' id='" + item.Id.ToString() + "' title='Click để xem chi tiết'>"; result += "<td class='center childrows'></td>"; result += "<td>" + item.BranchCode + "</td>"; result += "<td>" + item.BranchName + "</td>"; result += "<td>" + item.CreateAt + "</td>"; result += "<td>" + item.StockCode + "</td>"; result += "<td>" + item.MemberCode + "</td>"; result += "<td>" + item.MemberName + "</td>"; result += "<td>" + item.Address + "</td>"; result += "<td>" + item.Phone + "</td>"; result += "<td>" + item.FullName + "</td>"; result += "<td>" + item.Code + "</td>"; result += "<td>" + item.Name + "</td>"; result += "<td>" + item.ProductCode + "</td>"; result += "<td>" + item.ProductName + "</td>"; result += "<td>" + item.UnitName + "</td>"; result += "<td>" + item.Quantity.ToString() + "</td>"; result += "<td>" + string.Format("{0:0,0}", item.Price.Value) + "</td>"; result += "<td>" + item.DiscountPercent.ToString() + " %</td>"; if (item.Discount.Value > 999) { result += "<td>" + string.Format("{0:0,0}", item.Discount) + "</td>"; } else { result += "<td>" + item.Discount.ToString() + "</td>"; } result += "<td>" + string.Format("{0:0,0}", item.TotalPrice) + "</td>"; if (!tmp1.ContainsKey(item.StockCode)) { result += "<td>" + string.Format("{0:0,0}", item.TTPrice) + "</td>"; result += "<td>" + item.TotalDiscountPercent.ToString() + " %</td>"; if (item.TotalDiscount > 999) { result += "<td>" + string.Format("{0:0,0}", item.TotalDiscount) + "</td>"; } else { result += "<td>" + item.TotalDiscount.ToString() + "</td>"; } result += "<td>" + (item.Total_Price == 0 ? "0" : string.Format("{0:0,0}", item.Total_Price)) + "</td>"; result += "<td>" + (item.CustomePay == 0 ? "0" : string.Format("{0:0,0}", item.CustomePay)) + "</td>"; result += "<td>" + (item.CustomeReturn == 0 ? "0" : string.Format("{0:0,0}", item.CustomeReturn)) + "</td>"; result += "<td>" + item.PaymentType + "</td>"; result += "<td>" + item.Note + "</td>"; tmp1.Add(item.StockCode, item.TTPrice.Value); total_revenue += item.Total_Price.Value; } else { result += "<td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td>"; } result += "</tr>"; i++; } lbCount.Text = count < 999 ? count.ToString() : string.Format("{0:0,0}", count); lbTongTien.Text = total_revenue == 0 ? "0" : string.Format("{0:0,0 đ}", total_revenue); return(result); }