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) {}
        }
        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();
        }
        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();
        }
        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);
            }
        }
Exemple #6
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 #7
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();
        }
Exemple #8
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           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 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)
            {}
        }
Exemple #11
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 #12
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");
            }
        }
Exemple #13
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 #14
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 #15
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 #16
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");
     }
 }
        protected void btnDeleteQ_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = DB_Connect.GetConnection();
                conn.Open();
                string     query  = "SPDelQuotation";
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.Connection = conn;
                newCmd.Parameters.AddWithValue("@qtid", int.Parse(this.TextBox1.Text));


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

                LabelDQ.Visible = true;

                conn.Close();
            }
            catch (NullReferenceException) { }
        }
        protected void btnDelete_Click1(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = DB_Connect.GetConnection();
                conn.Open();
                string     query  = "SPDelAuthor";
                SqlCommand newCmd = conn.CreateCommand();
                newCmd.Connection = conn;
                newCmd.Parameters.AddWithValue("@aid", int.Parse(this.TextBox1.Text));

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

                LabelDA.Visible = true;

                // MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery().ToString());
                conn.Close();
            }
            catch (NullReferenceException) { }
        }
Exemple #19
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            SqlConnection conn = DB_Connect.GetConnection();

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

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

            //if (dr.HasRows)
            //{
            while (dr.Read())
            {
                this.txtBID.Text         = dr.GetInt32(0).ToString();
                this.txtBTitle.Text      = dr.GetString(1);
                this.DDLTopic.Text       = dr.GetString(2);
                this.txtBPName.Text      = dr.GetString(3);
                this.txtBCType.Text      = dr.GetString(4);
                this.txtNotes.Text       = dr.GetString(5);
                this.txtBPPrice.Text     = dr.GetString(6);
                this.DDLAuthor.Text      = dr.GetString(7);
                this.txtBENumber.Text    = dr.GetString(8);
                this.txtBCYear.Text      = dr.GetString(9);
                this.txtBDPurchased.Text = dr.GetString(10);
                int aa = dr.GetInt32(11);

                this.txtBPages.Text = "" + aa;
                this.txtBSNo.Text   = dr.GetString(12);
            }
            //}
            //else
            //  LabelSB.Visible = true;


            ////////////////////////////
            conn.Close();
        }
        /* 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");
            }
        }
Exemple #21
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                conn = DB_Connect.GetConnection();
                conn.Open();

                SqlCommand newCmd = conn.CreateCommand();
                newCmd.CommandText = "SPInsertBook";
                newCmd.CommandType = CommandType.StoredProcedure;

                newCmd.Parameters.AddWithValue("@title", txtBTitle.Text);
                newCmd.Parameters.AddWithValue("@topic", DDLTopic.SelectedValue);
                newCmd.Parameters.AddWithValue("@pname", txtBPName.Text);
                newCmd.Parameters.AddWithValue("@ctype", txtBCType.Text);
                newCmd.Parameters.AddWithValue("@notes", txtNotes.Text);
                newCmd.Parameters.AddWithValue("@pprice", txtBPPrice.Text);
                newCmd.Parameters.AddWithValue("@author", DDLAuthor.SelectedValue);
                newCmd.Parameters.AddWithValue("@enum", txtBENumber.Text);
                newCmd.Parameters.AddWithValue("@cyear", txtBCYear.Text);
                newCmd.Parameters.AddWithValue("@dpur", txtBDPurchased.Text);
                newCmd.Parameters.AddWithValue("@page", txtBPages.Text);
                newCmd.Parameters.AddWithValue("@sno", txtBSNo.Text);
                newCmd.ExecuteNonQuery();

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

                /*string javaScript =
                 * "<script language=JavaScript>\n" +
                 * "alert('Record Added Succesfully!...');\n" +
                 * "</script>";
                 * RegisterStartupScript("Button1_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 Topic Where TopicID=" + int.Parse(ddlTopic.SelectedValue.ToString());
            SqlCommand    cmd   = new SqlCommand(query, conn);
            SqlDataReader dr    = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    this.txtTID.Text   = dr.GetInt32(0).ToString();
                    this.txtTopic.Text = dr.GetString(1);
                }
            }


            ////////////////////////////
            conn.Close();
        }