PageRenderTime 63ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/WEB/c/user/shopping-order/_ctrl/_cntOrderList.ascx.cs

https://bitbucket.org/zzare/eko
C# | 105 lines | 66 code | 34 blank | 5 comment | 17 complexity | 583b85f95c0fb28c9ac94e063b63f43a MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. using System.Collections.Generic;
  14. namespace SM.UI.Controls
  15. {
  16. public partial class _shoppuing_order_cntOrderList : BaseControl
  17. {
  18. public delegate void OnEditEventHandler(object sender, SM.BLL.Common.Args .IDguidEventArgs e);
  19. public event OnEditEventHandler OnEdit;
  20. public event OnEditEventHandler OnDelete;
  21. public string OnEditTarget = "_self";
  22. public int PageSize = 20;
  23. public string SearchText { get; set; }
  24. public bool? Active { get; set; }
  25. public short? Status {get; set;}
  26. public bool IsAdmin { get; set; }
  27. public Guid PageID { get; set; }
  28. public Guid UserId { get; set; }
  29. protected void Page_Load(object sender, EventArgs e)
  30. {
  31. }
  32. protected void ldsList_OnSelecting(object sender, LinqDataSourceSelectEventArgs e)
  33. {
  34. eMenikDataContext db = new eMenikDataContext();
  35. var list = from l in db.SHOPPING_ORDERs where l.PageId == PageID select l;
  36. if (UserId != Guid.Empty) {
  37. list = list.Where(w=>w.UserId == UserId );
  38. }
  39. // apply filters
  40. if (Active == true)
  41. list = list.Where(w => !(w.OrderStatus >= SHOPPING_ORDER.Common.Status.NEW && w.OrderStatus <= SHOPPING_ORDER.Common.Status.STEP_4 ));
  42. else if (Active == false)
  43. list = list.Where(w => (w.OrderStatus >= SHOPPING_ORDER.Common.Status.NEW && w.OrderStatus <= SHOPPING_ORDER.Common.Status.STEP_4));
  44. if (Status != null)
  45. list = list.Where(w => w.OrderStatus == Status);
  46. else
  47. // exclude canceled
  48. {
  49. list = list.Where(w => w.OrderStatus != SHOPPING_ORDER.Common.Status.CANCELED);
  50. }
  51. //if (!String.IsNullOrEmpty(SearchText))
  52. // list = list.Where(w => (w.OrderRefID.ToString().Contains(SearchText) || (w.EM_USER.USERNAME ).Contains(SearchText) ));
  53. // result
  54. e.Result = list.OrderByDescending(o => o.DateStart );
  55. }
  56. public void BindData()
  57. {
  58. lvList.DataBind();
  59. }
  60. public string RenderCustomer(object o) {
  61. string ret = "";
  62. Guid userID = (Guid)o;
  63. CustomerRep crep = new CustomerRep();
  64. CUSTOMER c = crep.GetCustomerByID(userID);
  65. if (c == null)
  66. return ret;
  67. ret = c.USERNAME;
  68. return ret;
  69. }
  70. }
  71. }