示例#1
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            conn = new MySqlConnection(GetConnectionString());
            String cbid      = TextBox1.Text;
            String stock     = TextBox3.Text;
            String amt       = TextBox2.Text;
            String validfrom = TextBox4.Text;
            String validto   = TextBox5.Text;

            try
            {
                conn.Open();
                MySqlCommand comm = new MySqlCommand("Insert into Combopack values ('" + cbid + "'," + stock + "," + amt + ",STR_TO_DATE('" + validfrom + "','%d-%m-%Y'),STR_TO_DATE('" + validto + "','%d-%m-%Y'))", conn);
                comm.ExecuteNonQuery();
            }
            catch (Exception ex)
            { Response.Write(ex.Message); }
            finally { conn.Close(); }
            int count = 0;

            try
            {
                conn.Open();
                MySqlCommand    comm = new MySqlCommand("Select count(*) from Combopack", conn);
                MySqlDataReader dr   = comm.ExecuteReader();
                dr.Read();
                count = dr.GetInt32(0);
                dr.Close();
            }
            catch (Exception ex)
            { Response.Write(ex.Message); }
            finally { conn.Close(); }
            count++;

            TextBox1.Text        = "CB" + count.ToString();
            TextBox2.Text        = "";
            TextBox3.Text        = "";
            TextBox7.Text        = "";
            Label9.Text          = "0";
            Label10.Text         = "Rs.";
            TextBox3.Text        = "10";
            GridView1.DataSource = null;
            GridView1.DataBind();
            ComboProductsList.DataSource = null;
            ComboProductsList.DataBind();
            RadioButtonList1.ClearSelection();
        }
示例#2
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            String parameter = RadioButtonList1.SelectedValue.ToString();
            String prparam   = TextBox7.Text;

            String sql = "";

            if (parameter.Equals("By Product ID"))
            {
                sql = "Select Product_ID,CONCAT(Company_Name,' ',Product_Name,' ',Retail_Price) from Current_Store_Products where Product_ID='" + prparam + "' and Stock<>0";
            }

            if (parameter.Equals("By Product Name"))
            {
                sql = "Select Product_ID,CONCAT(Company_Name,' ',Product_Name,' ',Retail_Price) from Current_Store_Products where Product_Name like'%" + prparam + "%' and Stock<>0";
            }

            conn = new MySqlConnection(GetConnectionString());

            try
            {
                conn.Open();
                MySqlCommand    comm = new MySqlCommand(sql, conn);
                MySqlDataReader dr   = comm.ExecuteReader();
                ComboProductsList.DataSource     = dr;
                ComboProductsList.DataTextField  = "CONCAT(Company_Name,' ',Product_Name,' ',Retail_Price)";
                ComboProductsList.DataValueField = "Product_ID";
                ComboProductsList.DataBind();
                dr.Close();
            }
            catch (Exception ex)
            { Response.Write("InButton3Click" + ex.Message); }
            finally { conn.Close(); }
            BulletedList1.DataSource = null;
            BulletedList1.DataBind();
        }