private void PrintBtn_Click(object sender, EventArgs e)
        {
            //ViolationCombo.Focus();
            if (ViolationCombo.SelectedIndex != -1)
            {
                Ticket.PrintCount = 1;
                Ticket.StatusCode = "O";

                if (!inserted)
                {
                    DBHelp dbh = new DBHelp();
                    dbh.InsertTicket();
                    inserted = true;
                }
                if (sDate == "")
                {
                    sDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                }

                PrintTicket();
            }
            else
            {
                PopUpForm pf = new PopUpForm("No Offense Selected");
                pf.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void SubmitBtn_Click(object sender, EventArgs e)
        {
            CancelReasonTxt.Focus();
            DBHelp dbh = new DBHelp();

            if (CancelReasonTxt.Text != "")
            {
                Ticket.Notes      = "CANCELED: " + CancelReasonTxt.Text;
                Ticket.StatusCode = "C";

                try
                {
                    if (Ticket.PrintError)
                    {
                        dbh.CancelExistingTicket(Ticket.TicketNumber);
                    }
                    else
                    {
                        if (!inserted)
                        {
                            dbh.InsertTicket();
                            inserted = true;
                        }
                    }

                    if (dbh.IsNetConnected())
                    {
                        dbh.PostTicket();
                    }

                    pg.locationForm.Show();
                    this.Hide();
                    CancelReasonTxt.Text = "";
                    CurrentCharge.Charge = null;
                    inserted             = false;
                }
                catch (Exception er) { }
            }
            else
            {
                CancelReasonTxt.Focus();


                PopUpForm pf = new PopUpForm("Cancel Reason not entered.");
                pf.ShowDialog();
            }
        }
        void yn_FormClosed(object sender, FormClosedEventArgs e)
        {
            DBHelp dbh = new DBHelp();

            bool reprint = ((YesNoForm)sender).returnValue;

            if (reprint)
            {
                dbh.UpdatePrintCount(Ticket.TicketNumber);
                PrintTicket();
            }
            else
            {
                if (dbh.TicketCount() > 0)
                {
                    inserted = false;
                    if (dbh.IsNetConnected())
                    {
                        dbh.PostTicket();
                    }
                    else
                    {
                        PopUpForm pf = new PopUpForm("Not Connected to Network. Tickets not posted.");
                        pf.ShowDialog();
                    }
                }
                pg.locationForm.Show();
                this.Hide();

                Ticket.PrintError            = false;
                ViolationCombo.SelectedIndex = -1;
                CurrentCharge.Charge         = null;
                sDate = "";

                if (Ticket.Latitude > 0)
                {
                    Ticket.Latitude = 0;
                }
                if (Ticket.Longitude > 0)
                {
                    Ticket.Longitude = 0;
                }
            }
        }
Ejemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            pg = new Program();
            pg.lForm.Show();

            DBHelp dbh = new DBHelp();

            string fulluser = WindowsIdentity.GetCurrent().Name.ToString();
            string user     = fulluser.Split('\\')[1].ToString();

            int count = dbh.TicketCount();

            if (dbh.EmployeeLogin(user))
            {
                Attendant.username  = user;
                Ticket.OfficerBadge = Attendant.OfficerBadge;

                if (count > 0)
                {
                    if (dbh.IsNetConnected())
                    {
                        dbh.PostTicket();
                    }
                    else
                    {
                        PopUpForm pf = new PopUpForm("Not Connected to Network. Tickets not posted.");
                        pf.ShowDialog();
                    }
                }
            }
            else
            {
                PopUpForm pf = new PopUpForm("Not Authorized User");
                pf.FormClosed += pf_FormClosed;
                pf.ShowDialog();
            }

            label1.Text = dbh.TicketCount().ToString();

            pg.lForm.Close();
        }
Ejemplo n.º 5
0
        private void SubmitBtn_Click(object sender, EventArgs e)
        {
            LicenseTxt.Focus();
            bool hasEdits = false;

            if (LicenseTxt.Text != "" && StateTxt.Text != "")
            {
                if (LicenseTxt.Text.Length < 13)
                {
                    Vehicle.TagNumber = LicenseTxt.Text.ToUpper();
                    Ticket.TagNumber  = LicenseTxt.Text.ToUpper();
                }
                else
                {
                    LicenseTxt.Focus();
                    PopUpForm pf = new PopUpForm("Tag Number is too long");
                    pf.ShowDialog();
                    LicenseTxt.Text = "";
                    return;
                }

                if (stateList.Contains(StateTxt.Text.ToUpper()))
                {
                    Vehicle.TagState = StateTxt.Text.ToUpper();
                    Ticket.TagState  = StateTxt.Text.ToUpper();
                }
                else
                {
                    StateTxt.Focus();
                    PopUpForm pf = new PopUpForm("Not valid state");
                    pf.ShowDialog();
                    StateTxt.Text = "";
                    return;
                }

                hasEdits = true;
            }
            else if (VINTxt.Text != "")
            {
                Vehicle.VIN  = VINTxt.Text.ToUpper();
                Ticket.Notes = "VIN: " + VINTxt.Text.ToUpper();
                hasEdits     = true;
            }

            if (hasEdits)
            {
                if (dbh.IsNetConnected())
                {
                    TicketService();
                }
                else
                {
                    TicketOffline();
                }


                //pg.locationForm.Show();
                this.Hide();
                LicenseTxt.Text = "";
                StateTxt.Text   = "";
                VINTxt.Text     = "";

                //reset is set to true if there a ticket is unable to be written due to constraints
                //If reset is false, go to Offence Form, else go to Location Form
                if (reset == false)
                {
                    pg.offenceForm.Show();
                }
                else
                {
                    reset = false;
                    pg.locationForm.Show();
                }
            }
            else
            {
                PopUpForm pf = new PopUpForm("Not Enough Information Entered");
                pf.ShowDialog();
            }
        }
Ejemplo n.º 6
0
        private void TicketService()
        {
            Ticket.IsOffline = false;
            List <Violation> vioList = new List <Violation>();

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://coaworks/api/publicsafety/parkingticket/search?"
                                                                       + "tagState=" + Vehicle.TagState
                                                                       + "&tagNumber=" + Vehicle.TagNumber
                                                                       + "&meter=" + Ticket.MeterNumber);//MeterTxt.Text);

            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://parking/api/tag/search/"
            //    + Vehicle.TagState + "/" + Vehicle.TagNumber
            //    + "?meter=" + MeterTxt.Text
            //    + "&tagCategory=" + Ticket.VehicleTagCategory
            //    + "&user="******"GET";
            request.Timeout     = 10000;
            request.Credentials = CredentialCache.DefaultCredentials;

            HttpWebResponse response;
            Stream          responseStream;
            StreamReader    reader;

            try
            {
                response       = request.GetResponse() as HttpWebResponse;
                responseStream = response.GetResponseStream();
                reader         = new StreamReader(responseStream);
                string responseText = reader.ReadToEnd();

                #region JSON

                JObject o = JObject.Parse(responseText);

                #region Owner

                JContainer ownerContainer = null;
                if (o["owner"] != null && o["owner"].Type != JTokenType.Null)
                {
                    ownerContainer = (JContainer)o["owner"];
                    ParkingApp_Tablet.Owner.Name      = (string)ownerContainer["name"];
                    ParkingApp_Tablet.Owner.ProfileID = (string)ownerContainer["profileID"];
                    Ticket.ProfileID = ParkingApp_Tablet.Owner.ProfileID;
                }
                else
                {
                    ownerContainer = null;
                }

                #endregion

                #region Vehicle

                JContainer vehicleContainer = null;
                if (o["vehicle"] != null && o["vehicle"].Type != JTokenType.Null)
                {
                    vehicleContainer    = (JContainer)o["vehicle"];
                    Vehicle.Description = (string)vehicleContainer["description"];
                    Vehicle.TowEligible = (bool)vehicleContainer["towEligible"];

                    #region Meter Violation

                    JContainer eligibleMeterViolationContainer = null;
                    if (vehicleContainer["eligibleMeterViolation"] != null && vehicleContainer["eligibleMeterViolation"].Type != JTokenType.Null)
                    {
                        eligibleMeterViolationContainer  = (JContainer)vehicleContainer["eligibleMeterViolation"];
                        Vehicle.MeterViolationCharge     = (string)eligibleMeterViolationContainer["charge"];
                        Vehicle.MeterViolationChargeCode = (string)eligibleMeterViolationContainer["chargeCode"];
                        Vehicle.MeterViolationAmount     = (string)eligibleMeterViolationContainer["amount"];
                    }
                    else
                    {
                        eligibleMeterViolationContainer = null;
                        Vehicle.MeterViolationCharge    = "";
                    }

                    JContainer lastMeterViolationContainer = null;
                    if (vehicleContainer["lastMeterViolation"] != null && vehicleContainer["lastMeterViolation"].Type != JTokenType.Null)
                    {
                        lastMeterViolationContainer          = (JContainer)vehicleContainer["lastMeterViolation"];
                        Vehicle.LastMeterViolationCharge     = (string)lastMeterViolationContainer["charge"];
                        Vehicle.LastMeterViolationChargeCode = (string)lastMeterViolationContainer["chargeCode"];
                        //string lastMeterAmount = (string)lastMeterViolationContainer["amount"];
                    }
                    else
                    {
                        lastMeterViolationContainer          = null;
                        Vehicle.LastMeterViolationCharge     = "";
                        Vehicle.LastMeterViolationChargeCode = "";
                    }

                    #endregion

                    #region 2 Hour Violation

                    JContainer eligibleTwoHourViolationContainer = null;
                    if (vehicleContainer["eligibleTwoHourViolation"] != null && vehicleContainer["eligibleTwoHourViolation"].Type != JTokenType.Null)
                    {
                        eligibleTwoHourViolationContainer  = (JContainer)vehicleContainer["eligibleTwoHourViolation"];
                        Vehicle.TwoHourViolationCharge     = (string)eligibleTwoHourViolationContainer["charge"];
                        Vehicle.TwoHourViolationChargeCode = (string)eligibleTwoHourViolationContainer["chargeCode"];
                        Vehicle.TwoHourViolationAmount     = (string)eligibleTwoHourViolationContainer["amount"];
                    }
                    else
                    {
                        eligibleTwoHourViolationContainer = null;
                        Vehicle.TwoHourViolationCharge    = "";
                    }

                    JContainer lastTwoHourViolationContainer = null;
                    if (vehicleContainer["lastTwoHourViolation"] != null && vehicleContainer["lastTwoHourViolation"].Type != JTokenType.Null)
                    {
                        lastTwoHourViolationContainer          = (JContainer)vehicleContainer["lastTwoHourViolation"];
                        Vehicle.LastTwoHourViolationCharge     = (string)lastTwoHourViolationContainer["charge"];
                        Vehicle.LastTwoHourViolationChargeCode = (string)lastTwoHourViolationContainer["chargeCode"];
                        //string lastTwoHourAmount = (string)lastTwoHourViolationContainer["amount"];
                    }
                    else
                    {
                        lastTwoHourViolationContainer          = null;
                        Vehicle.LastTwoHourViolationCharge     = "";
                        Vehicle.LastTwoHourViolationChargeCode = "";
                    }

                    #endregion
                }
                else
                {
                    vehicleContainer = null;
                }

                #endregion

                #region Meter

                JContainer meterContainer;
                if (o["meter"] != null && o["meter"].Type != JTokenType.Null)
                {
                    meterContainer = (JContainer)o["meter"];
                }
                else
                {
                    meterContainer = null;
                }

                //if (MeterTxt.Text != "")
                //    Ticket.MeterNumber = MeterTxt.Text.ToUpper();
                //if (LocationTxt.Text != "")
                //    Ticket.ViolationLocation = LocationTxt.Text;
                //else
                //    Ticket.ViolationLocation = meter[0];

                #endregion

                #region Violation

                JContainer violationContainer;
                if (o["outstanding"] != null && o["outstanding"].Type != JTokenType.Null)
                {
                    violationContainer      = (JContainer)o["outstanding"];
                    Violations.TotalBalance = (string)violationContainer["total"];
                }
                else
                {
                    violationContainer = null;
                }

                if (violationContainer != null)
                {
                    JContainer violations = (JContainer)violationContainer["violations"];
                    for (int i = 0; i < violations.Count(); i++)
                    {
                        JToken job = violations[i];
                        vioList.Add(new Violation()
                        {
                            Amount = (string)job["amount"],
                            Charge = (string)job["charge"],
                            Date   = (string)job["date"],
                            Ticket = (string)job["ticketNumber"]
                        });
                    }
                    Violations.ViolationList = vioList;
                }

                #endregion

                //If Vehicle can be towed
                if (Vehicle.TowEligible)
                {
                    PopUpForm pf = new PopUpForm("This vehicle is eligible for towing.");
                    pf.ShowDialog();
                }

                if (Ticket.MeterNumber != "")
                {
                    if (dbh.CheckDate())
                    {
                        //If Vehicle has reached the limit of meter violations for today
                        if (Vehicle.MeterViolationCharge == "" && Vehicle.LastMeterViolationChargeCode == "03")
                        {
                            PopUpForm pf = new PopUpForm("Meter Violation Limit Reached.  \nNot Eligible For New Meter Violation");
                            pf.ShowDialog();

                            reset = true;
                        }
                        //if Vehicle has received a meter violation within the last two hours.
                        else if (Vehicle.MeterViolationCharge == "")
                        {
                            PopUpForm pf = new PopUpForm("Previous Meter Violation Issued Within Two Hours. \nNot Eligible For New Meter Violation");
                            pf.ShowDialog();

                            reset = true;
                        }
                    }
                    else
                    {
                        PopUpForm pf = new PopUpForm("Meter Violations Can Only Be Issued Between 8AM and 5PM Monday - Friday");
                        pf.ShowDialog();

                        reset = true;
                    }
                }
                else
                {
                    if (Vehicle.TwoHourViolationCharge == "" && Vehicle.LastTwoHourViolationChargeCode == "14")
                    {
                        PopUpForm pf = new PopUpForm("Two Hour Violation Limit Reached.  \nNot Eligible For New Two Hour Violation");
                        pf.ShowDialog();
                    }
                    else if (Vehicle.TwoHourViolationCharge == "")
                    {
                        PopUpForm pf = new PopUpForm("Previous Two Hour Violation Issued Within Two Hours. \nNot Eligible For New Two Hour Violation");
                        pf.ShowDialog();
                    }
                }

                #endregion

                try
                {
                    request.Abort();
                    response.Close();
                    responseStream.Close();
                    reader.Close();
                }
                catch (Exception ex) { }
            }
            catch (Exception execpt)
            {
                request.Abort();
                TicketOffline();
            }
        }
        private void CancelBtn_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                MeterTxt.Focus();
                if (MeterTxt.Text == "" && LocationTxt.Text == "")
                {
                    this.Hide();

                    int count = dbh.TicketCount();
                    if (count > 0)
                    {
                        if (dbh.IsNetConnected() && Attendant.username != null)
                        {
                            dbh.PostTicket();
                        }
                        else
                        {
                            PopUpForm pf = new PopUpForm(count + " tickets not posted.");
                            pf.ShowDialog();
                        }
                    }

                    if (dbh.IsNetConnected())
                    {
                        dbh.TableCheck();
                    }
                    try
                    {
                        Process[] procs = Process.GetProcessesByName("TabTip");

                        if (procs.Count() > 0)
                        {
                            procs[0].Kill();
                        }
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show(ex.Message);
                    }
                    Application.Exit();
                }
                else
                {
                    MeterTxt.Text    = "";
                    LocationTxt.Text = "";
                }
            }
            else if (tabControl1.SelectedIndex == 1)
            {
                if (flowLayoutPanel1.Controls.Count > 0)
                {
                    flowLayoutPanel1.Controls.Clear();
                }
                else
                {
                    int count = dbh.TicketCount();
                    if (count > 0)
                    {
                        if (dbh.IsNetConnected() && Attendant.username != null)
                        {
                            dbh.PostTicket();
                        }
                        else
                        {
                            PopUpForm pf = new PopUpForm(count + " tickets not posted.");
                            pf.ShowDialog();
                        }
                    }

                    if (dbh.IsNetConnected())
                    {
                        dbh.TableCheck();
                    }
                    try
                    {
                        Process[] procs = Process.GetProcessesByName("TabTip");

                        if (procs.Count() > 0)
                        {
                            procs[0].Kill();
                        }
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show(ex.Message);
                    }
                    Application.Exit();
                }
            }
            else if (tabControl1.SelectedIndex == 2)
            {
                if (flowLayoutPanel2.Controls.Count > 0)
                {
                    flowLayoutPanel2.Controls.Clear();
                }
                else
                {
                    int count = dbh.TicketCount();
                    if (count > 0)
                    {
                        if (dbh.IsNetConnected() && Attendant.username != null)
                        {
                            dbh.PostTicket();
                        }
                        else
                        {
                            PopUpForm pf = new PopUpForm(count + " tickets not posted.");
                            pf.ShowDialog();
                        }
                    }

                    if (dbh.IsNetConnected())
                    {
                        dbh.TableCheck();
                    }
                    try
                    {
                        Process[] procs = Process.GetProcessesByName("TabTip");

                        if (procs.Count() > 0)
                        {
                            procs[0].Kill();
                        }
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show(ex.Message);
                    }
                    Application.Exit();
                }
            }
        }
        private void SubmitBtn_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                MeterTxt.Focus();
                meter = new List <string>();

                if (MeterTxt.Text == "" && LocationTxt.Text == "")
                {
                    PopUpForm pf = new PopUpForm("No Information Entered");
                    pf.ShowDialog();
                }
                else
                {
                    Cursor.Current = Cursors.WaitCursor;

                    if (MeterTxt.Text != "")
                    {
                        meter = dbh.MeterInfo(MeterTxt.Text.ToUpper());  //This is a list of meter info ("Meter Location","Meter ID")

                        if (meter[1] == "")
                        {
                            PopUpForm pf = new PopUpForm("Not Valid Meter");
                            pf.ShowDialog();

                            MeterTxt.Text = "";

                            if (Cursor.Current == Cursors.WaitCursor)
                            {
                                Cursor.Current = Cursors.Default;
                            }

                            return;
                        }
                        else
                        {
                            Ticket.MeterNumber       = meter[1];
                            Ticket.ViolationLocation = meter[0];
                        }
                    }
                    else if (LocationTxt.Text != "")
                    {
                        Ticket.MeterNumber       = "";
                        Ticket.ViolationLocation = LocationTxt.Text;
                    }

                    Cursor.Current   = Cursors.Default;
                    MeterTxt.Text    = "";
                    LocationTxt.Text = "";

                    pg.vehicleForm.Show();
                    this.Hide();
                }
            }
            else if (tabControl1.SelectedIndex == 1)
            {
            }
            else if (tabControl1.SelectedIndex == 2)
            {
            }
        }