Esempio n. 1
0
    private int LoadCuaHang(int ViTriCuaHang, int KhuVucID)
    {
        if (Common.LoaiNguoiDungID() == 3)
        {
            //For administrator
            CuaHang ch = new CuaHang();
            DataSet ds = ch.SelectAllCuaHangAtViTriCuaHang(ViTriCuaHang);

            ds.Tables[0].Columns.Add("Selected", Type.GetType("System.String"));
            ds.Tables[0].Columns["Selected"].DefaultValue = "false";
            DataRow[] selectedRows = ds.Tables[0].Select("ViTriCuaHang=" + ViTriCuaHang + " AND KhuVucID=" + KhuVucID);
            for (int i = 0; i < selectedRows.Length; i++)
            {
                selectedRows[i]["Selected"] = "true";
            }
            grdStore.DataSource = ds;
            grdStore.DataBind();
            return selectedRows.Length;
        }
        else if (Common.LoaiNguoiDungID() == 2)
        {
            //For e-store manager
            QuangCao qcao = new QuangCao();
            CuaHang ch = new CuaHang();
            DataSet ds = ch.SelectAllCuaHangAtViTriCuaHangByNguoiDungID(Common.NguoiDungID(), ViTriCuaHang);
            ds.Tables[0].Columns.Add("Selected", Type.GetType("System.String"));
            ds.Tables[0].Columns["Selected"].DefaultValue = "false";
            DataRow[] selectedRows = ds.Tables[0].Select("ViTriCuaHang=" + ViTriCuaHang + " AND KhuVucID=" + KhuVucID);
            for (int i = 0; i < selectedRows.Length; i++)
            {
                selectedRows[i]["Selected"] = "true";
            }
            grdStore.DataSource = ds;
            grdStore.DataBind();
            return selectedRows.Length;
        }
        return 0;
    }