Ejemplo n.º 1
0
        public void searchCustomerData()
        {
            string       sql  = "SELECT cusfields.Index,cusfields.Value,cusindex.Name,cusfields.IDKey AS FID FROM crm2.cusfields INNER JOIN crm2.cusindex ON cusfields.CusID=cusindex.IDKey WHERE cusfields.CusID='" + customer + "';";
            TaskCallback call = populatePage;

            DatabaseFunctions.SendToPhp(false, sql, call);
        }
Ejemplo n.º 2
0
        // Functia principala de calcul a Recomandarilor.
        public static List<Preparat> Recomandari(int id_user, Comanda comanda_actuala, int k)
        {
            IstoricComenzi istoric = DatabaseFunctions.getIstoric(id_user);
            List<Comanda> istoric_comenzi = istoric.ListaComenzi;
            List<Preparat> recomandari=null;

            if (istoric_comenzi.Count > 0)
            {
                recomandari = Gaseste_recomandari_ContentBased(id_user, k/2, istoric_comenzi);
                List<Preparat> recomandari_collective = Gaseste_recomandari_Collective(id_user, comanda_actuala, k);
                foreach (var preparat in recomandari_collective)
                {
                    if (recomandari.Count == k)
                    {
                        break;
                    }
                    if (!recomandari.Contains(preparat))
                    {
                        recomandari.Add(preparat);
                    }
                }
            }
            else
            {
                List<String> lista_specifice = DatabaseFunctions.getSpecificsForUser(id_user);
                if (lista_specifice == null)
                    recomandari = DatabaseFunctions.topKPreparate(k);
                else
                    recomandari = DatabaseFunctions.topKPreparateSpecific(lista_specifice, k);
            }
            return recomandari;
        }
Ejemplo n.º 3
0
        public void onClicked(object sender, RoutedEventArgs e)
        {
            List <string> batch = new List <string>();

            foreach (DataPair dataPair in this.entryDict)
            {
                if (dataPair.isNew)
                {
                    string s = "INSERT INTO cusfields (cusfields.Value,cusfields.Index,CusID) VALUES('" + FormatFunctions.CleanDateNew(dataPair.Value.Text) + "','" + FormatFunctions.CleanDateNew(dataPair.Index.Text) + "','" + this.customer + "')";
                    batch.Add(s);
                    dataPair.isNew = false;
                }
                else if (!dataPair.Index.Text.Equals(dataPair.Index.GetInit()) || !dataPair.Value.Text.Equals(dataPair.Value.GetInit()))
                {
                    string s = "UPDATE cusfields SET cusfields.Value = '" + FormatFunctions.CleanDateNew(dataPair.Value.Text) + "',cusfields.Index='" + FormatFunctions.CleanDateNew(dataPair.Index.Text) + "' WHERE (IDKey= '" + dataPair.Index.GetInt() + "');";
                    batch.Add(s);
                }
            }
            string sql = "UPDATE cusfields SET cusfields.value='" + FormatFunctions.CleanDateNew(noteLabel.Text) + "' WHERE cusfields.Index LIKE'%otes%' AND CusID= '" + customer + "'";

            batch.Add(sql);
            string sql2 = "UPDATE cusindex SET Name='" + FormatFunctions.CleanDateNew(nameLabel.Text) + "' WHERE IDKey= '" + customer + "'";

            batch.Add(sql2);
            string sql3 = "UPDATE cusfields SET cusfields.value='" + FormatFunctions.CleanDateNew(BookingDate.Text) + "' WHERE cusfields.Index LIKE '%ookin%' AND CusID= '" + customer + "'";

            batch.Add(sql3);
            string sql4 = "UPDATE cusfields SET cusfields.value='" + FormatFunctions.CleanPhone(phoneLabel.Text) + "' WHERE cusfields.Index LIKE '%hone%' AND CusID= '" + customer + "'";

            batch.Add(sql4);
            string sql5 = "UPDATE cusfields SET cusfields.value='" + FormatFunctions.CleanDateNew(DateTime.Now.ToString("yyyy/M/d h:mm:ss")) + "' WHERE cusfields.Index LIKE '%odified On%' AND CusID= '" + customer + "'";//'Modified On','" + FormatFunctions.CleanDateNew(DateTime.Now.ToString("yyyy/M/d h:mm:ss")) + "'

            batch.Add(sql5);
            DatabaseFunctions.SendBatchToPHP(batch);
        }
Ejemplo n.º 4
0
    private void BuildAvgScoreTable(Table table, string title, Dictionary <int, decimal> data, Dictionary <int, int> numberOfRoundsPlayed, int titleFont)
    {
        table.CellSpacing = 5;
        TableRow  tableTitleRow = new TableRow();
        TableCell titleCell     = AddCell(tableTitleRow, title);

        titleCell.HorizontalAlign = HorizontalAlign.Center;
        titleCell.Font.Bold       = true;
        titleCell.Font.Size       = titleFont;
        titleCell.ColumnSpan      = 3;
        tableTitleRow.Cells.Add(titleCell);
        table.Rows.Add(tableTitleRow);

        table.Rows.Add(CreateAvgScoreColumnTitleRow("Number of Rounds"));

        var items = from pair in data
                    orderby pair.Value ascending
                    select pair;

        foreach (KeyValuePair <int, decimal> pair in items)
        {
            if (numberOfRoundsPlayed[pair.Key] > 0)
            {
                table.Rows.Add(CreateRow(new List <string>()
                {
                    DatabaseFunctions.GetGolferName(pair.Key), Decimal.Round(data[pair.Key], 2).ToString(), numberOfRoundsPlayed[pair.Key].ToString()
                }));
            }
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        bool isUserCommissioner = false;

        leagueID        = (int)((SiteMaster)this.Master).LeagueID;
        currentSeasonID = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());
        if (leagueID == 3)
        {
            RulesHyperlink.Visible     = true;
            RulesHyperlink.NavigateUrl = "http://www.golfleagueinfo.com/2017ProgCOSLeagueRules.htm";
        }

        List <Announcement> announcements = DatabaseFunctions.GetAnnouncements(leagueID);

        foreach (var announcement in announcements)
        {
            AddAnnouncementRow(announcement);
        }

        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            var currentUserID = Membership.GetUser().ProviderUserKey.ToString();
            var commisioners  = DatabaseFunctions.GetCommissionerIds(leagueID);
            isUserCommissioner = commisioners.Contains(currentUserID);
            if (isUserCommissioner)
            {
                this.ButtonAddAnnouncement.Visible = true;
            }
        }
    }
Ejemplo n.º 6
0
    private void BuildAvgScoreTable(Table table, string title, Dictionary <int, Scoring.WeightedAvgHelper> data, int titleFont, string thirdColumnTitle)
    {
        table.CellSpacing = 5;
        TableRow  tableTitleRow = new TableRow();
        TableCell titleCell     = AddCell(tableTitleRow, title);

        titleCell.HorizontalAlign = HorizontalAlign.Center;
        titleCell.Font.Bold       = true;
        titleCell.Font.Size       = titleFont;
        titleCell.ColumnSpan      = 3;
        tableTitleRow.Cells.Add(titleCell);
        table.Rows.Add(tableTitleRow);

        table.Rows.Add(CreateAvgScoreColumnTitleRow(thirdColumnTitle));

        var items = from pair in data
                    orderby pair.Value.averageValue ascending
                    select pair;

        foreach (KeyValuePair <int, Scoring.WeightedAvgHelper> pair in items)
        {
            if (pair.Value.numValues > 0)
            {
                table.Rows.Add(CreateRow(new List <string>()
                {
                    DatabaseFunctions.GetGolferName(pair.Key), Decimal.Round(pair.Value.averageValue, 2).ToString(), pair.Value.numValues.ToString()
                }));
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (((SiteMaster)this.Master).LeagueName != null)
        {
            this.leagueID = leagueID = (int)((SiteMaster)this.Master).LeagueID;
        }
        else
        {
            //error?
            Response.Redirect("NoLeague.aspx");
        }

        currentSeasonID  = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());
        eventsAndGolfers = DatabaseFunctions.GetEventsAndPlayers(leagueID, currentSeasonID);
        //Dictionary<int, string> courses = DatabaseFunctions.GetAllCourses();
        //Dictionary<int, string> teams = DatabaseFunctions.GetTeamNames(leagueID, currentSeasonID);


        if (!Page.IsPostBack)
        {
            ListItem initialItem = new ListItem("Select Event to Continue", "0");
            Dropdown_LeagueEvent.Items.Add(initialItem);
            //TODO only add events in current season?

            foreach (KeyValuePair <int, EventInfo> eventPair  in eventsAndGolfers.events.OrderBy(x => x.Value.EventID))
            {
                int      eventID   = eventPair.Key;
                ListItem eventItem = new ListItem(eventsAndGolfers.events[eventID].EventName, eventID.ToString());
                Dropdown_LeagueEvent.Items.Add(eventItem);
            }
            Dropdown_LeagueEvent.SelectedIndex = 0;
        }
    }
    private void AddSubsToDropdown(DropDownList dropdown, int selectedEventID)
    {
        Dictionary <int, string> allGolfers    = DatabaseFunctions.GetGolferNamesAndIDs(leagueID.ToString());//get all players
        List <int>            scheduledGolfers = DatabaseFunctions.GetGolfersByEvent(selectedEventID);
        Dictionary <int, int> subs             = DatabaseFunctions.GetSubs(selectedEventID);

        foreach (int golferID in scheduledGolfers)
        {
            if (!subs.ContainsKey(golferID))
            {
                allGolfers.Remove(golferID);
            }
        }
        foreach (int golferID in subs.Values)
        {
            allGolfers.Remove(golferID);
        }


        ListItem selectionItem = new ListItem("None", "0");

        dropdown.Items.Add(selectionItem);
        foreach (int golferID in allGolfers.Keys)
        {
            ListItem playerItem = new ListItem(allGolfers[golferID], golferID.ToString());
            dropdown.Items.Add(playerItem);
        }
    }
Ejemplo n.º 9
0
        // Token: 0x06000833 RID: 2099 RVA: 0x0003A480 File Offset: 0x00038680
        protected virtual void LoadFromReader(IDataReader rd)
        {
            if (rd == null)
            {
                throw new ArgumentNullException("rd");
            }
            this.Id          = DatabaseFunctions.GetGuid(rd, "NotificationID");
            this.Title       = DatabaseFunctions.GetString(rd, "Title");
            this.Description = DatabaseFunctions.GetString(rd, "Description");
            this.CreatedAt   = DatabaseFunctions.GetDateTime(rd, "CreatedAt");
            this.Ignored     = DatabaseFunctions.GetBoolean(rd, "Ignored");
            this.TypeId      = DatabaseFunctions.GetGuid(rd, "NotificationTypeID");
            this.Url         = DatabaseFunctions.GetString(rd, "Url");
            DateTime dateTime = DatabaseFunctions.GetDateTime(rd, "AcknowledgedAt");

            if (dateTime == DateTime.MinValue)
            {
                this.AcknowledgedAt = null;
            }
            else
            {
                this.AcknowledgedAt = new DateTime?(dateTime);
            }
            this.AcknowledgedBy = DatabaseFunctions.GetString(rd, "AcknowledgedBy");
        }
Ejemplo n.º 10
0
    public DataSet getEwalletNumber_new(string userid, string portal)
    {
        DatabaseFunctions db = new DatabaseFunctions();


        return(db.getEwalletNumber_New(userid, portal));
    }
Ejemplo n.º 11
0
        private async void UpdateButton_Clicked(object sender, EventArgs e)
        {
            DatabaseFunctions dbf = new DatabaseFunctions();

            var userList = await dbf.getUsers();

            foreach (var item in userList)
            {
                if (item.Profile == t.Profile)
                {
                    t = item;
                }
            }

            var check = await dbf.deleteUser(t);

            if (!CrossConnectivity.Current.IsConnected)
            {
                await DisplayAlert("Warning", "Please, check your internet settings!", "OK");
            }
            else if (check)
            {
                DependencyService.Get <ISaveAndLoad>().SaveText("login.txt", "");

                await Navigation.PushAsync(new MainCsPage());
            }
            else
            {
                await DisplayAlert("Warning", "Something went wrong, please check back later!", "OK");
            }
        }
Ejemplo n.º 12
0
        public void populate()
        {
            string       sql2  = "SELECT agents.FName,agents.IDKey FROM agents WHERE Active='1'";
            TaskCallback call3 = populateSalesCombo;

            DatabaseFunctions.SendToPhp(false, sql2, call3);
        }
Ejemplo n.º 13
0
        public void getFavoriteAgents()
        {
            string       statement = "SELECT agents.Fname AS Name,agents.IDKey, '0' AS g FROM agents INNER JOIN chatfavorite ON agents.IDKey=chatfavorite.TargetID WHERE chatfavorite.AgentID='" + ClientData.AgentIDK + "';";
            TaskCallback call      = new TaskCallback(this.populatePicker);

            DatabaseFunctions.SendToPhp(false, statement, call);
        }
Ejemplo n.º 14
0
        public void populateTardiGridBypass()
        {
            TaskCallback call = populateTardiGrid;
            string       sql  = "SELECT * FROM agentrecords WHERE AgentID='" + agents[Agent3.SelectedIndex] + "'";

            DatabaseFunctions.SendToPhp(false, sql, call);
        }
Ejemplo n.º 15
0
        public void onClickLate(object sender, RoutedEventArgs e)
        {
            string sql = "INSERT INTO agentrecords (AgentID,Note,Date,RecordType) VALUES ('" + agents[Agent3.SelectedIndex] + "','" + SickNote.Text + "','" + DayPicker3.SelectedDate.Value.ToString("yyyy/M/d") + "','Tardy')";

            DatabaseFunctions.SendToPhp(sql);
            populateTardiGridBypass();
        }
Ejemplo n.º 16
0
    private void BindDataToGridview(int selectedEventID)
    {
        List <ScoresView>              dataToBind  = new List <ScoresView>();
        Dictionary <int, string>       golferNames = DatabaseFunctions.GetGolferNamesAndIDs(leagueID.ToString());
        Dictionary <int, int>          subs        = DatabaseFunctions.GetSubs(selectedEventID);
        Dictionary <int, List <byte> > scores      = DatabaseFunctions.GetScores(selectedEventID);
        List <int> golferIDs = DatabaseFunctions.GetGolfersByEvent(selectedEventID);


        foreach (int golferID in golferIDs)
        {
            try
            {
                string      sub = subs.ContainsKey(golferID) ? golferNames[subs[golferID]] : "";
                List <byte> scoresToUse;

                if (sub == "")
                {
                    scoresToUse = scores.ContainsKey(golferID) ? scores[golferID] : null;
                }
                else
                {
                    scoresToUse = scores[subs[golferID]];
                }
                ScoresView scoresView = new ScoresView(golferNames[golferID], sub, scoresToUse, golferID);
                dataToBind.Add(scoresView);
            }
            catch { }
        }

        grdScores.DataSource = dataToBind;
        grdScores.DataBind();
    }
Ejemplo n.º 17
0
    public int InserteWalletDepositForm(string Enumber, string Formtype, string paymentdate, string amountpaid, string trnum, string bankname, string OnlineBankAccountName, string BankTransactionNo, byte[] imagefile,string imageName)
    {
        int id=-1;
        try { 
        MemoryStream ms = new MemoryStream(imagefile);
        FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath
                   ("~/depositSlipScans/") + imageName, FileMode.Create);
        ms.WriteTo(fs);
         
        DatabaseFunctions db = new DatabaseFunctions();

        Enumber = utilities.Encrypt(Enumber);
        Formtype = utilities.Encrypt(Formtype);
        amountpaid=    utilities.Encrypt(amountpaid);
        trnum    =utilities.Encrypt(trnum);
        bankname = utilities.Encrypt(bankname);
        OnlineBankAccountName = utilities.Encrypt(OnlineBankAccountName);
        BankTransactionNo = utilities.Encrypt(BankTransactionNo);
        imageName = utilities.Encrypt(imageName);
        
       id=  db.InserteWalletDepositForm(Enumber,Formtype,paymentdate,amountpaid,trnum,bankname,OnlineBankAccountName,BankTransactionNo,imageName);
        ms.Close();
        fs.Close();
        fs.Dispose();
        
        }
        catch (Exception e) { 
            
            }
                return id;
    }
Ejemplo n.º 18
0
    public int InserteWalletDepositForm(string Enumber, string Formtype, string paymentdate, string amountpaid, string trnum, string bankname, string OnlineBankAccountName, string BankTransactionNo, byte[] imagefile, string imageName)
    {
        int id = -1;

        try {
            MemoryStream ms = new MemoryStream(imagefile);
            FileStream   fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath
                                                 ("~/depositSlipScans/") + imageName, FileMode.Create);
            ms.WriteTo(fs);

            DatabaseFunctions db = new DatabaseFunctions();

            Enumber               = utilities.Encrypt(Enumber);
            Formtype              = utilities.Encrypt(Formtype);
            amountpaid            = utilities.Encrypt(amountpaid);
            trnum                 = utilities.Encrypt(trnum);
            bankname              = utilities.Encrypt(bankname);
            OnlineBankAccountName = utilities.Encrypt(OnlineBankAccountName);
            BankTransactionNo     = utilities.Encrypt(BankTransactionNo);
            imageName             = utilities.Encrypt(imageName);

            id = db.InserteWalletDepositForm(Enumber, Formtype, paymentdate, amountpaid, trnum, bankname, OnlineBankAccountName, BankTransactionNo, imageName);
            ms.Close();
            fs.Close();
            fs.Dispose();
        }
        catch (Exception e) {
        }
        return(id);
    }
        public async Task <PaginatedList <ChefListItemDto> > Handle(SearchForChefsQuery query, CancellationToken ct)
        {
            var filter = query.Filter;

            var dbQuery = context.Users
                          .Where(u => u.UserProfiles.Any(p => p.IdProfile == (int)Profile.CHEF) &&
                                 DatabaseFunctions.IsNear(u.Id, filter.Latitude, filter.Longitude, distanceConfig.MinDistance));

            dbQuery = ApplyFilters(dbQuery, filter);

            return(await dbQuery.Select(u => new ChefListItemDto
            {
                Id = u.Id,
                Picture = u.Picture ?? NoDataFallbacks.NO_DATA_IMAGE,
                ChefFullName = u.FirstName + " " + u.LastName,
                City = u.UserAddresses
                       .OrderBy(ua => ua.LastTimeUsed)
                       .FirstOrDefault()
                       .Address
                       .City
                       .Name,
                Categories = DatabaseFunctions.UserCategories(u.Id),
            })
                   .ToPaginatedListAsync(filter.PageIndex, filter.ItemsPerPage, ct));
        }
Ejemplo n.º 20
0
    private void AddTableRow(Table SkinsTable, int golferID, List <byte> scores, List <int> skins)
    {
        TableRow tr = new TableRow();

        //CheckBox checkBox = new CheckBox();
        //checkBox.ID = "Checkbox_" + golferID.ToString();
        //checkBox.Checked = true;
        //checkBox.Text = DatabaseFunctions.GetGolferName(golferID);
        //skinsCheckboxes.Add(golferID, checkBox);

        //TableCell cell = new TableCell();
        //cell.Controls.Add(checkBox);
        //tr.Cells.Add(cell);
        AddCell(tr, DatabaseFunctions.GetGolferName(golferID));

        for (int i = 0; i < 9; i++)
        {
            TableCell c = AddCell(tr, scores[i].ToString());
            if (skins[i] == golferID)
            {
                c.BackColor = Color.LightBlue;
            }
        }
        SkinsTable.Rows.Add(tr);
    }
Ejemplo n.º 21
0
        public void assessStage()
        {
            string       sql  = "SELECT Stage FROM jobindex WHERE IDKey='" + customer + "'";
            TaskCallback call = populateAssessment;

            DatabaseFunctions.SendToPhp(false, sql, call);
        }
Ejemplo n.º 22
0
    private void DisplayHandicappedSkins()
    {
        int selectedEventID = int.Parse(Dropdown_LeagueEvent.SelectedValue);

        if (selectedEventID != 0)
        {
            Dictionary <int, List <byte> > scores    = DatabaseFunctions.GetScores(selectedEventID);
            Dictionary <int, int>          handicaps = Scoring.GetPlayerHandicapsForEvent(leagueID, selectedEventID, scores.Keys.ToList());

            Table_SkinsResults.Width = 800;
            Table_SkinsResults.Rows.Clear();
            var courseInfo = DatabaseFunctions.GetCourseInfo(selectedEventID);
            AddCourseInfoRowsSkinsTable(Table_SkinsResults, courseInfo);

            Scoring.ApplyHandicapsToScoresForHandicappedSkins(scores, handicaps, courseInfo);
            List <int> skins = Scoring.calculateSkins(scores);

            //reset skins dropdown
            DropdownList_SkinsPlayers.Items.Clear();
            ListItem initialItem = new ListItem("Select Golfers(s) to Exclude From Skins", "0");
            DropdownList_SkinsPlayers.Items.Add(initialItem);

            foreach (int GolferID in scores.Keys)
            {
                ListItem item = new ListItem(DatabaseFunctions.GetGolferName(GolferID), GolferID.ToString());
                DropdownList_SkinsPlayers.Items.Add(item);
                AddTableRow(Table_SkinsResults, GolferID, scores[GolferID], skins);
            }
        }
    }
Ejemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        leagueID = (int)((SiteMaster)this.Master).LeagueID;

        if (!Page.IsPostBack)
        {
            int currentSeasonID = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());
            AddEventsToDropdown(currentSeasonID);

            List <Season> seasons = DatabaseFunctions.GetSeasons(leagueID);
            int           i       = 0;
            foreach (Season season in seasons)
            {
                ListItem newItem = new ListItem(season.SeasonName, season.SeasonID.ToString());
                Dropdown_Seasons.Items.Add(newItem);
                if (season.isCurrentSeason)
                {
                    Dropdown_Seasons.SelectedIndex = i;
                }
                i++;
            }
            //populate views dropdown
            ListItem initialItem = new ListItem("Select View to Continue", "0");
            DropDown_View.Items.Add(initialItem);
            DropDown_View.Items.Add(SKINS_VIEW);
            DropDown_View.Items.Add(SKINS_VIEW_HANDICAPPED);
            DropDown_View.Items.Add(WEEKLY_LEADERBOARD_VIEW);
            DropDown_View.Items.Add(WEEKLY_RESULTS_VIEW);

            ViewState["PlayersToExcludeFromSkins"] = new List <int>();
            ListItem initialItem2 = new ListItem("Select Golfers(s) to Exclude From Skins", "0");
            DropdownList_SkinsPlayers.Items.Add(initialItem2);
        }
    }
Ejemplo n.º 24
0
        public void getFavoriteGroups()
        {
            string       statement = "SELECT IDKey,GroupName AS Name, '2' AS g FROM groupmembers WHERE MemberID='" + ClientData.AgentIDK + "';";
            TaskCallback call      = new TaskCallback(this.populatePicker);

            DatabaseFunctions.SendToPhp(false, statement, call);
        }
Ejemplo n.º 25
0
        public async Task <string> DiagnosticDataSpecific(string pcId)
        {
            await DatabaseFunctions.InitializeStaticStorage(_db).ConfigureAwait(false);

            try {
                var lastMinutes      = _db.LastMinutes;
                var listOfLastMinute = await lastMinutes.Where(lm => lm.PcId.Equals(pcId)).ToListAsync <LastMinute>();

                if (listOfLastMinute.Count == 0)
                {
                    return("false");
                }
                listOfLastMinute.Sort((LastMinute lm1, LastMinute lm2) =>
                {
                    if (lm1.TimeChanged == null)
                    {
                        return(0);
                    }
                    return(lm2.TimeChanged != null ? ((DateTime)lm1.TimeChanged).CompareTo((DateTime)lm2.TimeChanged) : 0);
                });

                for (var i = 1; i <= 60; i++)
                {
                    listOfLastMinute[i - 1].Second = i;
                }
                return(JsonSerializer.Serialize(listOfLastMinute));
            }
            catch (Exception e)
            {
                return("false");
            }
        }
Ejemplo n.º 26
0
    public string getEwalletNumber(string userid, string portal)
    {
        DatabaseFunctions db = new DatabaseFunctions();


        return(db.getEwalletNumber(userid, portal));
    }
Ejemplo n.º 27
0
    protected void RemoveButtonClick(object sender, CommandEventArgs e)
    {
        Button b = (Button)sender;
        string matchupIDToRemove = b.ID;
        int    team1ID, team2ID;

        MatchupIDtoTeamIDs(matchupIDToRemove, out team1ID, out team2ID);
        List <Control> controlsToRemove = new List <Control>();

        foreach (Control control in Panel_Matchups.Controls)
        {
            if (control.ID.Contains(matchupIDToRemove))
            {
                controlsToRemove.Add(control);
            }
        }
        foreach (Control control in controlsToRemove)
        {
            Panel_Matchups.Controls.Remove(control);
        }
        int currentSeasonID            = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());
        Dictionary <int, string> teams = DatabaseFunctions.GetTeamNames(leagueID);

        AddTeamToDropdowns(team1ID, teams);
        AddTeamToDropdowns(team2ID, teams);
        SelectedMatchups.Remove(team1ID);
        ViewState["MatchupControls"] = SelectedMatchups;
    }
Ejemplo n.º 28
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string pagename = Path.GetFileName(Request.PhysicalPath);
     string UserID = string.Empty;
     bool loggedStatus = false;
     if(System.Web.HttpContext.Current.User != null)
     {
         loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
         if(loggedStatus)
         {
             UserID = Membership.GetUser().ProviderUserKey.ToString();
             DatabaseFunctions d = new DatabaseFunctions();
             int uid = d.GetCandidateID(UserID);
             DBFunctions db = new DBFunctions();
             var timetable = db.gettimetable(uid);
             foreach (var t in timetable)
             {
                 timetabletbl.Text += "<tr ><td>" + t.Courses_tbl.Course + "</td><td>" + t.Day + "</td><td>" + t.Teacher + "</td><td>" + t.StartTime + "</td><td>" + t.EndTime + "</td></tr>";
             }
         }
     }
     else
     {
         Response.Redirect("Login.aspx?Redirecturl=" + pagename); Response.Redirect("Login.aspx?Redirecturl=" + pagename);
     }
 }
Ejemplo n.º 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string pagename     = Path.GetFileName(Request.PhysicalPath);
        string UserID       = string.Empty;
        bool   loggedStatus = false;

        if (System.Web.HttpContext.Current.User != null)
        {
            loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            if (loggedStatus)
            {
                UserID = Membership.GetUser().ProviderUserKey.ToString();
                DatabaseFunctions d   = new DatabaseFunctions();
                int         uid       = d.GetCandidateID(UserID);
                DBFunctions db        = new DBFunctions();
                var         timetable = db.gettimetable(uid);
                foreach (var t in timetable)
                {
                    timetabletbl.Text += "<tr ><td>" + t.Courses_tbl.Course + "</td><td>" + t.Day + "</td><td>" + t.Teacher + "</td><td>" + t.StartTime + "</td><td>" + t.EndTime + "</td></tr>";
                }
            }
        }
        else
        {
            Response.Redirect("Login.aspx?Redirecturl=" + pagename); Response.Redirect("Login.aspx?Redirecturl=" + pagename);
        }
    }
Ejemplo n.º 30
0
        public void onClick(object sender, RoutedEventArgs e)
        {
            DateTime d   = (DateTime)DayPicker.SelectedDate;
            string   sql = "SELECT * FROM punchclock WHERE AgentID='" + agents[Agent.SelectedIndex] + "' AND (" + FormatFunctions.getRelevantDates(d, "TimeStamp") + ")";

            if ((bool)AppCheck.IsChecked)
            {
                sql += " AND Approved='1'";
            }
            if ((bool)!LocCheck.IsChecked)
            {
                sql += " AND (State='True' OR State='False')";
            }
            sql += " ORDER BY IDKey ASC";
            TaskCallback call = populateStamps;

            DatabaseFunctions.SendToPhp(false, sql, call);

            if ((bool)tarCheck.IsChecked)
            {
                string       sql4  = "SELECT * FROM agentrecords WHERE AgentID='" + agents[Agent.SelectedIndex] + "' AND (" + FormatFunctions.getRelevantDates(d, "Date") + ")  ORDER BY IDKey DESC";
                TaskCallback call3 = populateTardiness;
                DatabaseFunctions.SendToPhp(false, sql4, call3);
            }
        }
Ejemplo n.º 31
0
    private void populateEventDetailsInModal(int EventID)
    {
        //int currentSeasonID = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());
        List <EventInfo> events = DatabaseFunctions.GetEvents(leagueID, currentSeasonID);

        EventInfo eventInfo = events.Where(x => x.EventID == EventID).ToList().First();

        Dictionary <int, int>  matchups = DatabaseFunctions.GetMatchups(eventInfo.EventID);
        Dictionary <int, Team> teams    = DatabaseFunctions.GetTeams(leagueID);

        foreach (int team1ID in matchups.Keys)
        {
            AddMatchup(team1ID, matchups[team1ID], teams[team1ID].TeamName, teams[matchups[team1ID]].TeamName);
            teams.Remove(team1ID);
            teams.Remove(matchups[team1ID]);
        }

        if (!eventInfo.HasScores)
        {
            foreach (Team team in teams.Values)
            {
                if (!team.hidden)
                {
                    AddToRemainingTeams(team.TeamID, team.TeamName);
                }
            }
        }

        TextBox_EventName.Text        = eventInfo.EventName;
        datepicker.Text               = eventInfo.Date;
        Dropdown_Course.SelectedValue = eventInfo.CourseID.ToString();
    }
Ejemplo n.º 32
0
        internal static void OnC2SAskCreateCharacter(ByteBuffer buffer, Connection connection)
        {
            var incPacket = new CharacterPackets.C2SAskCreateCharacter(buffer, connection);
            var client    = ClientManager.GetClient(connection);

            if (!DatabaseFunctions.CreateCharacter(
                    client.UserId, incPacket.CharName,
                    (byte)incPacket.ClassCode,
                    (byte)incPacket.HeightCode,
                    (byte)incPacket.FaceCode,
                    (byte)incPacket.HairCode,
                    out var character))
            {
                return;
            }
            if (!DatabaseFunctions.AddCharacterToDB(character, out var charID))
            {
                return;
            }
            character.Id = charID;
            var charInfoForPacket = new PacketStructs.CharacterInfo(character);
            var outPacket         = new CharacterPackets.S2CAnsCreateCharacter(charInfoForPacket.ToBytes(), connection);

            outPacket.Send(connection);
        }
 protected void Requestbtn_Click(object sender, EventArgs e)
 {
     DBFunctions db = new DBFunctions();
     DatabaseFunctions d = new DatabaseFunctions();
  
     LibraryMember member = new LibraryMember { UserID = stid, Status = 0,JoinDate=DateTime.Now.Date };
     db.requestlibrarymembership(member);
 }
Ejemplo n.º 34
0
    public string inserteWalletTranscation(string ewalletnumber, string description, string Amount, string tType, string transcationnum
        , string Portal)
    {
       
        DatabaseFunctions db = new DatabaseFunctions();
        db.inserteWalletTranscationrow(ewalletnumber, description, Amount, tType, transcationnum, Portal);

        return "Done";
    }
Ejemplo n.º 35
0
 protected void submitcommentbtn_Click(object sender, EventArgs e)
 {
     DBFunctions db = new DBFunctions();
     DatabaseFunctions d = new DatabaseFunctions();
     Discussions_tbl dis = new Discussions_tbl { userID = d.GetCandidateID(UserID), Discission = commenttxt.InnerText, TopicID = int.Parse(Request.QueryString["topicid"].ToString()), Date = DateTime.Now };
     dis= db.adddiscussion(dis);
     //discusion.Text += "<div class='comment-name'><img src='images//" + Session["Image"] + "' height='50px' width='50px'> <span class='h4 '>" + Session["Name"] + "</span></div><br>";
     //discusion.Text += "<p class='blockquote comment'> " + dis.Discission + "</p><br>";
     //discusion.Text += "<p class='caption'>" + dis.Date + "</p><br><hr>";
     loaddiscussions(dis.TopicID.Value);
 }
Ejemplo n.º 36
0
 public int AddEwallet(string userid,string Enumber, string pin, string Name, string address, string portal)
 {
     DatabaseFunctions db = new DatabaseFunctions();
     Enumber = utilities.Encrypt(Enumber);
     pin = utilities.Encrypt(pin);
     Name = utilities.Encrypt(Name);
     address = utilities.Encrypt(address);
     portal = utilities.Encrypt(portal);
     int flag = db.createeWalletAccount(userid, Enumber, pin, Name, address, portal);
     return flag;
 }
Ejemplo n.º 37
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        string returnuurl = "";
        if (Request.QueryString["Redirecturl"] != null)
        {
            returnuurl = Request.QueryString["Redirecturl"];
            Message.Visible = true;
            Message.Text = "Please Login First";
        }
        else
        {
            DBFunctions db = new DBFunctions();
            Candidate_tbl candidate = db.LoginChek(username.Text, password.Text);
            if (Membership.ValidateUser(username.Text, password.Text))
            {
                FormsAuthentication.SetAuthCookie(username.Text, true);
                string UserID = "";
                bool LoggedStatus = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;

                             MembershipUser mu = Membership.GetUser(username.Text);
                            UserID = mu.ProviderUserKey.ToString();
                            DatabaseFunctions d = new DatabaseFunctions();
                            int uid = d.GetCandidateID(UserID);
                            Session["username"] = username.Text;
                            Session["userid"] = uid;

                            Session["Name"] = candidate.Name;
                            Session["Image"] = candidate.Image;
                            Session["Role"] = "Student";
                            Session["email"] = candidate.Email;
                            Session["candidate"] = candidate;

                            if (returnuurl == "")
                            {
                                Response.Redirect("ProfilePage.aspx");
                            }
                            else
                            {
                                Response.Redirect(returnuurl);
                            }
                  
            }
            else
            {
                Message.Text = "Wrong Username or Password";
                Message.Visible = true;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        bool loggedStatus = false;
        if (System.Web.HttpContext.Current.User != null)
        {
            DatabaseFunctions d = new DatabaseFunctions();
            loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            if (loggedStatus)
            {
                UserID = Membership.GetUser().ProviderUserKey.ToString();
                stid = d.GetCandidateID(UserID);
                if (stid != -1)
                {
                    DBFunctions db = new DBFunctions();
                    backlink.Text = "<a href='#0' class='btn btn-primary' onclick='history.back()'>Back</a>";

                    var chk = db.getLirarymember(stid);
                    if (chk == null)
                    {
                        var stdent = db.getstdentinfo(stid);
                        nametxt.Text = stdent.Candidate_tbl.Name;
                        metricno.Text = stdent.Candidate_tbl.AddmissionList_tbl.FirstOrDefault().MetricNo;
                        programme.Text = stdent.Program_tbl.ProgramName;
                    }
                    else
                    {
                        membershipform.Visible = false;
                        membermsg.Visible = true;
                        if (chk.Status == 0)
                        {
                            membermsg.InnerText = "Your Request For Library Membership is Pending..!!";
                        }

                        else if (chk.Status == 1)
                        {
                            membermsg.InnerText = "You Already Have The Library Membership!!";

                        }
                    }
                }
                else
                {

                }
            }
        }
    }
    public static string depositFormUpdate(string trnum, string userID, int pageIndex)
    {

        DatabaseFunctions db = new DatabaseFunctions();

        int actualAmount = db.getDepositFormAmount(trnum);
        db.Update_eWallet_Status_Balance(trnum, userID, actualAmount);

        string query = "[GeteWalletPaymentdeposit_application]";
        SqlCommand cmd = new SqlCommand(query);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
        cmd.Parameters.AddWithValue("@PageSize", PageSize);
        cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
        return GetData(cmd, pageIndex).GetXml();

    }
Ejemplo n.º 40
0
    protected void LoginBtn_Click(object sender, EventArgs e)
    {
        string enumber = utilities.Encrypt(InputEnumber.Text);
        string pin = utilities.Encrypt(InputPin.Text);
        string name = utilities.Encrypt(InputName.Text);
        string address = utilities.Encrypt(InputAddress.Text);
        string portal = utilities.Encrypt(InputPortal.Text);

        DatabaseFunctions db = new DatabaseFunctions();
        //db.createeWalletAccount(,enumber, pin, name, address, portal);
        //string encpPin = utilities.Base64Encode(pin);
      //  Response.Write("<script>alert('"+encpPin+"')</script>");
        
     //   Response.Write("<script>alert('" + utilities.Base64Decode(encpPin) + "')</script>");

       
    }
Ejemplo n.º 41
0
    public void getcoursesfee()
    {
        DatabaseFunctions d = new DatabaseFunctions();
        int sid= d.GetCandidateID(UserID);
        DBFunctions db = new DBFunctions();
       var coursefeelist= db.getstudentcoursefee(sid);
        foreach(var cf in coursefeelist)
        {
            if(cf.Status==0)
            coursefeetbl.Text += "<tr><td>"+cf.Courses_tbl.Course+"</td><td>"+cf.Courses_tbl.Marks+"</td><td>"+cf.Courses_tbl.Fee+"</td><td><a href=#0 class='btn btn-danger'>Unpaid</a></td><td><a hred='#0' class='btn btn-primary'>Pay</a></td></tr>";
            else if(cf.Status==1)
            {
                coursefeetbl.Text += "<tr><td>" + cf.Courses_tbl.Course + "</td><td>" + cf.Courses_tbl.Marks + "</td><td>" + cf.Courses_tbl.Fee + "</td><td><a href=#0 class='btn btn-info'>paid</a></td></tr>";
           
            }
        }

    }
Ejemplo n.º 42
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string Userid = string.Empty;
        bool loggedStatus = false;
        if (Session["admin"] == null)
        {
            if (System.Web.HttpContext.Current.User != null)
            {
                DatabaseFunctions db = new DatabaseFunctions();
                loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
                if (loggedStatus)
                {
                    Userid = Membership.GetUser().ProviderUserKey.ToString();
                    //  loadprogrammes();
                    if (!IsPostBack)
                    {
                        int uid = db.GetCandidateID(Userid);
                        int status = db.GetAdmissionStatus(uid);
                        int CheckRegno = -1;
                        string FormNumber = "";
                        FormNumber = db.getFormumber();
                        if (FormNumber != "")
                        {
                            CheckRegno = db.CheckAdmission(FormNumber);
                            if (CheckRegno == -1 || CheckRegno == 0)
                            {
                                isSTudent = false;
                            }
                            else if (CheckRegno > 0)
                            {
                                isSTudent = true;
                            }

                        }
                    }

                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
        }
    }
Ejemplo n.º 43
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        MembershipCreateStatus createStatus;
        string message = string.Empty;
        Candidate_tbl candidate = new Candidate_tbl { Name = Nametxt.Text, Username = Usernametxt.Text, Email = Emailtxt.Text, Password = Passwordtxt.Text, Phone = Phonetxt.Text,  Status = 0, AdmissionYear = DateTime.Now.Year.ToString() };
        MembershipUser newUser = System.Web.Security.Membership.CreateUser(Usernametxt.Text, Passwordtxt.Text, Emailtxt.Text, null, null, true, out createStatus);
        switch (createStatus)
        {
            case MembershipCreateStatus.Success: message = "The user account was successfully created!";
                FormsAuthentication.SetAuthCookie(Usernametxt.Text, true);
                DatabaseFunctions db = new DatabaseFunctions();
                DBFunctions d = new DBFunctions();
                int i=db.insertUserOtherInfo(Usernametxt.Text, Phonetxt.Text, newUser.ProviderUserKey.ToString(),0);
                int CandidateID=d.AddCandidate(candidate);
                if(i!=-1)
                {
                    db.InsertMappindIDs(newUser.ProviderUserKey.ToString(),CandidateID);
                    Response.Redirect("ProfilePage.aspx");
                }
                break;

            case MembershipCreateStatus.DuplicateUserName: message = "There already exists a user with this username.";

                break;
            case MembershipCreateStatus.DuplicateEmail: message = "There already exists a user with this email address.";

                break;
            case MembershipCreateStatus.InvalidEmail: message = "There email address you provided in invalid.";

                break;
            case MembershipCreateStatus.InvalidAnswer: message = "There security answer was invalid.";

                break;
            case MembershipCreateStatus.InvalidPassword: message = "The password you provided is invalid. It must be atleast 4 characters long.";

                break;
            default: message = "There was an unknown error; the user account was NOT created.";

                break;
        }
        RegistrationLabel.Visible = true;
        RegistrationLabel.Text = message;
    }
Ejemplo n.º 44
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string pagname = Path.GetFileName(Request.PhysicalPath);
     if (System.Web.HttpContext.Current.User != null)
     {
         bool LoggedStatus = false;
         LoggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
         if (LoggedStatus)
         {
             UserID = Membership.GetUser().ProviderUserKey.ToString();
             DatabaseFunctions db = new DatabaseFunctions();
             StudentID = db.GetCandidateID(UserID);
             loadmails();
         }
         
     }
     else
     {
         Response.Redirect("Login.aspx?Redirecturl=" + pagname);
     }
 }
 public static string getinboxcount()
 {
     DBFunctions db = new DBFunctions();
     if(System.Web.HttpContext.Current.User != null){
         DatabaseFunctions d = new DatabaseFunctions();
         int check = d.GetCandidateID( Membership.GetUser().ProviderUserKey.ToString());
         if (check != -1)
         {
             return db.getstudentinboxcount(check).ToString();
         }
         else
         {
             return "";
         }
     }
     else
     {
         return "0";
     }
     
     
 }
    protected void Page_Load(object sender, EventArgs e)
    {
         string pagename = Path.GetFileName(Request.PhysicalPath);
         
         bool loggedStatus = false;
         if (System.Web.HttpContext.Current.User != null)
         {
             DatabaseFunctions db = new DatabaseFunctions();
             loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
             if (loggedStatus)
             {
                 Userid = Membership.GetUser().ProviderUserKey.ToString();
                 //  loadprogrammes();
                

             }
             else
             {
                 Response.Redirect("Login.aspx");
             }
         }

    }
Ejemplo n.º 47
0
    protected void Page_Load(object sender, EventArgs e)
    {
        
            string pagename = Path.GetFileName(Request.PhysicalPath);
            bool loggedStatus = false;
            if (System.Web.HttpContext.Current.User != null)
            {
                if (!IsPostBack)
                {
                    loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
                    if (loggedStatus)
                    {
                        DBFunctions db = new DBFunctions();
                        DatabaseFunctions d = new DatabaseFunctions();
                        Userid = Membership.GetUser().ProviderUserKey.ToString();
                        uid = d.GetCandidateID(Userid);
                        //  loadprogrammes();

                        StudentInfo_tbl temp = db.getstdentinfo(uid);

                        StudentSelectedCredit obj = db.getStudentCredits(uid).FirstOrDefault();
                        if (obj != null)
                        {
                            Credits = Convert.ToInt16(obj.SelectedCourseCount);
                        }

                        getcourses();

                    }
                    else
                    {
                        Response.Redirect("Login.aspx?Redirecturl=" + pagename);
                    }
                }
            }
      //  dropdownCourse.DataSource=
    }
    protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

        if (AsyncFileUpload1.HasFile)
        {
            var fileName = AsyncFileUpload1.FileName;
            var fileExtension = fileName.Substring(fileName.LastIndexOf('.') + 1);
            if (fileExtension.ToLower().Contains("jpg") || fileExtension.ToLower().Contains("png"))
            {
                if (AsyncFileUpload1.FileContent.Length < 2000000)
                {
                    String savePath = MapPath("profilepics/" + AsyncFileUpload1.FileName);
                    DatabaseFunctions db = new DatabaseFunctions();
                    string formnum = db.getFormumber();

                    string origPath = MapPath("profilepics/" + formnum + ".jpg");
                    AsyncFileUpload1.SaveAs(origPath);
                    // File.AppendAllText("C:/lg.txt", "\r\n"+savePath);
                    AsyncFileUpload1.SaveAs(savePath);

                    var image = new Bitmap(MapPath("profilepics/" + formnum + ".jpg"));
                    if (image.Height > 200 || image.Width > 200)
                    {
                        Console.Write("IMAGE DIMENSION LARGE PROCESSING IMAGE");
                        var image2 = ResizeImage(image, 200, 200);
                        image.Dispose();
                        image = null;
                        File.Delete(origPath);
                        image2.Save(origPath);
                        image2.Dispose();
                        image2 = null;

                    }
                    else
                    {
                        //Console.Write("IMAGE DIMENSION SMALL SKIPPING IMAGE");
                        image.Dispose();
                        image = null;
                    }

                    // AsyncFileUpload1.SaveAs(MapPath("C:/AdmissionPortal/profilepics/" + AsyncFileUpload1.FileName));
                    //   literealErrorImage.Text = "";
                    UploadFolderPath = "profilepics/";
                    ViewState["imageDisplay_str"] = formnum + "." + fileExtension;
                }
                else
                {
                    ClearContents(sender as Control);
                    //   literealErrorImage.Text = " <span class=\"btn btn-danger\">Image file size should be less than 2 MB </span>";

                }
            }

        }


    }
    public void getstates()
    {
        DatabaseFunctions db = new DatabaseFunctions();
        DataSet dt = db.getStates();
        if (dt.Tables[0].Rows.Count > 0)
        {
            dropdownSto.DataSource = dt.Tables[0];
            dropdownSto.DataBind();
        }

    }
    public void loadbirthDay_Dropdowns()
    {
        getstates();

        for (int i = 1; i < 32; i++)
        {

            dropdownDay.Items.Insert((i - 1), new ListItem(i.ToString(), i.ToString()));

        }
        int j = 0;

        for (int i = 1900; i < 2015; i++)
        {

            dropdownyears.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            j++;
        }

        int c = DateTime.Now.Year;
        int c2 = c - 45;
        j = 1;
        for (int i = c; i >= c2; i--)
        {
            dropdownExamYear.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            dropdownListexamyear2.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            j++;
        }

        c2 = c - 35;
        j = 1;
        for (int i = c; i >= c2; i--)
        {
            dropdownJambExamYear_Previous.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            dropdownyearCompleted_Previous.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            dropdownIndustrialTrainingEndYear.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            dropdownIndustrialTrainingYearStart2.Items.Insert(j, new ListItem(i.ToString(), i.ToString()));
            j++;
        }

        //j=1;

        //for (int x = c; x < c + 20; x++)
        //{
        //    dropdownIndustrialTrainingEndYear.Items.Insert(j, new ListItem(x.ToString(), x.ToString()));
        //    dropdownIndustrialTrainingYearStart2.Items.Insert(j, new ListItem(x.ToString(), x.ToString()));
        //    j++;
        //}
        //dropdownJambExamYear_Previous


        DatabaseFunctions db = new DatabaseFunctions();
        DataSet ds = new DataSet();
        ds = db.getdates_CBT(Convert.ToInt32(ViewState["programID"]));

        if (ds.Tables[0].Rows.Count > 0)
        {
            dropdownScheduleDate.DataSource = ds.Tables[0];
            dropdownScheduleDate.DataBind();
        }
        else
        {
            dropdownScheduleDate.Items.Clear();
            dropdownScheduleDate.Items.Insert(0, new ListItem("Select Date", ""));
            dropdownScheduleDate.DataBind();
        }

    }
    protected void FileUploadComplete_Old(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

        if (AsyncFileUpload1.HasFile)
        {
            var fileName = AsyncFileUpload1.FileName;
            var fileExtension = fileName.Substring(fileName.LastIndexOf('.') + 1);
            if (fileExtension.ToLower().Contains("jpg") || fileExtension.ToLower().Contains("png"))
            {
                if (AsyncFileUpload1.FileContent.Length < 2000000)
                {
                    String savePath = MapPath("profilepics/" + AsyncFileUpload1.FileName);
                    DatabaseFunctions db = new DatabaseFunctions();
                    string formnum = db.getFormumber();

                    AsyncFileUpload1.SaveAs(MapPath("profilepics/" + formnum + ".jpg"));
                    // File.AppendAllText("C:/lg.txt", "\r\n"+savePath);
                    AsyncFileUpload1.SaveAs(savePath);
                    // AsyncFileUpload1.SaveAs(MapPath("C:/AdmissionPortal/profilepics/" + AsyncFileUpload1.FileName));
                    //   literealErrorImage.Text = "";
                    UploadFolderPath = "profilepics/";
                    ViewState["imageDisplay_str"] = formnum + "." + fileExtension;
                }
                else
                {
                    ClearContents(sender as Control);
                    //   literealErrorImage.Text = " <span class=\"btn btn-danger\">Image file size should be less than 2 MB </span>";

                }
            }

        }


    }
    public void saveFunction_SaveAll()
    {
        DatabaseFunctions db = new DatabaseFunctions();


        string userId = Membership.GetUser().ProviderUserKey.ToString();
        try
        {
            //if (tabName == "HasJambData")
            {
                string fullName = db.getStudent_CompleteName(userId);

                db.InsertJambData(ViewState["formnum"].ToString(), txtJambRegNo.Text, dropdownSubject1.SelectedItem.Value, txtScore1.Text, dropdownSubject2.SelectedItem.Value, txtscore2.Text,
                    dropdownSubject3.SelectedItem.Value, txtscore3.Text, dropdownSubject4.SelectedItem.Value, txtscore4.Text, dropdownJambchoice.SelectedItem.Value, userId);

            }
            //  else if (tabName == "HasBioDataSection")
            {
                string dob = dropdownyears.SelectedItem.Value + "-" + dropdownMonth.SelectedItem.Value + "-" + dropdownDay.SelectedItem.Value;
                string img = string.Empty;


                if (hidden_dpImage.Value != "")
                {
                    img = ViewState["formnum"].ToString() + ".jpg";
                }
                db.InsertBioData(ViewState["formnum"].ToString(), txtSurname.Text, txtFirstName.Text, txtOtherName.Text, dropdownGender.SelectedItem.Value, txtHomeaddress.Text, txtPhonenumber.Value, txtEmail.Text, dropdownSto.SelectedItem.Value, dropdownLocalGovtarea.SelectedItem.Value, userId, img, dob);

            }
            // else if (tabName == "HasOlevelResult")
            {
                db.InsertOlevelInfo_FirstSitting(ViewState["formnum"].ToString(), userId, dropdownExam.SelectedItem.Value, dropdownExamMonth.SelectedItem.Value, txtExamNum.Text, dropdownExamYear.SelectedItem.Value,
                    dropdownOlevelSub1.SelectedItem.Value, dropdownolevelGrade1.SelectedItem.Value, dropdownOlevelSub2.SelectedItem.Value, dropdownGrade2.SelectedItem.Value,
                    dropdownolevelSub3.SelectedItem.Value, dropdownGrade3.SelectedItem.Value, dropdownOlvlSub4.SelectedItem.Value, dropdownGrade4.SelectedItem.Value, dropdownOlevelsub5.SelectedItem.Value, dropdownGrade5.SelectedItem.Value,
                    dropdownOlevelSub6.SelectedItem.Value, dropdownGrade6.SelectedItem.Value, dropdownOlevelSub7.SelectedItem.Value, dropdonGrade7.SelectedItem.Value, dropdownolevelSub8.SelectedItem.Value, dropdownGrade8.SelectedItem.Value,
                    dropdowOlevelSub9.SelectedItem.Value, dropdownGrade9.SelectedItem.Value);

                db.InsertOlevelInfo_SecondSitting(ViewState["formnum"].ToString(), userId, dropdownExamType2.SelectedItem.Value, dropdownExamMonth2.SelectedItem.Value, txtExamNum2.Text, dropdownListexamyear2.SelectedItem.Value,
                   dropdownOlevelsubject1b.SelectedItem.Value, dropdownListGrade2.SelectedItem.Value, dropdownOlevelSub2b.SelectedItem.Value, dropdownGrade2b.SelectedItem.Value,
                   dropdownolevelSub3b.SelectedItem.Value, dropdownGrade3b.SelectedItem.Value, dropdownOlvlSub4b.SelectedItem.Value, dropdownGrade4b.SelectedItem.Value, dropdownOlevelsub5b.SelectedItem.Value, dropdownGrade5b.SelectedItem.Value,
                   dropdownOlevelSub6b.SelectedItem.Value, dropdownGrade6b.SelectedItem.Value, dropdownOlevelSub7b.SelectedItem.Value, dropdonGrade7b.SelectedItem.Value, dropdownolevelSub8b.SelectedItem.Value, dropdownGrade8b.SelectedItem.Value,
                   dropdowOlevelSub9b.SelectedItem.Value, dropdownGrade9b.SelectedItem.Value);

            }
            //  else if (tabName == "HasPreviousRecord")
            {
                string indstart = dropdownIndustrialtrainingStart.SelectedItem.Value + "-" + dropdownIndustrialTrainingEndYear.SelectedItem.Value;

                string indEnd = dropdownIndustrialStarmonth2.SelectedItem.Value + "-" + dropdownIndustrialTrainingYearStart2.SelectedItem.Value;


                db.InsertPreviousRecord(ViewState["formnum"].ToString(), userId, txtjaRegno_previous.Text, dropdownJambExamYear_Previous.SelectedItem.Value, txtJambFullName_previous.Text,
                    dropdwnJamIns_Previous.SelectedItem.Value, txtJambCourseName_previous.Text, dropdownCourseType_Previous.SelectedItem.Value, dropdownCourseGrade_Prvious.SelectedItem.Value,
                    dropdownyearCompleted_Previous.SelectedItem.Value, indstart, indEnd, txtNdMetricNum.Text);

            }
            //else if (tabName == "HasCBTSchedule")
            {
                DataSet ds = db.getSingleTimes_CBT(dropdownScheduleDate.SelectedItem.Value, Convert.ToInt32(ViewState["programID"]), dropdownTime.SelectedItem.Text.ToString());

                if (ds.Tables[0].Rows.Count > 0)
                {
                    //GET INGO ...
                    int ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"].ToString());
                    int Usedcapacity = Convert.ToInt16(ds.Tables[0].Rows[0]["Used"].ToString());
                    Usedcapacity = Usedcapacity + 1;

                    int insertFlag = db.InsertCbtScheduleIngo(ViewState["formnum"].ToString(), userId, dropdownScheduleDate.SelectedItem.Value, dropdownTime.SelectedItem.Text, ViewState["formnum"].ToString(), lblCbtPassword.Text);
                    if (insertFlag > 0)
                    {
                        //UPDATE PROGRAM USED CAPACITY
                        db.updateCBTSCheduler(ID, Usedcapacity);
                    }

                }
            }
            //  if (tmp == 1)
            {
                //ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alert('Form section saved Successfully !');", true);
            }
        }
        catch (Exception ex)
        {

        }
    }
    public void loadDates_CBT()
    {
        DatabaseFunctions db = new DatabaseFunctions();
        DataSet ds = new DataSet();
        ds = db.getdates_CBT(Convert.ToInt32(ViewState["programID"]));

        if (ds.Tables[0].Rows.Count > 0)
        {
            dropdownScheduleDate.DataSource = ds.Tables[0];
            dropdownScheduleDate.DataBind();
        }
        else
        {
            dropdownScheduleDate.Items.Clear();
            dropdownScheduleDate.Items.Insert(0, new ListItem("Select Date", ""));
            dropdownScheduleDate.DataBind();
        }

    }
    public void loadInstitutions()
    {
        DatabaseFunctions db = new DatabaseFunctions();
        DataSet dt = db.getInstitutions();
        if (dt.Tables[0].Rows.Count > 0)
        {
            dropdwnJamIns_Previous.DataSource = dt.Tables[0];
            dropdwnJamIns_Previous.DataBind();
        }

    }
    public void loadTabsInfo(string colName)
    {
        DataSet ds = new DataSet();
        DatabaseFunctions db = new DatabaseFunctions();
        string userID = Membership.GetUser().ProviderUserKey.ToString();

        if (colName == "HasJambData")
        {
            ds = db.loadJamDataByUserID(userID);
            if (ds.Tables[0].Rows.Count > 0)
            {
                txtJambRegNo.Text = ds.Tables[0].Rows[0]["JambRegNo"].ToString();
                dropdownSubject1.SelectedValue = ds.Tables[0].Rows[0]["Subject1"].ToString();
                txtScore1.Text = ds.Tables[0].Rows[0]["Score1"].ToString();
                dropdownSubject2.SelectedValue = ds.Tables[0].Rows[0]["Subject2"].ToString();
                txtscore2.Text = ds.Tables[0].Rows[0]["Score2"].ToString();
                dropdownSubject3.SelectedValue = ds.Tables[0].Rows[0]["Subject3"].ToString();
                txtscore3.Text = ds.Tables[0].Rows[0]["Score3"].ToString();
                dropdownSubject4.SelectedValue = ds.Tables[0].Rows[0]["Subject4"].ToString();
                txtscore4.Text = ds.Tables[0].Rows[0]["Score4"].ToString();
                dropdownJambchoice.SelectedValue = ds.Tables[0].Rows[0]["ChoiceOfPolytechnic"].ToString();

                if (txtScore1.Text != "" && txtscore2.Text != "" && txtscore3.Text != "" && txtscore4.Text != "")
                {
                    int sum = Convert.ToInt16(txtScore1.Text) + Convert.ToInt16(txtscore2.Text) + Convert.ToInt16(txtscore3.Text) + Convert.ToInt16(txtscore4.Text);

                    txtJambUtmeScore.Value = sum.ToString();
                }
            }
        }
        else if (colName == "HasBioDataSection")
        {
            ds = db.loadBiodataUserID(userID);
            if (ds.Tables[0].Rows.Count > 0)
            {
                string picture = ds.Tables[0].Rows[0]["ProfilePic"].ToString();
                if (picture != "")
                {
                    hidden_dpImage.Value = picture;
                    imgDisplay.Src = "profilepics/" + picture;
                    imgDisplay.Style.Add("display", "inline");
                }
                txtSurname.Text = ds.Tables[0].Rows[0]["Surname"].ToString();
                txtFirstName.Text = ds.Tables[0].Rows[0]["Firstname"].ToString();
                txtOtherName.Text = ds.Tables[0].Rows[0]["Othername"].ToString();
                dropdownGender.SelectedValue = ds.Tables[0].Rows[0]["Gender"].ToString();
                string dob = ds.Tables[0].Rows[0]["DOB"].ToString();
                //SPLIE AND ASSIGN

                string[] splitter = dob.Split('-');
                if (splitter.Length > 0)
                {
                    dropdownDay.SelectedValue = splitter[2];
                    dropdownMonth.SelectedValue = splitter[1];
                    dropdownyears.SelectedValue = splitter[0];
                }

                txtPhonenumber.Value = ds.Tables[0].Rows[0]["Phonenumber"].ToString();
                txtEmail.Text = ds.Tables[0].Rows[0]["Email"].ToString();
                txtHomeaddress.Text = ds.Tables[0].Rows[0]["Address"].ToString();


                if (dropdownSto.Items.Count == 1)
                {
                    getstates();
                }
                try
                {
                    dropdownSto.SelectedValue = ds.Tables[0].Rows[0]["state"].ToString();
                }
                catch (Exception exx)
                { }
                DataSet dstate = new DataSet();
                dstate = db.getAreas_States(Convert.ToInt16(ds.Tables[0].Rows[0]["state"].ToString()));
                if (dstate.Tables[0].Rows.Count > 0)
                {
                    dropdownLocalGovtarea.DataSource = dstate.Tables[0];
                    dropdownLocalGovtarea.DataTextField = "Area";
                    dropdownLocalGovtarea.DataValueField = "ID";

                    dropdownLocalGovtarea.DataBind();
                }

                dropdownLocalGovtarea.SelectedValue = ds.Tables[0].Rows[0]["LocalGovtArea"].ToString();

            }
        }
        else if (colName == "HasOlevelResult")
        {
            loadSubjectandGrades();
            ds = db.loadOlevelDataUserID_fs1(userID);
            if (ds.Tables[0].Rows.Count > 0)
            {


                dropdownExam.SelectedValue = ds.Tables[0].Rows[0]["Examtype"].ToString();
                dropdownExamMonth.SelectedValue = ds.Tables[0].Rows[0]["Exammonth"].ToString();
                dropdownExamYear.SelectedValue = ds.Tables[0].Rows[0]["ExamYear"].ToString();
                txtExamNum.Text = ds.Tables[0].Rows[0]["Examnumber"].ToString();


                dropdownOlevelSub1.SelectedValue = ds.Tables[0].Rows[0]["Subject1"].ToString();
                dropdownolevelGrade1.SelectedValue = ds.Tables[0].Rows[0]["Grade1"].ToString();
                dropdownOlevelSub2.SelectedValue = ds.Tables[0].Rows[0]["Subject2"].ToString();
                dropdownGrade2.SelectedValue = ds.Tables[0].Rows[0]["Grade2"].ToString();
                dropdownolevelSub3.SelectedValue = ds.Tables[0].Rows[0]["Subject3"].ToString();
                dropdownGrade3.SelectedValue = ds.Tables[0].Rows[0]["Grade3"].ToString();
                dropdownOlvlSub4.SelectedValue = ds.Tables[0].Rows[0]["Subject4"].ToString();
                dropdownGrade4.SelectedValue = ds.Tables[0].Rows[0]["Grade4"].ToString();
                dropdownOlevelsub5.SelectedValue = ds.Tables[0].Rows[0]["Subject5"].ToString();
                dropdownGrade5.SelectedValue = ds.Tables[0].Rows[0]["Grade5"].ToString();
                dropdownOlevelSub6.SelectedValue = ds.Tables[0].Rows[0]["Subject6"].ToString();
                dropdownGrade6.SelectedValue = ds.Tables[0].Rows[0]["Grade6"].ToString();
                dropdownOlevelSub7.SelectedValue = ds.Tables[0].Rows[0]["Subject7"].ToString();
                dropdonGrade7.SelectedValue = ds.Tables[0].Rows[0]["Grade7"].ToString();
                dropdownolevelSub8.SelectedValue = ds.Tables[0].Rows[0]["Subject8"].ToString();
                dropdownGrade8.SelectedValue = ds.Tables[0].Rows[0]["Grade8"].ToString();
                dropdowOlevelSub9.SelectedValue = ds.Tables[0].Rows[0]["Subject9"].ToString();
                dropdownGrade9.SelectedValue = ds.Tables[0].Rows[0]["Grade9"].ToString();

            }
            ds = new DataSet();
            ds = db.loadOlevelDataUserID_fs2(userID);
            if (ds.Tables[0].Rows.Count > 0)
            {
                dropdownExamType2.SelectedValue = ds.Tables[0].Rows[0]["Examtype"].ToString();
                dropdownExamMonth2.SelectedValue = ds.Tables[0].Rows[0]["Exammonth"].ToString();
                dropdownListexamyear2.SelectedValue = ds.Tables[0].Rows[0]["ExamYear"].ToString();
                txtExamNum2.Text = ds.Tables[0].Rows[0]["Examnumber"].ToString();


                dropdownOlevelsubject1b.SelectedValue = ds.Tables[0].Rows[0]["Subject1"].ToString();
                dropdownListGrade2.SelectedValue = ds.Tables[0].Rows[0]["Grade1"].ToString();
                dropdownOlevelSub2b.SelectedValue = ds.Tables[0].Rows[0]["Subject2"].ToString();
                dropdownGrade2b.SelectedValue = ds.Tables[0].Rows[0]["Grade2"].ToString();
                dropdownolevelSub3b.SelectedValue = ds.Tables[0].Rows[0]["Subject3"].ToString();
                dropdownGrade3b.SelectedValue = ds.Tables[0].Rows[0]["Grade3"].ToString();
                dropdownOlvlSub4b.SelectedValue = ds.Tables[0].Rows[0]["Subject4"].ToString();
                dropdownGrade4b.SelectedValue = ds.Tables[0].Rows[0]["Grade4"].ToString();
                dropdownOlevelsub5b.SelectedValue = ds.Tables[0].Rows[0]["Subject5"].ToString();
                dropdownGrade5b.SelectedValue = ds.Tables[0].Rows[0]["Grade5"].ToString();
                dropdownOlevelSub6b.SelectedValue = ds.Tables[0].Rows[0]["Subject6"].ToString();
                dropdownGrade6b.SelectedValue = ds.Tables[0].Rows[0]["Grade6"].ToString();
                dropdownOlevelSub7b.SelectedValue = ds.Tables[0].Rows[0]["Subject7"].ToString();
                dropdonGrade7b.SelectedValue = ds.Tables[0].Rows[0]["Grade7"].ToString();
                dropdownolevelSub8b.SelectedValue = ds.Tables[0].Rows[0]["Subject8"].ToString();
                dropdownGrade8b.SelectedValue = ds.Tables[0].Rows[0]["Grade8"].ToString();
                dropdowOlevelSub9b.SelectedValue = ds.Tables[0].Rows[0]["Subject9"].ToString();
                dropdownGrade9b.SelectedValue = ds.Tables[0].Rows[0]["Grade9"].ToString();

            }
        }
        else if (colName == "HasPreviousRecord")
        {
            loadInstitutions();
            ds = db.loadPreviousAcademicRecordByUserID(userID);
            if (ds.Tables[0].Rows.Count > 0)
            {

                txtNdMetricNum.Text = ds.Tables[0].Rows[0]["ND_Matric_Number"].ToString();
                txtjaRegno_previous.Text = ds.Tables[0].Rows[0]["JAMBRegno"].ToString();
                dropdownJambExamYear_Previous.SelectedValue = ds.Tables[0].Rows[0]["JambExamyear"].ToString();
                txtJambFullName_previous.Text = ds.Tables[0].Rows[0]["JambFullName"].ToString();
                dropdwnJamIns_Previous.SelectedValue = ds.Tables[0].Rows[0]["InstitutionAttented"].ToString();
                txtJambCourseName_previous.Text = ds.Tables[0].Rows[0]["CourseName"].ToString();
                dropdownCourseType_Previous.Text = ds.Tables[0].Rows[0]["CourseType"].ToString();
                dropdownCourseGrade_Prvious.Text = ds.Tables[0].Rows[0]["CourseGrade"].ToString();
                dropdownyearCompleted_Previous.SelectedValue = ds.Tables[0].Rows[0]["YearCompleted"].ToString();
                string insStart = ds.Tables[0].Rows[0]["IndTrainingStart"].ToString();
                string[] splitter = insStart.Split('-');

                dropdownIndustrialtrainingStart.SelectedValue = splitter[0];
                dropdownIndustrialTrainingEndYear.SelectedValue = splitter[1];

                string[] splitter2 = ds.Tables[0].Rows[0]["IndTrainingEnd"].ToString().Split('-');

                dropdownIndustrialStarmonth2.SelectedValue = splitter2[0];
                dropdownIndustrialTrainingYearStart2.SelectedValue = splitter2[1];

            }
        }
        else if (colName == "HasCBTSchedule")
        {
            loadDates_CBT();

            ds = db.loadCbtScheduleUserID(userID);
            if (ds.Tables[0].Rows.Count > 0)
            {
                string dateTxt = ds.Tables[0].Rows[0]["ScheduleDate"].ToString();
                dropdownScheduleDate.SelectedItem.Text = dateTxt;
                dropdownTime.SelectedItem.Text = ds.Tables[0].Rows[0]["ScheduleTime"].ToString();
                //DataSet dm = db.getAllTimes_CBT(dateTxt, Convert.ToInt32(ViewState["programID"]));
                //if (dm.Tables[0].Rows.Count > 0)
                //{
                //    dropdownTime.DataSource = dm.Tables[0];
                //    dropdownTime.DataBind();
                //}
                string time = ds.Tables[0].Rows[0]["ScheduleTime"].ToString();
                //string timeID = ds.Tables[0].Rows[0]["timeID"].ToString();
                //dropdownTime.SelectedValue = timeID;
                labelScheduleTxt.Text = dateTxt + ", " + time;
                labelCbtUser.Text = ds.Tables[0].Rows[0]["CbtUserName"].ToString();
                lblCbtPassword.Text = ds.Tables[0].Rows[0]["CbtPassword"].ToString();

                dropdownTime.Enabled = false;
                RequiredFieldValidator87.Enabled = false;
                RequiredFieldValidator76.Enabled = false;
                dropdownScheduleDate.Enabled = false;
            }
        }

    }
    public void loadSubjectandGrades()
    {
        DatabaseFunctions db = new DatabaseFunctions();
        DataSet ds = new DataSet();
        ds = db.getSubjects();
        if (ds.Tables[0].Rows.Count > 0)
        {
            dropdownOlevelSub1.DataSource = ds.Tables[0];
            dropdownOlevelSub1.DataBind();

            dropdownOlevelSub2.DataSource = ds.Tables[0];
            dropdownOlevelSub2.DataBind();

            dropdownolevelSub3.DataSource = ds.Tables[0];
            dropdownolevelSub3.DataBind();

            dropdownOlvlSub4.DataSource = ds.Tables[0];
            dropdownOlvlSub4.DataBind();

            dropdownOlevelsub5.DataSource = ds.Tables[0];
            dropdownOlevelsub5.DataBind();

            dropdownOlevelSub6.DataSource = ds.Tables[0];
            dropdownOlevelSub6.DataBind();

            dropdownOlevelSub7.DataSource = ds.Tables[0];
            dropdownOlevelSub7.DataBind();

            dropdownolevelSub8.DataSource = ds.Tables[0];
            dropdownolevelSub8.DataBind();

            dropdowOlevelSub9.DataSource = ds.Tables[0];
            dropdowOlevelSub9.DataBind();

            dropdownOlevelsubject1b.DataSource = ds.Tables[0];
            dropdownOlevelsubject1b.DataBind();


            dropdownOlevelSub2b.DataSource = ds.Tables[0];
            dropdownOlevelSub2b.DataBind();

            dropdownolevelSub3b.DataSource = ds.Tables[0];
            dropdownolevelSub3b.DataBind();

            dropdownOlvlSub4b.DataSource = ds.Tables[0];
            dropdownOlvlSub4b.DataBind();

            dropdownOlevelsub5b.DataSource = ds.Tables[0];
            dropdownOlevelsub5b.DataBind();

            dropdownOlevelSub6b.DataSource = ds.Tables[0];
            dropdownOlevelSub6b.DataBind();

            dropdownOlevelSub7b.DataSource = ds.Tables[0];
            dropdownOlevelSub7b.DataBind();

            dropdownolevelSub8b.DataSource = ds.Tables[0];
            dropdownolevelSub8b.DataBind();

            dropdowOlevelSub9b.DataSource = ds.Tables[0];
            dropdowOlevelSub9b.DataBind();
        }

    }
    protected void dropdownTime_SelectedIndexChanged(object sender, EventArgs e)
    {
        string dateTxt = dropdownScheduleDate.SelectedItem.Text.ToString();
        DataSet ds = new DataSet();
        DatabaseFunctions db = new DatabaseFunctions();
        ds = db.getSingleTimes_CBT(dateTxt, Convert.ToInt32(ViewState["programID"]), dropdownTime.SelectedItem.Text.ToString());

        if (ds.Tables[0].Rows.Count > 0)
        {
            //GET INGO ...
            string time = ds.Tables[0].Rows[0]["ScheduleTime"].ToString();
            int capacity = Convert.ToInt16(ds.Tables[0].Rows[0]["Capacity"].ToString());
            int Usedcapacity = Convert.ToInt16(ds.Tables[0].Rows[0]["Used"].ToString());

            int available = 0;
            available = capacity - Usedcapacity;
            if (available > 0)
            {
                labelScheduleTxt.Text = dateTxt + ", " + time + " (" + available + " available)";
                lblError.Visible = false;
                Random generator = new Random();
                if (lblCbtPassword.Text == "")
                {
                    int r = generator.Next(1000, 9999);
                    lblCbtPassword.Text = r.ToString();
                }
            }
            else
            {
                lblCbtPassword.Text = "";
                labelScheduleTxt.Text = "";
                lblError.Text = "No more space available , please choose another slot.";
                lblError.Visible = true;
            }
        }

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string pageName = Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath);
        
        if (System.Web.HttpContext.Current.User != null)
        {
            loggedStatus = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            if (loggedStatus)
            {
                DatabaseFunctions d = new DatabaseFunctions();
                string UserID = Membership.GetUser().ProviderUserKey.ToString();
                StudentID = d.GetCandidateID(UserID);
                Page.Form.Attributes.Add("enctype", "multipart/form-data");
                if (!IsPostBack)
                {
                    DatabaseFunctions db = new DatabaseFunctions();

                    DataSet appStatus = db.getApplication_ID(Request.QueryString["ApplicationID"].ToString());
                    if (appStatus.Tables[0].Rows.Count > 0)
                    {
                        if (appStatus.Tables[0].Rows[0]["formfilled"].ToString() != "Yes")
                        {

                            int programID = 0;

                            DataSet ds = db.getProgramIDbyApplicationID(Convert.ToInt32(Request.QueryString["ApplicationID"].ToString()));
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                programID = Convert.ToInt16(ds.Tables[0].Rows[0]["programID"].ToString());
                                ViewState["programID"] = programID;

                                ViewState["formnum"] = (ds.Tables[0].Rows[0]["FormNumber"].ToString());
                                loadbirthDay_Dropdowns();

                                int JambForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasJambData"].ToString());  //1
                                int BioForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasBioDataSection"].ToString());//2
                                int OlevelForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasOlevelResult"].ToString());//3
                                int PreviousRecordForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasPreviousRecord"].ToString());//4
                                int CbtScheduleForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasCBTSchedule"].ToString());//5


                                int progressBarAlgo = 0;
                                if (JambForm == 1)
                                {
                                    progressBarAlgo = progressBarAlgo + 1;
                                }
                                if (BioForm == 1)
                                {
                                    progressBarAlgo = progressBarAlgo + 1;
                                }
                                if (OlevelForm == 1)
                                {
                                    progressBarAlgo = progressBarAlgo + 1;
                                }
                                if (PreviousRecordForm == 1)
                                {
                                    progressBarAlgo = progressBarAlgo + 1;
                                }
                                if (CbtScheduleForm == 1)
                                {
                                    progressBarAlgo = progressBarAlgo + 1;
                                }

                                int startingPercentage = 0;
                                if (progressBarAlgo > 0)
                                {
                                    startingPercentage = 100 / progressBarAlgo;
                                }
                                else { startingPercentage = 100; }

                                progressBar.InnerHtml = "<div aria-valuemax=\"100\" aria-valuemin=\"0\"  role=\"progressbar\" class=\"progress-bar progress-bar-striped active\" style=\"width: " + startingPercentage + "%;height:30px;font-size:30px;padding-top:5px\">" + startingPercentage + "%</div>";
                                ViewState["stepsIncrement"] = startingPercentage;
                                ViewState["progressValue"] = startingPercentage;


                                var dt = ds.Tables[0];



                                ViewState["panelInfo"] = dt;
                                ViewState["NextPanel"] = "";
                                ViewState["PreviousPanel"] = "";
                                ViewState["CurrentPanel"] = "";
                                ViewState["previousPanelName"] = "";
                                ViewState["FirstPanel"] = "";
                                ViewState["CurrentPanelName"] = "";

                                string validationGroup = string.Empty;
                                for (int c = 2; c < ds.Tables[0].Columns.Count; c++)
                                {
                                    if (ds.Tables[0].Rows[0][c].ToString() == "1")
                                    {
                                        string colName = ds.Tables[0].Columns[c].ColumnName.ToString();
                                        Panel paneltx = this.Master.FindControl("ContentPlaceHolder1").FindControl(colName) as Panel;
                                        if (paneltx != null)
                                        {
                                            if (ViewState["CurrentPanel"] == "")
                                            {
                                                if (colName == "HasJambData")
                                                {
                                                    validationGroup = "appForm";
                                                }
                                                else if (colName == "HasBioDataSection")
                                                {
                                                    validationGroup = "appForm_biodata";
                                                }
                                                else if (colName == "HasOlevelResult")
                                                {
                                                    validationGroup = "appForm_Olevel";
                                                }
                                                else if (colName == "HasPreviousRecord")
                                                {
                                                    validationGroup = "appPreviousRecord";
                                                }
                                                else if (colName == "HasCBTSchedule")
                                                {
                                                    validationGroup = "appCBT";
                                                }



                                                ViewState["previousPanelName"] = colName;
                                                ViewState["FirstPanel"] = colName;
                                                ViewState["CurrentPanelName"] = colName;
                                                paneltx.Visible = true;
                                                ViewState["CurrentPanel"] = c;

                                                loadTabsInfo(colName);

                                                btnSave.ValidationGroup = validationGroup;
                                                btnSave.Visible = true;
                                            }
                                            else
                                            {
                                                ViewState["NextPanel"] = c;
                                                btnNext.ValidationGroup = validationGroup;
                                                btnNext.Visible = true;
                                                break;
                                            }
                                        }


                                    }
                                }


                                lblCbtUsername.Text = ViewState["formnum"].ToString();





                                if (ViewState["NextPanel"] != "")
                                {
                                    btnNext.Visible = true;
                                    btnNext.ValidationGroup = validationGroup;
                                    btnPreview.Visible = false;
                                }
                                else
                                {
                                    btnSave.Visible = false;
                                    btnNext.Visible = false;
                                    btnPreview.ValidationGroup = validationGroup;
                                    btnPreview.Visible = true;
                                }
                            }



                            string imgD = hidden_dpImage.Value;
                            if (imgD != "")
                            {
                                imgDisplay.Src = "profilepics/" + imgD.ToString();
                                imgDisplay.Style.Add("display", "inline");
                            }
                        }
                        else
                        {
                            Response.Redirect("Profilepage.aspx");
                        }
                    }

                }

            }
            else
            {
                Response.Redirect("Login.aspx?ReturnUrl=" + pageName + ".aspx");
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string applicationID = Request.QueryString["ApplicationID"].ToString();

            //      ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alertNew('Application Submitted Successfully !','0');", true);

            DatabaseFunctions db = new DatabaseFunctions();
            db.updateApplicationStatus_Submit(Convert.ToInt32(applicationID));

            DataSet appData = db.getApplication_ID((applicationID));
            if (appData != null)
            {
                int programID = Convert.ToInt32(appData.Tables[0].Rows[0]["ProgramID"].ToString());
                DataSet pDate = db.getProgramByID(programID);
                if (pDate.Tables[0].Rows.Count > 0)
                {
                    int instantadmission = Convert.ToInt16(pDate.Tables[0].Rows[0]["InstantAdmission"].ToString());
                    if (instantadmission == 1)
                    {
                        string programName = appData.Tables[0].Rows[0]["programName"].ToString();
                        string CourseName = appData.Tables[0].Rows[0]["Course1"].ToString();
                        string campus = appData.Tables[0].Rows[0]["Campus"].ToString();
                        string regno = appData.Tables[0].Rows[0]["formnumber"].ToString();

                        db.insertInstantAdmissiondata(regno, programName, CourseName, campus);
                        //db.AssignAcceptanceFee()
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup2", "alertNew('You have been successfully awarded admission !','0');", true);
                        DatabaseFunctions d = new DatabaseFunctions();
                        d.AssignAcceptanceFee(StudentID, programID, 0);
                        ///// Generate acceptance fee and send a message. 
                        d.InsertIntoStudentInfoTableNew(programID, "ND1", StudentID, 0, 1, "0", DateTime.Now.Year.ToString());
                        int BatchID = d.GetBatchID(DateTime.Now.Year.ToString());
                        string matricno=DateTime.Now.Year+"-"+programName+"-"+StudentID;
                        d.InsertIntoAddmissionTableNew(programID, StudentID, 0, "Merit", matricno, BatchID);
                        double AcceptanceFee = d.GetAcceptanceFeeForProgram(programID);
                        ///// Update Admission Status to 1 . 
                        ///// Insert Values to StudentInfo_tbl and AddmissionList (New One) 

                        if(AcceptanceFee!=-1)
                        {
                            string Message = "Acceptence Fee Of " +AcceptanceFee+ " Has Been Assigned to You <br> Please Submit This Fees with in One Week";
                            d.SendMessage(StudentID, Message, "Acceptance Fee", 0);
                        }

                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alertNew('Application Submitted Successfully !','0');", true);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alertNew('Error Submiting Application!','1');", true);
        }
    }
    public void formPreview()
    {
        btnSave.Visible = false;
        btnNext.Visible = false;
        btnPrevious.Visible = false;
        btnPreview.Visible = false;

        DataSet ds = new DataSet();
        DatabaseFunctions db = new DatabaseFunctions();

        ds = db.getProgramIDbyApplicationID(Convert.ToInt32(Request.QueryString["ApplicationID"].ToString()));
        if (ds.Tables[0].Rows.Count > 0)
        {
            int JambForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasJambData"].ToString());  //1
            int BioForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasBioDataSection"].ToString());//2
            int OlevelForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasOlevelResult"].ToString());//3
            int PreviousRecordForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasPreviousRecord"].ToString());//4
            int CbtScheduleForm = Convert.ToInt16(ds.Tables[0].Rows[0]["HasCBTSchedule"].ToString());//5

            if (OlevelForm == 0)
            {
                HasOlevelResult.Visible = false;
            }
            if (PreviousRecordForm == 0)
            {
                panelpreview_PreviousRecord.Visible = false;
            }
            if (CbtScheduleForm == 0)
            {
                HasCBTSchedule.Visible = false;
            }

        }

        string previousColName = ViewState["CurrentPanelName"].ToString();
        Panel panelprev = this.Master.FindControl("ContentPlaceHolder1").FindControl(previousColName) as Panel;
        if (panelprev != null)
        {
            panelprev.Visible = false;
        }

        panelPreview.Visible = true;


        ds = new DataSet();


        ds = db.getAlluserRelatedInfo((Membership.GetUser().ProviderUserKey.ToString()));
        if (ds.Tables[0].Rows.Count > 0)
        {
            string programName = string.Empty;
            string img = ds.Tables[0].Rows[0]["profilepic"].ToString();
            string course = string.Empty;

            if (img != "")
            {
                imgDp.Src = "profilepics/" + img.ToString(); ;
                imgDp.Visible = true;

            }
            else
            {
                imgDp.Visible = false;
            }


            DataSet pgName = db.getProgramByID(Convert.ToInt32(ViewState["programID"]));
            if (pgName.Tables[0].Rows.Count > 0)
            {
                programName = pgName.Tables[0].Rows[0]["ProgramName"].ToString();
            }



            lblSuname.Text = ds.Tables[0].Rows[0]["surname"].ToString();
            lblFname.Text = ds.Tables[0].Rows[0]["firstname"].ToString();
            lblOtherName.Text = ds.Tables[0].Rows[0]["othername"].ToString();

            lblGender.Text = ds.Tables[0].Rows[0]["gender"].ToString();
            lblPhonenum.Text = ds.Tables[0].Rows[0]["phonenumber"].ToString();

            lblProgram.Text = programName;
            lblCourse.Text = db.getApplication_Courses(Convert.ToInt32(ViewState["programID"]), Convert.ToInt32(Request.QueryString["ApplicationID"]));
            lblstateoforigin.Text = ds.Tables[0].Rows[0]["statenew"].ToString();
            lblLocalGotArea.Text = ds.Tables[0].Rows[0]["govtnew"].ToString();

            lblJambRegno.Text = ds.Tables[0].Rows[0]["JAMBRegno"].ToString();
            lblJambExamyear.Text = ds.Tables[0].Rows[0]["JambExamyear"].ToString();
            lblJambFullName.Text = ds.Tables[0].Rows[0]["JambFullName"].ToString();
            lblInstitutionAttended.Text = ds.Tables[0].Rows[0]["institutionNew"].ToString();
            lblCourseName.Text = ds.Tables[0].Rows[0]["CourseName"].ToString();
            courseType.Text = ds.Tables[0].Rows[0]["CourseType"].ToString();
            lblCourseGrade.Text = ds.Tables[0].Rows[0]["CourseGrade"].ToString();
            yearCompleted.Text = ds.Tables[0].Rows[0]["YearCompleted"].ToString();

            lblIndustrialStart.Text = ds.Tables[0].Rows[0]["IndTrainingStart"].ToString();
            lblIndustrialEnd.Text = ds.Tables[0].Rows[0]["IndTrainingEnd"].ToString();

            lblCbtSchedule.Text = ds.Tables[0].Rows[0]["ScheduleDate"].ToString() + ", " + ds.Tables[0].Rows[0]["ScheduleTime"].ToString();
            labelCbtUser.Text = ds.Tables[0].Rows[0]["CbtUserName"].ToString();
            lblCbtPass.Text = ds.Tables[0].Rows[0]["CbtPassword"].ToString();

            lblRegistrationNum.Text = ViewState["formnum"].ToString(); ;

        }
    }