protected void autoLogin()
        {
            mySqlConnector mySqlconn = new mySqlConnector();
            if (mySqlconn.isInitialized())
            {
                responseText.Visible = true;
                if (mySqlconn.login("*****@*****.**", "testing"))
                {
                    //validated, so write user session info
                    Session["firstname"] = mySqlconn.UserObj.FirstName;
                    Session["lastName"] = mySqlconn.UserObj.LastName;
                    Session["emailAddress"] = mySqlconn.UserObj.Email;
                    Session["isConsignor"] = mySqlconn.UserObj.isConsignor;
                    Session["isAdmin"] = mySqlconn.UserObj.isAdmin;
                    Session["userId"] = mySqlconn.UserObj.UserId;
                    Session["isLoggedIn"] = true;

                    //close connection
                    mySqlconn.deInitialize();

                    redirectUser();
                }
                else
                {
                    //displayResponseMessage(true, "Email & password combination are incorrect.  <br/>Please try again.");
                    displayResponseMessage(true, mySqlconn.connErrMsg);
                }
            }
            else
            {
                string whatGives = mySqlconn.testConnection();
                displayResponseMessage(true, "Database Connection Failure: " + whatGives);
            }
        }
        protected void verifyConsignor(string consignorEmail, string consignorID, string adminID)
        {
            string dbErr = "dbErr";

            mySqlConnector mySqlConn = new mySqlConnector();
            if (mySqlConn.isInitialized())
            {
                if (mySqlConn.callApproveConsignor(consignorEmail, consignorID, adminID))
                {
                    mySqlConn.deInitialize();
                    dbErr = "";
                }
            }

            Response.Redirect("~/Admin/Default.aspx?err=" + dbErr + "&f=approveconsignor&eid=" + consignorEmail);
        }
        protected void authenticateUser()
        {
            mySqlConnector mySqlconn = new mySqlConnector();
            if (mySqlconn.isInitialized())
            {
                if (mySqlconn.login(EmailAddress.Text, Password.Text, false))
                {
                    //validated, so write user session info
                    Session["firstname"] = mySqlconn.UserObj.FirstName;
                    Session["lastName"] = mySqlconn.UserObj.LastName;
                    Session["emailAddress"] = mySqlconn.UserObj.Email;
                    Session["isConsignor"] = mySqlconn.UserObj.isConsignor;
                    Session["isAdmin"] = mySqlconn.UserObj.isAdmin;
                    Session["userId"] = mySqlconn.UserObj.UserId;
                    Session["isLoggedIn"] = true;

                    //close connection
                    mySqlconn.deInitialize();
                    //success!
                    redirectUser();
                }
                else
                {//AUTHENTICATION HAS FAILED
                    //displayResponseMessage(true, "Email & password combination are incorrect.  <br/>Please try again.");
                    string errMsg = mySqlconn.connErrMsg;

                    if (errMsg.IndexOf("Please register") > 0)
                    {
                        displayResponseMessage(true, errMsg);
                    }
                    else
                    {
                        displayResponseMessage(true, mySqlconn.connErrMsg);
                        return;
                    }
                }
            }
            else
            {
                string whatGives = mySqlconn.testConnection();
                displayResponseMessage(true, "Database Connection Failure: " + whatGives);
            }
        }
        protected void saveInventoryForm(Dictionary<string, string> inventoryUploadForm)
        {
            saveErr = "";

            try
            {
                mySqlConnector mySqlConn = new mySqlConnector();
                if (mySqlConn.isInitialized())
                {
                    saveErr = mySqlConn.uploadInventory(inventoryUploadForm) ? "" : mySqlConn.connErrMsg;
                    if (saveErr != "")
                    {
                        displayFormErrors();
                    }
                    mySqlConn.deInitialize();
                }
                else
                {
                    if (mySqlConn.connErrMsg == "already registered")
                    {
                        saveErr = "Email Address already registered.";
                        //trigger reset password link
                    }
                    else
                    {
                        saveErr = "Error connecting to database. Please try again later.";
                    }
                    displayFormErrors();
                    return;
                }
            }
            catch (Exception ee)
            {
                saveErr = ee.Message.ToString();
                displayFormErrors();
                return;
            }

            //push user to success page and consignment agreement
               // Response.Redirect("~/Default.aspx");
        }
        protected void saveEditedUserInfo(Dictionary<string, string> formInfo)
        {
            saveErr = "";

            try
            {
                mySqlConnector mySqlConn = new mySqlConnector();
                if (mySqlConn.isInitialized())
                {
                    saveErr = mySqlConn.saveUserEditInfo(Email.Text, formInfo) ? "" : mySqlConn.connErrMsg;
                    if (saveErr != "")
                    {
                        displayEditErrors(saveErr);
                        mySqlConn.deInitialize();
                    }
                    else
                    {   //write new session values
                        Session["emailAddress"] = formInfo["Email"];
                        Session["firstname"] = formInfo["First Name"];
                        Session["lastName"] = formInfo["Last Name"];

                        mySqlConn.deInitialize();
                        resetPage("Your Information has been updated!");
                    }
                }
                else
                {
                    displayEditErrors(mySqlConn.connErrMsg);
                }
            }
            catch (Exception ee)
            {
                displayEditErrors(ee.Message.ToString());
            }
        }
        protected void showConsignorsPanel()
        {
            string errMsg = string.Empty;

            mySqlConnector mySqlConn = new mySqlConnector();

            if (mySqlConn.isInitialized())
            {
                BoundField eventTitle = new BoundField();
                eventTitle.ReadOnly = true;
                eventTitle.HeaderText = "Event";
                eventTitle.DataField = "eventtitle";
                //eventTitle.SortExpression = "eventtitle";
                gvExportList.Columns.Add(eventTitle);

                BoundField venue = new BoundField();
                venue.ReadOnly = true;
                venue.HeaderText = "Venue";
                venue.DataField = "venue";
                //venue.SortExpression = "venue";
                gvExportList.Columns.Add(venue);

                BoundField eventDate = new BoundField();
                eventDate.ReadOnly = true;
                eventDate.HeaderText = "Date";
                eventDate.DataField = "eventdate";
                //eventDate.SortExpression = "eventdate";
                gvExportList.Columns.Add(eventDate);

                BoundField eventTime = new BoundField();
                eventTime.ReadOnly = true;
                eventTime.HeaderText = "Time";
                eventTime.DataField = "eventtime";
            //	eventTime.SortExpression = "eventtime";
                gvExportList.Columns.Add(eventTime);

                BoundField qty = new BoundField();
                qty.ReadOnly = true;
                qty.HeaderText = "Qty";
                qty.DataField = "quantity";
                //qty.SortExpression = "quantity";
                gvExportList.Columns.Add(qty);

                BoundField sec = new BoundField();
                sec.ReadOnly = true;
                sec.HeaderText = "Section";
                sec.DataField = "section";
                //sec.SortExpression = "section";
                gvExportList.Columns.Add(sec);

                BoundField seatRow = new BoundField();
                seatRow.ReadOnly = true;
                seatRow.HeaderText = "Row";
                seatRow.DataField = "seatrow";
                //seatRow.SortExpression = "seatrow";
                gvExportList.Columns.Add(seatRow);

                BoundField seatFrom = new BoundField();
                seatFrom.ReadOnly = true;
                seatFrom.HeaderText = "From";
                seatFrom.DataField = "seatfrom";
                //seatFrom.SortExpression = "seatfrom";
                gvExportList.Columns.Add(seatFrom);

                BoundField seatThru = new BoundField();
                seatThru.ReadOnly = true;
                seatThru.HeaderText = "Thru";
                seatThru.DataField = "seatthru";
                //seatThru.SortExpression = "seatthru";
                gvExportList.Columns.Add(seatThru);

                BoundField cost = new BoundField();
                cost.ReadOnly = true;
                cost.HeaderText = "Price";
                cost.DataField = "cost";
                //cost.SortExpression = "cost";
                gvExportList.Columns.Add(cost);

                BoundField cNotes = new BoundField();
                cNotes.ReadOnly = true;
                cNotes.HeaderText = "Notes";
                cNotes.DataField = "consignornotes";
                //cNotes.SortExpression = "consignornotes";
                gvExportList.Columns.Add(cNotes);

                //now make call to database for rows
                if (mySqlConn.getExportList(Convert.ToInt16(Session["userId"]), true))
                {
                    gvExportList.DataSource = null;
                    gvExportList.Dispose();
                    gvExportList.DataSource = mySqlConn.ds;
                    gvExportList.DataBind();
                }
                else
                {
                    noExports.Text = mySqlConn.connErrMsg;
                    noExports.Visible = true;
                }
            }
            else
            {
                errMsg = "db connection error!";
                displayMySqlConnErr(errMsg);
            }

            mySqlConn.deInitialize();

            consignorsPanel.Visible = true;
        }
        protected void showPendingInventoryExports()
        {
            string errMsg = string.Empty;

            mySqlConnector mySqlConn = new mySqlConnector();

            if (mySqlConn.isInitialized())
            {
                if (mySqlConn.getExportList())
                {
                    GVExportList_Clear();

                    if (gvExportList.Columns.Count < 1)
                    {

                        BoundField userId = new BoundField();
                        userId.ReadOnly = true;
                        userId.HeaderText = "UserId";
                        userId.DataField = "emailaddress";
                        //userId.SortExpression = "emailaddress";
                        gvExportList.Columns.Add(userId);

                        BoundField eventTitle = new BoundField();
                        eventTitle.ReadOnly = true;
                        eventTitle.HeaderText = "Event";
                        eventTitle.DataField = "eventtitle";
                        //eventTitle.SortExpression = "eventtitle";
                        gvExportList.Columns.Add(eventTitle);

                        BoundField venue = new BoundField();
                        venue.ReadOnly = true;
                        venue.HeaderText = "Venue";
                        venue.DataField = "venue";
                        //venue.SortExpression = "venue";
                        gvExportList.Columns.Add(venue);

                        BoundField eventDate = new BoundField();
                        eventDate.ReadOnly = true;
                        eventDate.HeaderText = "Date";
                        eventDate.DataField = "eventdate";
                        //eventDate.SortExpression = "eventdate";
                        gvExportList.Columns.Add(eventDate);

                        BoundField eventTime = new BoundField();
                        eventTime.ReadOnly = true;
                        eventTime.HeaderText = "Time";
                        eventTime.DataField = "eventtime";
                        //	eventTime.SortExpression = "eventtime";
                        gvExportList.Columns.Add(eventTime);

                        BoundField qty = new BoundField();
                        qty.ReadOnly = true;
                        qty.HeaderText = "Qty";
                        qty.DataField = "quantity";
                        //qty.SortExpression = "quantity";
                        gvExportList.Columns.Add(qty);

                        BoundField sec = new BoundField();
                        sec.ReadOnly = true;
                        sec.HeaderText = "Section";
                        sec.DataField = "section";
                        //sec.SortExpression = "section";
                        gvExportList.Columns.Add(sec);

                        BoundField seatRow = new BoundField();
                        seatRow.ReadOnly = true;
                        seatRow.HeaderText = "Row";
                        seatRow.DataField = "seatrow";
                        //seatRow.SortExpression = "seatrow";
                        gvExportList.Columns.Add(seatRow);

                        BoundField seatFrom = new BoundField();
                        seatFrom.ReadOnly = true;
                        seatFrom.HeaderText = "From";
                        seatFrom.DataField = "seatfrom";
                        //seatFrom.SortExpression = "seatfrom";
                        gvExportList.Columns.Add(seatFrom);

                        BoundField seatThru = new BoundField();
                        seatThru.ReadOnly = true;
                        seatThru.HeaderText = "Thru";
                        seatThru.DataField = "seatthru";
                        //seatThru.SortExpression = "seatthru";
                        gvExportList.Columns.Add(seatThru);

                        BoundField cost = new BoundField();
                        cost.ReadOnly = true;
                        cost.HeaderText = "Price";
                        cost.DataField = "cost";
                        //cost.SortExpression = "cost";
                        gvExportList.Columns.Add(cost);

                        BoundField cNotes = new BoundField();
                        cNotes.ReadOnly = true;
                        cNotes.HeaderText = "Notes";
                        cNotes.DataField = "consignornotes";
                        //cNotes.SortExpression = "consignornotes";
                        gvExportList.Columns.Add(cNotes);

                        gvExportList.DataSource = mySqlConn.ds;
                        gvExportList.DataBind();
                    }
                }
                else
                {
                    GVExportList_Clear();
                    noExports.Text = mySqlConn.connErrMsg;
                    noExports.Visible = true;
                }
            }
            else
            {
                errMsg = "db connection error!";
                displayFormErrors(errMsg);
            }

            mySqlConn.deInitialize();
        }
        protected void getLastExportTime()
        {
            string lastExport = String.Empty;
            mySqlConnector mySqlConn = new mySqlConnector();

            if (mySqlConn.isInitialized())
            {
                lastExport = mySqlConn.getLastInventoryExport();
            }
            else
            {
                lastExport = "db connection error!";
            }
            mySqlConn.deInitialize();
            lastExported.Text = lastExport;
        }
        protected void checkForConsignmentApprovals()
        {
            string errMsg = string.Empty;
            string statusMsg = string.Empty;
            string cEmailID = (!String.IsNullOrEmpty(Request.QueryString["eid"]))? Request.QueryString["eid"].ToString() : "";
            string dbErr =
            (!String.IsNullOrEmpty(Request.QueryString["dbErr"]))? Request.QueryString["dbErr"].ToString() : "";
            string funkShun =
            (!String.IsNullOrEmpty(Request.QueryString["f"]))? Request.QueryString["f"].ToString() : "";

            if (funkShun == "approveconsignor")
            {
                if (dbErr == "")
                {
                    statusMsg = "Consignor [ " + cEmailID + " ] approved.";
                    lblStatusMsg.CssClass = "statusMsg";
                }
                else
                {
                    statusMsg = "DB error on Consignor Approval: [ " + cEmailID + " ]. Please try again.";
                    lblStatusMsg.CssClass = "errMsg";
                }

                lblStatusMsg.Visible = true;
                lblStatusMsg.Text = statusMsg;
            }

            mySqlConnector mySqlConn = new mySqlConnector();

            if (mySqlConn.isInitialized())
            {
                //--	now check db for pending approvals
                if (mySqlConn.checkForPending_C_Approvals())
                {
                    HyperLinkField userId = new HyperLinkField();
                    userId.HeaderText = "UserId";
                    userId.DataTextField = "emailaddress";
                    userId.DataNavigateUrlFields = new string[] { "emailaddress", "userId" };
                    userId.DataNavigateUrlFormatString = "~/admin/approveConsignor.aspx?eid={0}&uid={1}&aid=" + Session["emailAddress"].ToString();
                    //userId.SortExpression = "emailaddress";
                    gvConsingorApproveList.Columns.Add(userId);

                    BoundField firstname = new BoundField();
                    firstname.ReadOnly = true;
                    firstname.HeaderText = "First";
                    firstname.DataField = "firstname";
                    //firstname.SortExpression = "firstname";
                    gvConsingorApproveList.Columns.Add(firstname);

                    BoundField lastname = new BoundField();
                    lastname.ReadOnly = true;
                    lastname.HeaderText = "Last";
                    lastname.DataField = "lastname";
                    //lastname.SortExpression = "lastname";
                    gvConsingorApproveList.Columns.Add(lastname);

                    BoundField address1 = new BoundField();
                    address1.ReadOnly = true;
                    address1.HeaderText = "Address";
                    address1.DataField = "address1";
                    //address1.SortExpression = "address1";
                    gvConsingorApproveList.Columns.Add(address1);

                    BoundField address2 = new BoundField();
                    address2.ReadOnly = true;
                    address2.HeaderText = "Address2";
                    address2.DataField = "address2";
                    //	address2.SortExpression = "address2";
                    gvConsingorApproveList.Columns.Add(address2);

                    BoundField city = new BoundField();
                    city.ReadOnly = true;
                    city.HeaderText = "City";
                    city.DataField = "city";
                    //city.SortExpression = "city";
                    gvConsingorApproveList.Columns.Add(city);

                    BoundField state = new BoundField();
                    state.ReadOnly = true;
                    state.HeaderText = "State";
                    state.DataField = "state";
                    //state.SortExpression = "state";
                    gvConsingorApproveList.Columns.Add(state);

                    BoundField zip = new BoundField();
                    zip.ReadOnly = true;
                    zip.HeaderText = "Zip";
                    zip.DataField = "zip";
                    //	zip.SortExpression = "zip";
                    gvConsingorApproveList.Columns.Add(zip);

                    BoundField phoneNumber = new BoundField();
                    phoneNumber.ReadOnly = true;
                    phoneNumber.HeaderText = "Phone";
                    phoneNumber.DataField = "phoneNumber";
                    //phoneNumber.SortExpression = "phoneNumber";
                    gvConsingorApproveList.Columns.Add(phoneNumber);

                    BoundField createDate = new BoundField();
                    createDate.ReadOnly = true;
                    createDate.HeaderText = "__date";
                    createDate.DataField = "created";
                    //phoneNumber.SortExpression = "phoneNumber";
                    gvConsingorApproveList.Columns.Add(createDate);

                    gvConsingorApproveList.DataSource = null;
                    gvConsingorApproveList.Dispose();
                    gvConsingorApproveList.DataSource = mySqlConn.ds;
                    gvConsingorApproveList.DataBind();
                    consingorApproveList.Visible = true;
                }
                else
                {
                    noConsignors.Text = mySqlConn.connErrMsg;
                    noConsignors.Visible = true;
                }
            }
            else
            {
                errMsg = "db connection error!";
                displayFormErrors(errMsg);
            }

            mySqlConn.deInitialize();
        }
        protected void exportBtn_click(object sender, EventArgs e)
        {
            //ten fields for export
            string[] columnHeaderList = new string[]{"Event, Venue, EventDate, EventTime, Quantity, Section, Row, SeatFrom, SeatThru, Notes, Cost"};

            List<List<string>> exportList;

            mySqlConnector mySqlConn = new mySqlConnector();

            if (mySqlConn.isInitialized())
            {
                exportList = mySqlConn.exportLatestUploads();

                if (exportList.Count < 1)
                {
                    noExports.Text = "Nothing to export.";
                    noExports.Visible = true;
                }
                else
                {
                    List<string> exportItem = exportList[0];
                    if (exportItem[0].IndexOf("Error:") > -1)
                    {
                        displayFormErrors(exportList[0].ToString());
                    }
                    else
                    {
                        mySqlConn.deInitialize();
                        showPendingInventoryExports();
                        CSVExporter csvExport = new CSVExporter(exportList, columnHeaderList);
                    }

                }
                mySqlConn.deInitialize();
            }
            else
            {
                displayFormErrors("Error connecting to database!");
            }
        }
        protected void saveUserInfo(Dictionary<string, string> formInfo)
        {
            saveErr = "";

            try
            {
                mySqlConnector mySqlConn = new mySqlConnector();
                if (mySqlConn.isInitialized() && mySqlConn.registerUser(formInfo))
                {
                    saveErr = mySqlConn.login(Email.Text, Password.Text) ? "" : mySqlConn.connErrMsg;
                    if (saveErr != "")
                    {
                        displayFormErrors();
                        mySqlConn.deInitialize();
                    }
                    else
                    {   //write session out for sng
                        Session["emailAddress"] = Email.Text;
                        Session["firstName"] = FirstName.Text;
                        Session["lastName"] = LastName.Text;
                        Session["isLoggedIn"] = true;
                        Session["userId"] = mySqlConn.UserObj.UserId;

                        //push user to success page and consignment agreement
                        mySqlConn.deInitialize();
                        Response.Redirect("RegisterSuccess.aspx");
                    }
                }
                else
                {
                    if (mySqlConn.connErrMsg == "already registered")
                    {
                        saveErr = "Email Address already registered.";
                    }
                    else
                    {
                        //TODO: refactor this code to produce a more specific error that can be reported??
                        saveErr = mySqlConn.connErrMsg;
                    }
                    displayFormErrors();
                }
            }
            catch (Exception ee)
            {
                saveErr = ee.Message.ToString();
                displayFormErrors();
            }
        }