Exemplo n.º 1
0
 public virtual void OnFirstNameUpdated(updateForm e)
 {
     if (FirstNameUpdated != null)
     {
         FirstNameUpdated(this, e);
     }
 }
Exemplo n.º 2
0
 private void Fnf_FirstNameUpdated(object sender, updateForm e)
 {
     // to be used to show data on form #3
     if (e != null && e.id != null)
     {
         fnf.Label2  = e.id;
         fnf.Label4  = e.s_id;
         fnf.Label6  = e.full_name;
         fnf.Label8  = e.transaction_type;
         fnf.Label10 = e.type;
     }
 }
Exemplo n.º 3
0
        private void setCustomerInformation(SqlConnection con, int q_cn, int q_id)
        {
            // Called when next button is clicked.
            if (checkIfNextCustomerExist(q_cn))
            {
                // Calls consecutive functions for the next customer to be served.

                SqlCommand cmd4, _cmd4, _cmd0;
                String     query         = "select TOP 1 Queue_Number,Type,Student_No,Full_name,Transaction_Type,Pattern_Current,Pattern_Max from Main_Queue where Queue_Number = @q_cn and Servicing_Office = @sn";
                String     _query_insert = "update Main_Queue set Queue_Number = @q_cn, Servicing_Office = @q_nso, Pattern_Current = Pattern_Current + 1 where id = @q_id";
                String     _query_delete = "delete from Main_Queue where id = @id";
                //Console.Write(" \n \n deleting from main queue qn = " + q_cn + " ;; sn = " + Servicing_Office);
                String _query_delete_queue_pattern = "delete from Queue_Transaction where Main_Queue_ID = @q_cn and Pattern_No = @q_pn";
                cmd4 = new SqlCommand(query, con);

                cmd4.Parameters.AddWithValue("@q_cn", q_cn);
                cmd4.Parameters.AddWithValue("@sn", Servicing_Office);
                SqlDataReader rdr3;
                rdr3 = cmd4.ExecuteReader();
                if (rdr3.Read())
                {
                    // Retrieves the information of the next customer to be served
                    id                  = rdr3["Queue_Number"].ToString();
                    type                = ((Boolean)rdr3["Type"] == false) ? "Student" : "Guest";
                    s_id                = rdr3["Student_No"].ToString();
                    full_name           = rdr3["Full_name"].ToString();
                    _pattern_max        = (int)rdr3["Pattern_Max"];
                    _pattern_current    = (int)rdr3["Pattern_Current"];
                    transaction_type_id = (int)rdr3["Transaction_Type"];
                    int q_nso = 0;
                    foreach (DataRow row in table_Transactions.Rows)
                    {
                        // Retrieves the Transaction ID of the queue
                        int _id = (int)row["Transaction_Type"];
                        if (_id == transaction_type_id)
                        {
                            transaction_type = (String)row["Transaction_Name"];
                        }
                    }
                    if (_pattern_current < _pattern_max)
                    {
                        // Checks if there are still next Servicing Offices after this transaction
                        q_nso = nextServicingOffice(_pattern_current, transaction_type_id);
                        _cmd4 = new SqlCommand(_query_insert, con);
                        _cmd4.Parameters.AddWithValue("@q_id", q_id);
                        _cmd4.Parameters.AddWithValue("@q_cn", getQueueNumber(con, q_nso));
                        _cmd4.Parameters.AddWithValue("@q_nso", q_nso);
                        incrementQueueNumber(con, q_nso);
                        _cmd4.ExecuteNonQuery();
                    }
                    else
                    {
                        // If no more Servicing Offices, delete from Main_Queue Table
                        _cmd4 = new SqlCommand(_query_delete, con);
                        _cmd4.Parameters.AddWithValue("@id", q_id);
                        _cmd4.ExecuteNonQuery();
                    }
                    Console.Write("\n\n using _cmd0 -- q_cn = " + q_cn + " _pattern_current = " + _pattern_current);
                    // Removes a Queue_Transaction info of the Customer everytime Next() is clicked
                    _cmd0 = new SqlCommand(_query_delete_queue_pattern, con);
                    _cmd0.Parameters.AddWithValue("@q_cn", q_cn);
                    _cmd0.Parameters.AddWithValue("@q_pn", _pattern_current);
                    _cmd0.ExecuteNonQuery();

                    // Updates the information shown on Form3
                    updateForm nuea = new updateForm();
                    nuea.id               = id;
                    nuea.type             = type;
                    nuea.s_id             = s_id;
                    nuea.full_name        = full_name;
                    nuea.transaction_type = transaction_type;
                    fnf.OnFirstNameUpdated(nuea);
                }

                //nuea.id = "wew";
                //nuea.type = "wew";
                //nuea.s_id = "wew";
                //nuea.full_name = "wew";
                //nuea.transaction_type = "wew";
                //fnf.OnFirstNameUpdated(nuea);
                Console.Write("updating using fnf...");
            }
            else
            {
                MessageBox.Show("checkIfNextCustomerExist returns FALSE.");
            }
        }