示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDataClass.getAllProducts();
            txtMessage.Text = "";
            if (!IsPostBack)
            {
                DisplayRow((int)Session["Prog3_Index"]);
            }
            string        Output = "";
            SqlConnection conn   = new SqlConnection(ConfigurationManager.ConnectionStrings["UWPCS3870ConnectionString1"].ConnectionString);

            conn.Open();
            string insertQuery = "Select Role from Users where UserName = '******'";

            SqlCommand com = new SqlCommand(insertQuery, conn);

            //com.ExecuteNonQuery();
            SqlDataReader item = com.ExecuteReader();

            while (item.Read())
            {
                Output = item.GetValue(0).ToString();
            }
            conn.Close();
            if (!Output.Contains("Admin"))
            {
                Response.Redirect("Default.aspx");
            }
        }
示例#2
0
 public static void getAllProducts()
 {
     if (SQLDataClass.prodAdapter == null)
     {
         SQLDataClass.setupProdAdapter();
     }
 }
示例#3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     this.DataBind();
     if (!IsPostBack)
     {
         DisplayRow((int)Application["Prog3_Index"]);
     }
 }
示例#4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     txtMessage.Text = "";
     if (!IsPostBack)
     {
         DisplayRow((int)Session["Prog3_Index"]);
     }
 }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDataClass.getAllProducts();
            this.DataBind();

            //txtID.Text = (string)Application["Prog2_ProductID"];
            //txtQuantity.Text = (string)Application["Prog2_ProductQuantity"];
            //txtPrice.Text = Application["Prog2_ProductPrice"].ToString();

            txtID.Focus();
        }
示例#6
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         string theID    = txtID.Text;
         string newName  = txtName.Text;
         double newPrice = double.Parse(txtPrice.Text.Replace("$", ""));
         string newDesc  = txtDescription.Text;
         SQLDataClass.UpdateProduct(theID, newName, newPrice, newDesc);
         txtMessage.Text = "Record updated.";
         SQLDataClass.getAllProducts();
     }
     catch (Exception ex)
     {
         txtMessage.Text = "Product Not Updated: " + ex.Message;
     }
 }
示例#7
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Prog2
            Application["Prog2_ProductID"]       = "";
            Application["Prog2_ProductPrice"]    = "";
            Application["Prog2_ProductQuantity"] = "";
            Application["Prog2_Computed"]        = false;

            //Prog3
            Application["Prog3_Index"] = 0;
            Application["Prog3_ID"]    = "";

            SQLDataClass.setupProdAdapter();
        }
示例#8
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text == "Add")
            {
                btnDelete.Enabled   = false;
                btnNext.Enabled     = false;
                btnPrevious.Enabled = false;
                btnFirst.Enabled    = false;
                btnLast.Enabled     = false;
                btnUpdate.Enabled   = false;
                btnAdd.Text         = "Save";
                clearTextFields();
            }
            else
            {
                btnDelete.Enabled   = true;
                btnNext.Enabled     = true;
                btnPrevious.Enabled = true;
                btnFirst.Enabled    = true;
                btnLast.Enabled     = true;
                btnUpdate.Enabled   = true;
                try
                {
                    btnAdd.Text = "Add";
                    string theID    = txtID.Text;
                    string newName  = txtName.Text;
                    double newPrice = double.Parse(txtPrice.Text.Replace("$", ""));
                    string newDesc  = txtDescription.Text;

                    SQLDataClass.InsertProduct(theID, newName, newPrice, newDesc);
                    txtMessage.Text = "Record added.";
                    SQLDataClass.getAllProducts();
                }
                catch (Exception ex)
                {
                    txtMessage.Text = "Product Not Added: " + ex.Message;
                }
            }
        }
示例#9
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string theID = txtID.Text;
                SQLDataClass.DeleteProduct(theID);
                txtMessage.Text = "Record deleted.";
                SQLDataClass.getAllProducts();

                int index = (int)Application["Prog3_Index"] - 1;
                if (index < 0)
                {
                    index = 0;
                }
                Application["Prog3_index"] = index;
                DisplayRow(index);
            }
            catch (Exception ex)
            {
                txtMessage.Text = "Product Not Deleted: " + ex.Message;
            }
        }
示例#10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
 }
示例#11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     ProductGrid.DataSource = SQLDataClass.tblProduct;
     ProductGrid.DataBind();
 }
示例#12
0
 protected void Application_Start(object sender, EventArgs e)
 {
     SQLDataClass.setupProdAdapter();
 }