Beispiel #1
0
        // Delete btn
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            HtmlButton btnDelete = (HtmlButton)sender;

            id = Convert.ToInt32(btnDelete.Attributes["value"]);

            if (id != -1)
            {
                try
                {
                    DataRow record = dsOrder.prod_order.FindByid(id); // Find and add the record to tbe record variable


                    // Deletes the record in memory
                    //Send Id using cookie, more seecure I presume
                    HttpCookie cID = new HttpCookie("ID"); // Cokkie variable named cID to hold a value
                    cID.Value = id.ToString();

                    HttpCookie action = new HttpCookie("Action"); // Cokkie variable named cID to hold a value
                    action.Value = "Delete";

                    Response.Cookies.Add(action);
                    Response.Cookies.Add(cID);

                    prod_orderTableAdapter daOrder = new prod_orderTableAdapter(); // table adapter to service table (Service adapter)

                    //Refresh the page to show the record being deleted
                    Response.Redirect("DeleteConfirmationPOrders.aspx");
                }
                catch
                {
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            try
            {
                dsOrder = new OrdersDataSet();
                prod_orderTableAdapter daOrder = new prod_orderTableAdapter();

                daOrder.Fill(dsOrder.prod_order);


                if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page
                {
                    id = Convert.ToInt32(Request.Cookies["ID"].Value);
                }
                if (Request.Cookies["Action"] != null && Request.Cookies["Action"].Value == "Delete")
                {
                    pnlDeleteConfirm.Visible = true;
                    lblTitle.Text            = "Delete Sale";
                }
                else
                {
                    pnlDeleteConfirm.Visible = false;
                }
            }
            catch { return; }
        }
Beispiel #3
0
        static NewOrderForm1()
        {
            prod_orderTableAdapter daOrder = new prod_orderTableAdapter();

            try
            {
                daOrder.Fill(dsOrder.prod_order);
            }
            catch { }
        }
 private void Save()
 {
     try
     {
         prod_orderTableAdapter daOrder = new prod_orderTableAdapter();
         daOrder.Update(dsOrder.prod_order); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD)
         dsOrder.AcceptChanges();            // Call accept method on the dataset so it update the chanmges to the database
         lblStatus.Text = "Record Successfully Updated";
     }
     catch
     {
         dsOrder.RejectChanges();
         lblStatus.Text = "Unable to Update Record";
     }
 }
Beispiel #5
0
        private void Save()
        {
            prod_orderTableAdapter daOrder = new prod_orderTableAdapter();

            try
            {
                daOrder.Update(dsOrder.prod_order);
                dsOrder.AcceptChanges();
                this.lblStatus.Text = "Order Created";
                Clear();
            }
            catch
            {
                dsOrder.RejectChanges();
                this.lblStatus.Text = "Failed";
            }
        }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         prod_orderTableAdapter prod = new prod_orderTableAdapter();
         prod.Fill(dsInventory.prod_order);
         int        ordNum = Convert.ToInt32(dsInventory.prod_order.Single().ItemArray[0].ToString());
         Prod_Order order  = new Prod_Order((ordNum + 1).ToString(), DateTime.Parse(txtDateOrdered.Text), true);
         Prod_Order.CreateProd_Order(order, out string status, out int id);
         foreach (On_Order line in onOrders)
         {
             line.prodorderID = id;
             On_Order.CreateOn_Order(line, out string onOrdStatus, out int onOrdId);
         }
     }
     catch { }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            try
            {
                dsOrder = new OrdersDataSet();
                prod_orderTableAdapter daOrder = new prod_orderTableAdapter();
                daOrder.Fill(dsOrder.prod_order);
                if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page
                {
                    id = Convert.ToInt32(Request.Cookies["ID"].Value);
                }
            }
            catch { return; }
            if (!IsPostBack)
            {
                if (id != -1)
                {
                    try
                    {
                        DataRow order = dsOrder.prod_order.FindByid(id); // Find the related Record and fill the fields in the page with the data

                        if (order != null)
                        {
                            this.txtID.Text         = order.ItemArray[0].ToString();
                            this.txtProdNumber.Text = order.ItemArray[1].ToString();
                            this.txtDate.Text       = order.ItemArray[2].ToString();
                            this.cbo_Paid.Text      = order.ItemArray[3].ToString();
                        }
                        else
                        {
                            lblStatus.Text = "Please Try Again";
                        }
                    }
                    catch
                    {
                        lblStatus.Text = "Database Error";
                    }
                }
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            try
            {
                dsOrder = new OrdersDataSet();
                prod_orderTableAdapter daOrder = new prod_orderTableAdapter();
                daOrder.Fill(dsOrder.prod_order);
                rows = (Session["criteria"] != null) ? dsOrder.prod_order.Select(Session["criteria"].ToString()) : dsOrder.prod_order.Select();
                DisplayOrder();
            }
            catch (Exception ex)
            {
            }
            //data loaded successfully
        }
        protected void btnDeleteConfirm_Click(object sender, EventArgs e)
        {
            if (id != -1)
            {
                try
                {
                    prod_orderTableAdapter daOrder = new prod_orderTableAdapter();
                    daOrder.Fill(dsOrder.prod_order);
                    DataRow record = dsOrder.prod_order.FindByid(id); // Find and add the record to tbe record variable
                    record.Delete();                                  // Deletes the record in memory

                    // table adapter to service table (Service adapter)
                    daOrder.Update(record);  // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD)
                    dsOrder.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database
                                             //Refresh the page to show the record being deleted
                    Response.Redirect("Default.aspx");
                }
                catch
                {
                    lblStatus.Text = "Delete failed. Probably this Order assigned to some arrived Order in Database.";
                }
            }
        }