Ejemplo n.º 1
0
        } // end of btnViewAll

        /// <summary>
        /// this will accept the ticket number and
        /// finish the stuff for leave
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAccept_Click(object sender, EventArgs e)
        {
            #region --- hide stuffs ---
            lblValid.Visible         = false;
            lblTicketDetails.Visible = false;
            lblTcktNo.Visible        = false;
            lblTmIn.Visible          = false;
            txtBxTicketNumber.Clear();
            txtBxTicketNumber.Visible = false;
            txtBxTimeIn.Clear();
            txtBxTimeIn.Visible = false;
            #endregion -- hide --

            #region --- reveals ---
            lblTmIn.Visible      = true; // just added
            lblTicketOut.Visible = true;
            lblTmOut.Visible     = true;
            lblTtlTime.Visible   = true;
            lblAmntDue.Visible   = true;
            btnPiad.Visible      = true;
            btnPiad.Enabled      = true;
            lblTcktNo.Visible    = true;
            #endregion -- reveals --

            int    number = Convert.ToInt32(txtBxInput.Text); // sets the value for tkt number to search
            string leave  = DateTime.Now.ToString();          // sets the datetime of leaving
            // make stuff visible
            txtBxtktNumOut.Visible = true;
            txtBxTimeOut.Visible   = true;
            txtBxTotalTime.Visible = true;
            txtBxTotalDue.Visible  = true;

            XDocument doc = XDocument.Load("tickets.xml");          // loads the xml doc


            // problemn here it is not recognizing the objects after the original 5
            doc.XPathSelectElement("//tickets/Ticket[" + number + "]/timeOut").Value = leave;             // reads the doc and updates necessary fields based on ticket number
            string ventry = doc.XPathSelectElement("//tickets/Ticket[" + number + "]/timeIn").Value;

            doc.Save("tickets.xml");                        // saves the xml file

            DateTime entry     = DateTime.Parse(ventry);
            string   vexit     = doc.XPathSelectElement("//tickets/Ticket[" + number + "]/timeOut").Value;
            DateTime exit      = DateTime.Parse(vexit);
            TimeSpan timeInLot = Ticket.tmeInLot(entry, exit); // calls the tmeinlot method for calculating time in lot
            // calculate the money due
            double due;                                        // establishes the variable
            due = Ticket.AmountDue(timeInLot);                 // calls the amount due method
            // need to populate all fields
            txtBxTimeIn.Visible       = true;
            lblTmIn.Visible           = true;
            txtBxTicketNumber.Visible = true;
            txtBxTicketNumber.Text    = doc.XPathSelectElement("//tickets/Ticket[" + number + "]/tktNumber").Value;
            txtBxTimeIn.Text          = doc.XPathSelectElement("//tickets/Ticket[" + number + "]/timeIn").Value;
            txtBxtktNumOut.Text       = number.ToString();          //doc.XPathSelectElement("//tktNumber[text()='" + number + "']").Value;
            txtBxTimeOut.Text         = exit.ToString();            //doc.XPathSelectElement("//tktNumber[text()='" + number + "']/timeOut").Value;
            txtBxTotalDue.Text        = due.ToString("C0");         // stes the total due
            txtBxTotalTime.Text       = timeInLot.Hours.ToString(); // sets the time in lot

            txtBxInput.Enabled = false;
        } // end of btnAccept