protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                conn = DB_Connect.GetConnection();
                conn.Open();

                /*if (conn.State.ToString() == "Closed")
                 * {
                 *  conn.Open();
                 * }*/
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.CommandText = "SPInsertTopic";

                newCmd.CommandType = CommandType.StoredProcedure;

                // newCmd.Parameters.AddWithValue("@id", Convert.ToInt32(txtTID.Text));
                newCmd.Parameters.AddWithValue("@name", txtTopic.Text);
                newCmd.ExecuteNonQuery();

                System.Threading.Thread.Sleep(3000);
                LabelET.Visible = true;

                /*string javaScript =
                 * "<script language=JavaScript>\n" +
                 * "alert('Record Added Succesfully!...');\n" +
                 * "</script>";
                 *
                 * RegisterStartupScript("btnSubmit_ClickScript", javaScript);
                 */
            }
            catch (NullReferenceException) { }
            conn.Close();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            SqlConnection conn = DB_Connect.GetConnection();

            conn.Open();
            /////////////////////////////

            string        query = "Select  * from Quotations Where QuoteID=" + int.Parse(this.TextBox1.Text.ToString());
            SqlCommand    cmd   = new SqlCommand(query, conn);
            SqlDataReader dr    = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    this.txtQID.Text = dr.GetInt32(0).ToString();

                    this.DDLBooks.Text   = dr.GetString(1);
                    this.DDLAuthors.Text = dr.GetString(2);
                    this.txtPNo.Text     = dr.GetString(3);
                    this.txtQuote.Text   = dr.GetString(4);
                }
            }
            else
            {
                LabelSQ.Visible = true;
            }
            ////////////////////////////
            conn.Close();
        }
Exemple #3
0
        /**
         * CONSTRUCTOR
         **/
        public Q7(int level, string user_email)
        {
            db = new DB_Connect();
            //setting level
            this.Level = level;
            //setting question before we find x.
            this.questionBeforeSetting = "Which artist was born in the same place as the artist X";
            //setting user email.
            this.User_email = user_email;

            //a goto jump point.
AA:
            // setting the name and location of artist x which the question is about.
            getFirstArtistNameAndLocation();
            // building the question.
            this.Question = buildQuestion();
            // building the wrong answers.
            this.WrongAnswers = buildAnswers();
            // building the true answer.
            this.TrueAnswer = buildTrueAnswer();
            if ((TrueAnswer == null) || (TrueAnswer == FirstArtistName))
            {
                goto AA;
            }
            // building the clue.
            this.Clue = buildClue();
            if (Clue == null)
            {
                goto AA;
            }
        }
        public View()
        {
            InitializeComponent();
            DB_Connect conn = DB_Connect.Instance;

            loadComboBoxItems();
        }
Exemple #5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                String        bookidSearch = this.TextBox1.Text.ToString();
                SqlConnection conn         = DB_Connect.GetConnection();
                conn.Open();

                string     query  = "SPUpdateBook";
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.Connection = conn;
                newCmd.Parameters.AddWithValue("@bid", int.Parse(this.TextBox1.Text.ToString()));
                newCmd.Parameters.AddWithValue("@title", this.txtBTitle.Text);
                newCmd.Parameters.AddWithValue("@topic", this.DDLTopic.SelectedValue);
                newCmd.Parameters.AddWithValue("@pname", this.txtBPName.Text);
                newCmd.Parameters.AddWithValue("@ctype", this.txtBCType.Text);
                newCmd.Parameters.AddWithValue("@notes", this.txtNotes.Text);
                newCmd.Parameters.AddWithValue("@pprice", this.txtBPPrice.Text);
                newCmd.Parameters.AddWithValue("@author", this.DDLAuthor.SelectedValue);
                newCmd.Parameters.AddWithValue("@enum", this.txtBENumber.Text);
                newCmd.Parameters.AddWithValue("@cyear", this.txtBCYear.Text);
                newCmd.Parameters.AddWithValue("@dpur", this.txtBDPurchased.Text);
                newCmd.Parameters.AddWithValue("@page", this.txtBPages.Text);
                newCmd.Parameters.AddWithValue("@sno", this.txtBSNo.Text);
                // newCmd.Parameters.Add("@booktitleSearch", this.textBox1.Text);
                newCmd.CommandType = CommandType.StoredProcedure;
                newCmd.CommandText = query;
                newCmd.ExecuteNonQuery();
                System.Threading.Thread.Sleep(3000);
                LabelUB.Visible = true;
                conn.Close();
            }
            catch (Exception E) {}
        }
Exemple #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            // access.add_quotation(DDLBooks.SelectedValue, DDLAuthors.SelectedValue,txtPNo.Text,txtQuote.Text);
            try
            {
                conn = DB_Connect.GetConnection();
                conn.Open();
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.CommandText = "SPInsertQuotation";
                newCmd.CommandType = CommandType.StoredProcedure;
                newCmd.Parameters.AddWithValue("@book", DDLBooks.SelectedValue);
                newCmd.Parameters.AddWithValue("@author", DDLAuthors.SelectedValue);
                newCmd.Parameters.AddWithValue("@pno", txtPNo.Text);
                newCmd.Parameters.AddWithValue("@quote", txtQuote.Text);

                newCmd.ExecuteNonQuery();
                System.Threading.Thread.Sleep(3000);
                LabelMsg.Visible = true;

                /*string javaScript =
                 * "<script language=JavaScript>\n" +
                 * "alert('Record Added Succesfully!...');\n" +
                 * "</script>";
                 * RegisterStartupScript("Button1_ClickScript", javaScript);*/
            }
            catch (NullReferenceException) { }
            conn.Close();
        }
        public HighScoresWindow(bool gameFinished, string wonMoney)
        {
            db = new DB_Connect();
            InitializeComponent();
            if (gameFinished)
            {
                stackPanelGameFinish.Visibility = Visibility.Visible;
                moneyLbl.Content = wonMoney + " $";
            }
            userLbls = new List <Label>();
            userLbls.Add(lblUsr1);
            userLbls.Add(lblUsr2);
            userLbls.Add(lblUsr3);
            userLbls.Add(lblUsr4);
            userLbls.Add(lblUsr5);
            userLbls.Add(lblUsr6);
            userLbls.Add(lblUsr7);
            userLbls.Add(lblUsr8);
            userLbls.Add(lblUsr9);
            userLbls.Add(lblUsr10);

            scrLbls = new List <Label>();
            scrLbls.Add(lblScr1);
            scrLbls.Add(lblScr2);
            scrLbls.Add(lblScr3);
            scrLbls.Add(lblScr4);
            scrLbls.Add(lblScr5);
            scrLbls.Add(lblScr6);
            scrLbls.Add(lblScr7);
            scrLbls.Add(lblScr8);
            scrLbls.Add(lblScr9);
            scrLbls.Add(lblScr10);
            createHighScoreTable();
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                int           idtosearch = int.Parse(this.TextBox1.Text);
                SqlConnection conn       = DB_Connect.GetConnection();

                conn.Open();
                string     query  = "SPUpdateAuthor";
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.Connection = conn;
                newCmd.Parameters.AddWithValue("@aid", int.Parse(this.TextBox1.Text.ToString()));
                newCmd.Parameters.AddWithValue("@fname", this.txtFName.Text);
                newCmd.Parameters.AddWithValue("@lname", this.txtLName.Text);
                newCmd.Parameters.AddWithValue("@nat", this.txtNation.Text);
                newCmd.Parameters.AddWithValue("@bdate", this.txtBDate.Text);
                newCmd.Parameters.AddWithValue("@bplace", this.txtBPlace.Text);
                newCmd.Parameters.AddWithValue("@tloc", this.txtTLoc.Text);
                newCmd.Parameters.AddWithValue("@minf", this.txtMInf.Text);
                newCmd.Parameters.AddWithValue("@notes", this.txtNotes.Text);
                //newCmd.Parameters.Add("@idtosearch", int.Parse(this.textBox1.Text) );
                newCmd.CommandType = CommandType.StoredProcedure;
                newCmd.CommandText = query;
                newCmd.ExecuteNonQuery();
                System.Threading.Thread.Sleep(3000);
                LabelUA.Visible = true;

                conn.Close();
            }
            catch (NullReferenceException) { }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                int           qidtosearch = int.Parse(this.TextBox1.Text.ToString());
                SqlConnection conn        = DB_Connect.GetConnection();

                conn.Open();


                string     query  = "SPUpdateQuotation";
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.Connection = conn;
                newCmd.Parameters.AddWithValue("@qtid", int.Parse(this.TextBox1.Text));
                newCmd.Parameters.AddWithValue("@book", this.DDLBooks.SelectedValue);
                newCmd.Parameters.AddWithValue("@author", this.DDLAuthors.SelectedValue);
                newCmd.Parameters.AddWithValue("@pno", this.txtPNo.Text);
                newCmd.Parameters.AddWithValue("@quote", this.txtQuote.Text);

                // newCmd.Parameters.Add("@qidtosearch", int.Parse(this.textBox1.Text));
                newCmd.CommandType = CommandType.StoredProcedure;
                newCmd.CommandText = query;
                newCmd.ExecuteNonQuery();

                LabelUQ.Visible = true;
                conn.Close();
            }
            catch (NullReferenceException) {}
        }
Exemple #10
0
        /**
         * CONSTRUCTOR
         **/
        public Q8(int level, string user_email)
        {
            db = new DB_Connect();
            //setting level
            this.Level = level;
            //setting question before we find x.
            this.questionBeforeSetting = "Which two songs were released in the year X";
            //setting user email.
            this.User_email = user_email;
BB:
            // selecting a random year on which this question will be based.
            randomly_Select_Year();
            // building the question.
            this.Question = buildQuestion();
            // building the wrong answers.
            this.WrongAnswers = buildAnswers();
            // building the true answer.
            this.TrueAnswer = buildTrueAnswer();
            if (TrueAnswer == null)
            {
                goto BB;
            }
            // building the clue.
            this.clue = buildClue();
            if (clue == null)
            {
                goto BB;
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            SqlConnection conn = DB_Connect.GetConnection();

            conn.Open();
            /////////////////////////////

            string        query = "Select  * from Authors Where AuthorID=" + int.Parse(this.TextBox1.Text.ToString());
            SqlCommand    cmd   = new SqlCommand(query, conn);
            SqlDataReader dr    = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    this.txtAID.Text    = dr.GetInt32(0).ToString();
                    this.txtFName.Text  = dr.GetString(1);
                    this.txtLName.Text  = dr.GetString(2);
                    this.txtNation.Text = dr.GetString(3);
                    this.txtBDate.Text  = dr.GetString(4);
                    this.txtBPlace.Text = dr.GetString(5);
                    this.txtTLoc.Text   = dr.GetString(6);
                    this.txtMInf.Text   = dr.GetString(7);
                    this.txtNotes.Text  = dr.GetString(8);
                }
            }
            else
            {
                LabelSA.Visible = true;
            }
            ////////////////////////////
            conn.Close();
        }
Exemple #12
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                conn = DB_Connect.GetConnection();
                conn.Open();
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.CommandText = "SPInsertAuthor";
                newCmd.CommandType = CommandType.StoredProcedure;

                // newCmd.Parameters.AddWithValue("@aid", Convert.ToInt32(aid));
                newCmd.Parameters.AddWithValue("@fname", txtFName.Text);
                newCmd.Parameters.AddWithValue("@lname", txtLName.Text);
                newCmd.Parameters.AddWithValue("@nat", txtNation.Text);
                newCmd.Parameters.AddWithValue("@bdate", txtBDate.Text);
                newCmd.Parameters.AddWithValue("@bplace", txtBPlace.Text);
                newCmd.Parameters.AddWithValue("@tloc", txtTLoc.Text);
                newCmd.Parameters.AddWithValue("@minf", txtMInf.Text);
                newCmd.Parameters.AddWithValue("@notes", txtNotes.Text);

                newCmd.ExecuteNonQuery();
                System.Threading.Thread.Sleep(3000);
                LabelEA.Visible = true;

                conn.Close();

                /*  string javaScript =
                 * "<script language=JavaScript>\n" +
                 * "alert('Record Added Succesfully!...');\n" +
                 * "</script>";
                 *
                 * RegisterStartupScript("Button1_ClickScript", javaScript);*/
            }
            catch (NullReferenceException) { }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                int           SearchID = int.Parse(this.ddlTopic.SelectedValue.ToString());
                SqlConnection conn     = DB_Connect.GetConnection();
                conn.Open();
                ////////////////////////

                string     query  = "SpTopicUpdate";
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.Connection = conn;
                newCmd.Parameters.AddWithValue("@id", int.Parse(this.ddlTopic.SelectedValue.ToString()));
                newCmd.Parameters.AddWithValue("@name", this.txtTopic.Text);

                // newCmd.Parameters.Add("@SearchID", int.Parse(this.textBox1.Text));
                newCmd.CommandType = CommandType.StoredProcedure;
                newCmd.CommandText = query;
                newCmd.ExecuteNonQuery();

                LabelUT.Visible = true;
                //Response.Write("no of rows effected" + newCmd.ExecuteNonQuery().ToString());

                conn.Close();
            }


            catch (NullReferenceException)
            {}
        }
        public DataTable getDataTable()
        {
            try
            {
                System.Data.DataTable aTable = new System.Data.DataTable();
                conn = DB_Connect.GetConnection();
                conn.Open();

                SqlCommand sqlCmd = new SqlCommand("ViewQuotations", conn);
                sqlCmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter da = new SqlDataAdapter(sqlCmd);

                da.Fill(aTable);

                conn.Close();
                sqlCmd.Dispose();
                da.Dispose();

                return(aTable);
            }
            catch (Exception err)
            {
                //TextFileWriter.WriteToLog(err.Message);
                return(null);
            }
        }
 /// <summary>
 /// Initializes a new instance of the GameFlow class, receiving the email of the user that playing on it.
 /// </summary>
 /// <param name="mail">The mail of the user that playing.</param>
 public GameFlow(string mail)
 {
     //Sign for threads that the game finished.
     gameFinished    = false;
     db              = new DB_Connect();
     CurrentClue     = "";
     CurrentMoney    = 0;
     questionsList   = new Iquestion[15];
     this.user_email = mail;
     //Building two Questions.
     buildFirstTwoQuestions();
     //Activate The first Question.
     ActivateQuestion((Iquestion)questionsList[0]);
     //Thread for first level questions.
     new Thread(() =>
     {
         buildFirstLevel();
     }).Start();
     //Thread for second level questions.
     new Thread(() =>
     {
         //Building Second Level
         buildSecondLevel();
     }).Start();
     //Thread for third level questions.
     new Thread(() =>
     {
         buildThirdLevel();
     }).Start();
 }
Exemple #16
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                bool flag = false;
                conn = DB_Connect.GetConnection();
                conn.Open();
                string     query     = "Select Count(*) from Registration where Name = '" + txtUserName.Text + "'";
                SqlCommand userExist = new SqlCommand(query, conn);
                int        response  = Convert.ToInt32(userExist.ExecuteScalar().ToString());
                if (response == 1)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
                if (flag)
                {
                    Response.Write("Already Exist");
                }
                else
                {
                    flag = false;
                    string Query = "Insert Into Registration (Name,Gender,BirthDay,Country,Language,Email,Password,AlternateEmail,SecretQuestion,YourAnswer) Values ('" + txtUserName.Text + "','" + DDLGender.SelectedValue + "','" + txtBirthDate.Text + "','" + DDLCountry.SelectedValue + "','"
                                   + DDLLanguage.SelectedValue + "','" + txtEmail.Text + "','" + txtPassword.Text + "','" + txtAEmail.Text + "','" + DDLSecurityQuest.SelectedValue + "','" + txtYAns.Text + "')";
                    SqlCommand aCommand = new SqlCommand(Query, conn);

                    response = aCommand.ExecuteNonQuery();

                    LabelRU.Visible = true;
                    conn.Close();
                    aCommand.Dispose();

                    if (response == 0)
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        Response.Redirect("Login.aspx");
                    }
                    else
                    {
                        Response.Write("Wrong Something Try Again");
                    }
                }
            }
            catch (Exception err)
            {
                Response.Write(err.Message);
            }
        }
Exemple #17
0
 public Q2(int level1, string user_email1)
 {
     Level      = level1;
     User_email = user_email1;
     db         = new DB_Connect();
     Question   = buildQuestion();
     string[] answers = buildAnswers();
     Clue = buildClue();
 }
Exemple #18
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            bool flag = false;

            conn = DB_Connect.GetConnection();
            conn.Open();
            string     query     = "Select Count(*) from Registration where Name = '" + txtUN.Text + "'";
            SqlCommand userExist = new SqlCommand(query, conn);
            int        response  = Convert.ToInt32(userExist.ExecuteScalar().ToString());

            if (response == 1)
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
            if (flag)
            {
                flag  = false;
                query = "Select Password from Registration where Name = '" + txtUN.Text + "'";
                SqlCommand validatePass = new SqlCommand(query, conn);
                string     pass         = validatePass.ExecuteScalar().ToString();
                if (pass.Equals(txtPassword.Text))
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
                if (flag)
                {
                    Session["LoginName"] = txtUN.Text;
                    Session["Login"]     = true;

                    Application["AliveUsers"] = Convert.ToInt64(Application["AliveUsers"]) + 1;


                    Response.Redirect("Default.aspx");
                }
                else
                {
                    Label1.Visible = true;
                    Label1.Text    = "Invalid Password";
                    //Response.Write("Invalid Password");
                }
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "Invalid User Name";
                //Response.Write("Invalid User Name");
            }
        }
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxEmail.Text.Length == 0)
            {
                //errormessage.Text = "Enter an email.";
                textBoxEmail.Focus();
            }
            else if (!Regex.IsMatch(textBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
            {
                errormessage.Text = "Enter a valid email.";
                textBoxEmail.Select(0, textBoxEmail.Text.Length);
                textBoxEmail.Focus();
            }
            else
            {
                string name     = textBoxName.Text;
                string email    = textBoxEmail.Text;
                string password = passwordBox1.Password;
                if (passwordBox1.Password.Length == 0)
                {
                    errormessage.Text = "Enter password.";
                    passwordBox1.Focus();
                }
                else if (passwordBoxConfirm.Password.Length == 0)
                {
                    errormessage.Text = "Enter Confirm password.";
                    passwordBoxConfirm.Focus();
                }
                else if (passwordBox1.Password != passwordBoxConfirm.Password)
                {
                    errormessage.Text = "Confirm password must be same as password.";
                    passwordBoxConfirm.Focus();
                }
                else
                {
                    errormessage.Text = "";
                    DB_Connect db_connect = new DB_Connect();
                    bool       result     = db_connect.InsertNewUser(name, password, email);

                    if (result == true)
                    {
                        errormessage.Text = "Login succssfuly.";
                        // here we will want to save the user email and nickname in app.config/ settings .
                        Properties.Settings.Default["user_name"]  = name;
                        Properties.Settings.Default["user_email"] = email;
                        Properties.Settings.Default.Save();
                        Reset();
                        this.Close();
                    }
                    else
                    {
                        errormessage.Text = "Email alredy exists.";
                    }
                }
            }
        }
Exemple #20
0
 public Q5(int level, string user_email)
 {
     db              = new DB_Connect();
     this.Level      = level;
     this.Question   = "What is the name of the song released by <artist_name> in <year> ?";
     this.User_email = user_email;
     this.Question   = buildQuestion();
     this.Clue       = buildClue();
     this.buildAnswers();
     buildTrueAnswer();
 }
 public MainWindow()
 {
     InitializeComponent();
     try
     {
         connect = new DB_Connect();
     } catch
     {
         MessageBox.Show("Не удаётся подключиться к серверу, проверьте подключение к сети. Перезапустите программу", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #22
0
 public Q6(int level, string user_email)
 {
     db                = new DB_Connect();
     this.Level        = level;
     this.Question     = "When <artist_name> released the album <album_name> ?";
     this.Clue         = "At the same year that the song <song_name> of <artist_name> was released.";
     this.User_email   = user_email;
     this.Question     = buildQuestion();
     this.Clue         = buildClue();
     this.WrongAnswers = buildAnswers();
     this.TrueAnswer   = buildTrueAnswer();
 }
Exemple #23
0
 public createAppoinment()
 {
     InitializeComponent();
     try
     {
         connect = new DB_Connect();
     } catch
     {
         MessageBox.Show("Не удаётся подключиться к серверу, проверьте подключение к сети, затем перезайдите в данную вкладку.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     initPostList();
 }
 public editAdmissions()
 {
     InitializeComponent();
     try
     {
         connect = new DB_Connect();
     } catch
     {
         MessageBox.Show("Не удаётся подключиться к серверу!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     initList();
 }
Exemple #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                conn = DB_Connect.GetConnection();
                conn.Open();
            }
            //LoadCountry();
            // Initilize the Controls from Cookies
            else
            {
                LoadCountry();
                LabelRU.Visible = false;
            }

            InitializeCookies();
        }
Exemple #26
0
        protected void DDLCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            int countID = Convert.ToInt32(DDLCountry.SelectedItem.Value);

            if (countID > 0)
            {
                conn = DB_Connect.GetConnection();
                conn.Open();
                string         query  = "Select * from City Where CountryID = " + countID;
                SqlDataAdapter _sqlda = new SqlDataAdapter(query, conn);
                DataTable      dt     = new DataTable();
                _sqlda.Fill(dt);
                DDLCity.DataSource     = dt;
                DDLCity.DataValueField = "CityID";
                DDLCity.DataTextField  = "CityName";
                DDLCity.DataBind();
            }
        }
Exemple #27
0
        protected void btnDelete_Click1(object sender, EventArgs e)
        {
            SqlConnection conn = DB_Connect.GetConnection();

            conn.Open();
            string     query  = "SPDelBook";
            SqlCommand newCmd = conn.CreateCommand();

            newCmd.Connection = conn;
            newCmd.Parameters.AddWithValue("@bid", this.TextBox1.Text);

            newCmd.CommandType = CommandType.StoredProcedure;
            newCmd.CommandText = query;
            newCmd.ExecuteNonQuery();

            LabelDB.Visible = true;
            // MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery());
            conn.Close();
        }
Exemple #28
0
 private void LoadCountry()
 {
     try
     {
         conn = DB_Connect.GetConnection();
         conn.Open();
         string         query  = "Select * from Country";
         SqlDataAdapter _sqlda = new SqlDataAdapter(query, conn);
         DataTable      dt     = new DataTable();
         _sqlda.Fill(dt);
         DDLCountry.DataSource     = dt;
         DDLCountry.DataValueField = "CID";
         DDLCountry.DataTextField  = "CountryName";
         DDLCountry.DataBind();
     }
     catch (Exception e)
     {
         Response.Write("Error");
     }
 }
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (emailBox.Text.Length == 0)
            {
                errormessage.Text = "Enter an email.";
                emailBox.Focus();
            }
            else if (!Regex.IsMatch(emailBox.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
            {
                errormessage.Text = "Enter a valid email.";
                emailBox.Select(0, emailBox.Text.Length);
                emailBox.Focus();
            }
            else
            {
                string email = emailBox.Text;
                string password = PasswordBox.Password;

                DB_Connect db_connect = new DB_Connect();
                List<string>[] answer = db_connect.SelectUser(email, password);
                if (answer != null)
                {
                    errormessage.Text = "Login successfully";
                    string user_name = answer[2][0];
                    // here we will want to save the user email and nickname in app.config/ settings .
                    Properties.Settings.Default["user_name"] = user_name;
                    Properties.Settings.Default["user_email"] = email;
                    Properties.Settings.Default.Save();
                    Reset();
                    this.Close();
                }
                else
                {
                    errormessage.Visibility = Visibility.Visible;
                    errormessage.Text = "Sorry! Please enter existing email/password.";
                }

            }
        }
        /* protected void DeleteTopic(object sender, GridViewDeleteEventArgs e)
         * {
         *   try
         *   {
         *       int id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[2].Text);
         *       conn = DB_Connect.GetConnection();
         *       conn.Open();
         *       SqlCommand aCommand = new SqlCommand("SpDelTopic", conn);
         *       aCommand.CommandType = CommandType.StoredProcedure;
         *
         *       aCommand.Parameters.AddWithValue("@id", id);
         *
         *       aCommand.ExecuteNonQuery();
         *       Response.Write("Record Deleted Successfully");
         *       conn.Close();
         *       aCommand.Dispose();
         *   }
         *   catch (Exception err)
         *   {
         *       //TextFileWriter.WriteToLog(err.Message);
         *       //return null;
         *   }
         * }*/

        protected void DeleteTopic2(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);
                conn = DB_Connect.GetConnection();
                conn.Open();
                SqlCommand aCommand = new SqlCommand("SpDelTopic", conn);
                aCommand.CommandType = CommandType.StoredProcedure;

                aCommand.Parameters.AddWithValue("@id", id);

                aCommand.ExecuteNonQuery();
                Response.Write("Record Deleted Successfully");
                conn.Close();
                aCommand.Dispose();
            }
            catch (Exception err)
            {
                Response.Write("Error");
            }
        }