예제 #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();
 }