示例#1
0
        // On find button click
        private async void button1_Click(object sender, EventArgs e)
        {
            // Check if billID is filled
            if (billID == -1)
            {
                MessageBox.Show("Hãy nhập id hóa đơn!!!");
            }
            else
            {
                // Searching...
                label2.ForeColor = Color.BlueViolet;
                label2.Text      = "Đang tìm...";
                // Calling search API
                dynamic data = await api.GetBill(billID);

                if (data == null)
                {
                    label2.ForeColor = Color.Red;
                    label2.Text      = "Không tìm thấy hóa đơn !!!";
                }
                else
                {
                    if ((int)data.error_code == 0)
                    {
                        // Found BILL => making report to user
                        if (data.data.paid_at == null)
                        {
                            label2.ForeColor = Color.Red;
                            label2.Text      = "Chưa thanh toán !!!";
                        }
                        else
                        {
                            dynamic billInfo = BillInfo(data.data);

                            Report r = new Report(billInfo, (string)billInfo.staff.name, billInfo.end);
                            r.Show();

                            // Hide user controll
                            this.Dispose();
                            this.Hide();
                        }
                    }
                    else
                    {
                        label2.ForeColor = Color.Red;
                        label2.Text      = "Không tìm thấy hóa đơn !!!";
                    }
                }
            }
        }