Example #1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Random        r     = new Random();
        int           bk_id = r.Next(100, 10000);
        SqlConnection con   = null;

        try
        {
            con = TbLogic.GetConnection();

            con.Open();
            TbInfo tbjj = new TbInfo();
            tbjj.Tableno  = txttb.Text;
            tbjj.Date     = txtd.Text;
            tbjj.Sessions = Ss.SelectedItem.Text;
            String     query = "insert into TBK" + "(Book_ID,Name,Mobile,NoTable,Session,Date) values" + "('" + bk_id + "','" + Session["Name"] + "','" + Session["Mobile"] + "','" + Session["NoTable"] + "','" + Session["Session"] + "','" + Session["Date"] + "')";
            SqlCommand com   = new SqlCommand(query, con);
            int        i     = com.ExecuteNonQuery();
            if (i == 1)
            {
                Session["Book_ID"] = bk_id;
                Response.Redirect("A_T_B.aspx");
            }
            else
            {
                Lbl.Text = "Try Again Plz";
            }
        }
        catch (Exception err)
        {
            err.Message.ToString();
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Example #2
0
        public void AddInfo(string Message)
        {
            this.SuspendLayout();
            string M = Message;

            if (Message == "安全門開啟")
            {
                M += "(";
                M += ForstDoorGate() != '1' ? "前," : "";
                M += SideDoorGate() != '1' ? "側," : "";
                M += WarmDoorGate() != '1' ? "回溫," : "";
                M += ColdDoorGate() != '1' ? "冷藏," : "";
                M  = M.Substring(0, M.Length - 1);
                M += ")";
            }

            M += "\r\n";

            ThreadSafeHelper.UIThread(this, () => {
                TbInfo.AppendText(M);
            });
            this.ResumeLayout(false);
            Once = true;
        }
Example #3
0
    protected void avail2_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        try
        {
            con = TbLogic.GetConnection();

            con.Open();
            TbInfo tbj = new TbInfo();
            tbj.Tableno  = txttb.Text;
            tbj.Date     = txtd.Text;
            tbj.Sessions = Ss.SelectedItem.Text;

            if ((tbj.Sessions).Equals("Lunch"))
            {
                String        query = "select * from TBL where Date = '" + txtd.Text + "'";
                SqlCommand    com   = new SqlCommand(query, con);
                SqlDataReader dr    = com.ExecuteReader();
                if (dr.Read())
                {
                    tbj.Availability = dr[1].ToString();
                    if (Int32.Parse(txttb.Text) <= Int32.Parse(tbj.Availability))
                    {
                        Lbl.Text = "Availble " + dr["Availability"].ToString();
                    }
                    else
                    {
                        Lbl.Text = "Not Availble";
                    }
                }
                else
                {
                    if (Int32.Parse(txttb.Text) <= 10)
                    {
                        Lbl.Text = "Full Available";
                    }
                    else
                    {
                        Lbl.Text = "U can have max of 10";
                    }
                }
            }
            else
            {
                String        query = "select * from TBD where Date = '" + txtd.Text + "'";
                SqlCommand    com   = new SqlCommand(query, con);
                SqlDataReader dr    = com.ExecuteReader();
                if (dr.Read())
                {
                    tbj.Availability = dr[1].ToString();
                    if (Int32.Parse(txttb.Text) <= Int32.Parse(tbj.Availability))
                    {
                        Lbl.Text = "Availble " + dr["Availability"].ToString();
                    }
                    else
                    {
                        Lbl.Text = "Not Availble";
                    }
                }
                else
                {
                    if (Int32.Parse(txttb.Text) <= 10)
                    {
                        Lbl.Text = "Full Available";
                    }
                    else
                    {
                        Lbl.Text = "U can have max of 10";
                    }
                }
            }
        }
        catch (Exception err)
        {
            err.Message.ToString();
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Example #4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            TbInfo tbji = new TbInfo();
            tbji.Tableno  = txttb.Text;
            tbji.Date     = txtd.Text;
            tbji.Sessions = Ss.SelectedItem.Text;
            if ((tbji.Sessions).Equals("Lunch"))
            {
                SqlConnection con = null;
                con = TbLogic.GetConnection();
                con.Open();
                String        query = "select * from TBL where Date = '" + txtd.Text + "'";
                SqlCommand    com   = new SqlCommand(query, con);
                SqlDataReader dr    = com.ExecuteReader();
                if (dr.Read())
                {
                    tbji.Availability = dr[1].ToString();
                    if (Int32.Parse(txttb.Text) <= Int32.Parse(tbji.Availability))
                    {
                        SqlConnection con1 = null;
                        con1 = TbLogic.GetConnection();
                        con1.Open();
                        String     query1 = "Update TBL set Availability = '" + (Int32.Parse(tbji.Availability) - Int32.Parse(tbji.Tableno)) + "' where Date='" + tbji.Date + "'";
                        SqlCommand com1   = new SqlCommand(query1, con1);
                        //SqlDataReader d1r = com1.ExecuteReader();
                        int i = com1.ExecuteNonQuery();
                        if (i == 1)
                        {
                            Lbl.Text = "Booked for Lunch";
                        }
                        else
                        {
                            Lbl.Text = "Not Booked";
                        }
                        con1.Close();
                    }
                    else
                    {
                        Lbl.Text = "Not Availble";
                    }
                    //con.Close();
                }
                else
                {
                    if (Int32.Parse(tbji.Tableno) <= 10)
                    {
                        SqlConnection con1 = null;
                        con1 = TbLogic.GetConnection();
                        con1.Open();
                        String     query1 = "insert into TBL" + "(Date,Availability) values" + "('" + txtd.Text + "','" + (10 - Int32.Parse(txttb.Text)) + "')";
                        SqlCommand com1   = new SqlCommand(query1, con1);
                        int        i      = com1.ExecuteNonQuery();
                        if (i == 1)
                        {
                            Lbl.Text = "Inserted To Lunch";
                        }
                        else
                        {
                            Lbl.Text = "Try Again";
                        }
                        //con1.Close();
                    }
                    else
                    {
                        Lbl.Text = "U can have max of 10";
                    }
                }
            }
            else
            {
                SqlConnection con = null;
                con = TbLogic.GetConnection();

                con.Open();
                String        query = "select * from TBD where Date = '" + txtd.Text + "'";
                SqlCommand    com   = new SqlCommand(query, con);
                SqlDataReader dr    = com.ExecuteReader();
                if (dr.Read())
                {
                    tbji.Availability = dr[1].ToString();
                    if (Int32.Parse(txttb.Text) <= Int32.Parse(tbji.Availability))
                    {
                        SqlConnection con1 = null;
                        con1 = TbLogic.GetConnection();
                        con1.Open();
                        String     query1 = "Update TBD set Availability = '" + (Int32.Parse(tbji.Availability) - Int32.Parse(txttb.Text)) + "' where Date='" + txtd.Text + "'";
                        SqlCommand com1   = new SqlCommand(query1, con1);
                        //SqlDataReader d1r = com1.ExecuteReader();
                        int i = com1.ExecuteNonQuery();
                        if (i == 1)
                        {
                            Lbl.Text = "Booked for Dinner";
                        }
                        else
                        {
                            Lbl.Text = "Try Again";
                        }
                        con1.Close();
                    }
                    else
                    {
                        Lbl.Text = "Not Availble";
                    }
                }
                else
                {
                    if (Int32.Parse(tbji.Tableno) <= 10)
                    {
                        SqlConnection con1 = null;
                        con1 = TbLogic.GetConnection();
                        con1.Open();
                        String     query1 = "insert into TBD" + "(Date,Availability) values" + "('" + txtd.Text + "','" + (10 - Int32.Parse(tbji.Tableno)) + "')";
                        SqlCommand com1   = new SqlCommand(query1, con1);
                        int        i      = com1.ExecuteNonQuery();
                        if (i == 1)
                        {
                            Lbl.Text = "Inserted To Dinner";
                        }
                        else
                        {
                            Lbl.Text = "Try Again";
                        }
                        con1.Close();
                    }
                    else
                    {
                        Lbl.Text = "U can have max of 10";
                    }
                }
                con.Close();
            }
        }
        catch (Exception err)
        {
            Lbl.Text = err.Message.ToString();
        }
        Session["Session"] = Ss.SelectedItem.Text;
        Session["Date"]    = txtd.Text;
        Session["NoTable"] = txttb.Text;
    }
#pragma warning disable IDE1006 // Naming Styles
        private void lbUsers_SelectionChanged(object sender, SelectionChangedEventArgs e)
#pragma warning restore IDE1006 // Naming Styles
        {
            switch (LbUsers.SelectedItems.Count)
            {
            case 1:
                PlayersGamesSumButton.IsEnabled = true;
                ChallengeButton.IsEnabled       = true;
                TowPlayersGameButton.IsEnabled  = false;
                break;

            case 2:
                TowPlayersGameButton.IsEnabled  = true;
                PlayersGamesSumButton.IsEnabled = false;
                ChallengeButton.IsEnabled       = false;
                break;

            default:
                PlayersGamesSumButton.IsEnabled = TowPlayersGameButton.IsEnabled = false;
                break;
            }

            try
            {
                if (LbUsers.SelectedItem == null || LbUsers.SelectedItems.Count > 1)
                {
                    TbInfo.Clear();
                }
                else
                {
                    timer.Stop();
                    var selectedItem = LbUsers.SelectedItem as string;
                    utils.PingServer();
                    var clientInfoList = Client.AllTheGamesOfSomeClient(selectedItem);
                    if (clientInfoList.Count == 0)
                    {
                        TbInfo.Text = selectedItem + " has not played yet";
                    }
                    else
                    {
                        foreach (var str in clientInfoList)
                        {
                            TbInfo.Text += str + "\n";
                        }
                    }
                    timer.Start();
                }
            }
            catch (FaultException <DbException> ex)
            {
                MessageBox.Show(ex.Message + "\nType: " + ex.GetType());
            }
            catch (FaultException <Exception> ex)
            {
                MessageBox.Show(ex.Message + "\nType: " + ex.GetType());
            }
            catch (TimeoutException ex)
            {
                MessageBox.Show("server is disconnected...\n" + ex.Message);
                timer.Stop();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\nType: " + ex.GetType());
            }
        }