Exemplo n.º 1
0
 private int LoadQuangCaoByKhuVuc(int ViTriQuangCao, int KhuVucID)
 {
     if (Common.LoaiNguoiDungID() == 3)
     {
         //For administrator
         QuangCao qcao = new QuangCao();
         DataSet ds = qcao.SelectAllQuangCaoAtViTriQuangCaoByLoaiNguoiDungID(Common.LoaiNguoiDungID(), ViTriQuangCao);
         ds.Tables[0].Columns.Add("Selected", Type.GetType("System.String"));
         ds.Tables[0].Columns["Selected"].DefaultValue = "false";
         DataRow[] selectedRows = ds.Tables[0].Select("ViTriQuangCao=" + ViTriQuangCao + " AND KhuVucID=" + KhuVucID);
         for (int i = 0; i < selectedRows.Length; i++)
         {
             selectedRows[i]["Selected"] = "true";
         }
         ds.Tables[0].DefaultView.Sort = "QuangCaoID DESC";
         grdAdv.DataSource = ds.Tables[0].DefaultView;
         grdAdv.DataBind();
         return selectedRows.Length;
     }
     else if (Common.LoaiNguoiDungID() == 2)
     {
         //For e-store manager
         QuangCao qcao = new QuangCao();
         DataSet ds = qcao.SelectAllQuangCaoAtViTriQuangCaoByNguoiDungID(Common.NguoiDungID(), ViTriQuangCao);
         ds.Tables[0].Columns.Add("Selected", Type.GetType("System.String"));
         ds.Tables[0].Columns["Selected"].DefaultValue = "false";
         DataRow[] selectedRows = ds.Tables[0].Select("ViTriQuangCao=" + ViTriQuangCao + " AND KhuVucID=" + KhuVucID);
         for (int i = 0; i < selectedRows.Length; i++)
         {
             selectedRows[i]["Selected"] = "true";
         }
         ds.Tables[0].DefaultView.Sort = "QuangCaoID DESC";
         grdAdv.DataSource = ds.Tables[0].DefaultView;
         grdAdv.DataBind();
         return selectedRows.Length;
     }
     return 0;
 }