コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (lblStatus.ForeColor == Color.Red && lbltable.Text != "")
            {
                con = new Connect();
                string    nametable = lbltable.Text;
                DataTable dt        = new DataTable();

                dt = con.ExecStoreTable("RES_Select_BillID", new string[] { "@idtable" }, new object[] { Idtable(lbltable.Text) });

                if (dt.Rows[0].ItemArray[0].ToString() != "")
                {
                    int      id        = Convert.ToInt32(dt.Rows[0].ItemArray[0].ToString());
                    BillDish frmdetail = new BillDish(id, userid, nametable);
                    frmdetail.passControl = new BillDish.PassControl(GetTable);
                    DialogResult dr = frmdetail.ShowDialog(this);

                    if (dr == DialogResult.Cancel)
                    {
                        frmdetail.Close();
                    }
                    else if (dr == DialogResult.OK)
                    {
                        frmdetail.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("Bạn chưa chọn bàn để thêm món");
            }
        }
コード例 #2
0
        private void btnaddbill_Click(object sender, EventArgs e)
        {
            con = new Connect();
            Connect con3 = null;

            con3 = new Connect();
            int       id          = 0;
            DataTable _dt         = new DataTable();
            int       ssss        = 0;
            int       ggg         = 0;
            string    tablenumber = "";

            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is Panel)
                {
                    Panel tempanel = ctrl as Panel;
                    foreach (Control ctrl1 in tempanel.Controls)
                    {
                        if (ctrl1 is Panel)
                        {
                            Panel tempanel1 = ctrl1 as Panel;
                            foreach (Control ctrl12 in tempanel1.Controls)
                            {
                                if (ctrl12 is CheckBox)
                                {
                                    CheckBox tempCheckBox = ctrl12 as CheckBox;

                                    if (tempCheckBox.Checked == true)
                                    {
                                        tablenumber = tempCheckBox.Name.Remove(0, 3);
                                        ssss        = 1;
                                        id          = con.GetIDBill(userid);
                                        BillDish frmdetail = new BillDish(id, userid, tablenumber);
                                        //frmdetaol.MdiParent = this;
                                        DialogResult dr = frmdetail.ShowDialog(this);
                                        if (dr == DialogResult.Cancel)
                                        {
                                            frmdetail.Close();
                                        }
                                        else if (dr == DialogResult.OK)
                                        {
                                            frmdetail.Close();
                                        }
                                        break;
                                    }
                                }
                            }
                            foreach (Control ctrl2 in tempanel1.Controls)
                            {
                                if (ctrl2 is CheckBox)
                                {
                                    CheckBox tempCheckBox = ctrl2 as CheckBox;

                                    if (tempCheckBox.Checked == true)
                                    {
                                        foreach (Control ctrl3 in tempanel1.Controls)
                                        {
                                            if (ctrl3 is Button)
                                            {
                                                DataTable dt1 = new DataTable();
                                                dt1 = con.laybang("Select * from R_BillDish where BillID='" + id + "'");
                                                if (dt1.Rows.Count > 0)
                                                {
                                                    Button tempbutton = ctrl3 as Button;
                                                    tablenumber = tempCheckBox.Name.Remove(0, 3);
                                                    string s = "btn" + tempCheckBox.Name.Remove(0, 3);
                                                    if (tempbutton.Name == s)
                                                    {
                                                        tempbutton.BackColor = Color.Red;
                                                        tempCheckBox.Enabled = false;
                                                        tempCheckBox.Checked = false;
                                                        _dt = con3.laybang("Select * from R_Tables where TableNumber='" + tablenumber + "'");
                                                        int kq = con.xulydulieu("UPDATE R_Tables SET Status=1,TableOrder=0  WHERE TableNumber='" + tablenumber + "'");
                                                        con.xulydulieu("Delete from R_CustomerTable where TableID=(Select ID from R_Tables where TableNumber='" + tablenumber + "')");
                                                        string tablename = _dt.Rows[0]["TableName"].ToString();
                                                        int    idtable   = Convert.ToInt32(_dt.Rows[0]["ID"].ToString());
                                                        int    kq1       = con.SPInsertBillTable("Res_Insert_BillTable", idtable, id);
                                                        _dt.Dispose();
                                                        _dt.Clear();
                                                        GetQUantityTable();
                                                        lbltable.Text          = tablenumber;
                                                        lblStatus.Text         = "Bàn đã có khách";
                                                        lblStatus.ForeColor    = Color.Red;
                                                        lblTableName.Text      = tablename;
                                                        lblTableName.ForeColor = Color.Red;
                                                        //tempbutton.MouseUp += new MouseEventHandler(Control_DoubleClick);
                                                        GetTable();
                                                        ggg = 1;
                                                    }
                                                }
                                                else
                                                {
                                                    int kkkk = con.xulydulieu("Delete from R_Bill where ID='" + id + "'");
                                                    tempCheckBox.Checked = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (ssss == 0)
            {
                MessageBox.Show("Bạn chưa chọn bàn!", "Notice!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (ggg == 1)
            {
                con.Ghilog("Thêm hóa đơn cho bàn:'" + tablenumber + "'", userid);
            }
        }
コード例 #3
0
        private void Control_DoubleClick(object sender, MouseEventArgs e)
        {
            Button btn1      = sender as Button;
            string nametable = btn1.Name.Remove(0, 3);

            con = new Connect();
            DataTable _dt = new DataTable();

            _dt = con.laybang("Select * from R_Tables where TableNumber=N'" + nametable + "'");
            string status = _dt.Rows[0]["Status"].ToString();
            string order  = _dt.Rows[0]["TableOrder"].ToString();

            if (e.Button == MouseButtons.Right)
            {
                if (btn1.BackColor == Color.White)
                {
                    int ggg = 0;
                    if (status == "False" && order == "False")
                    {
                        int      id        = con.GetIDBill(userid);
                        BillDish frmdetail = new BillDish(id, userid, nametable);
                        //frmdetaol.MdiParent = this;
                        DialogResult dr = frmdetail.ShowDialog(this);
                        if (dr == DialogResult.Cancel)
                        {
                            frmdetail.Close();
                        }
                        else if (dr == DialogResult.OK)
                        {
                            frmdetail.Close();
                        }
                        DataTable dt1 = new DataTable();
                        dt1 = con.laybang("Select * from R_BillDish where BillID='" + id + "'");
                        if (dt1.Rows.Count > 0)
                        {
                            ggg = 1;
                            DataTable dt11 = new DataTable();
                            dt11 = con.laybang("Select * from R_Tables where TableNumber='" + nametable + "'");
                            int kq = con.xulydulieu("UPDATE R_Tables SET Status=1,TableOrder=0  WHERE TableNumber='" + nametable + "'");
                            con.xulydulieu("Delete from R_CustomerTable where TableID=(Select ID from R_Tables where TableNumber='" + nametable + "')");
                            string tablename = _dt.Rows[0]["TableName"].ToString();
                            int    idtable   = Convert.ToInt32(_dt.Rows[0]["ID"].ToString());
                            int    kq1       = con.SPInsertBillTable("Res_Insert_BillTable", idtable, id);
                            dt11.Dispose();
                            dt11.Clear();
                            btn1.BackColor = Color.Red;
                            GetQUantityTable();
                            lbltable.Text          = nametable;
                            lblStatus.Text         = "Bàn đã có khách";
                            lblStatus.ForeColor    = Color.Red;
                            lblTableName.Text      = tablename;
                            lblTableName.ForeColor = Color.Red;
                            GetTable();
                            foreach (Control ctrl in this.Controls)
                            {
                                if (ctrl is Panel)
                                {
                                    Panel tempanel = ctrl as Panel;
                                    foreach (Control ctrl1 in tempanel.Controls)
                                    {
                                        if (ctrl1 is Panel)
                                        {
                                            Panel tempanel1 = ctrl1 as Panel;
                                            foreach (Control ctrl12 in tempanel1.Controls)
                                            {
                                                if (ctrl12 is CheckBox)
                                                {
                                                    CheckBox tempCheckBox = ctrl12 as CheckBox;
                                                    string   nameBox      = "ckb" + nametable;
                                                    if (tempCheckBox.Name == nameBox)
                                                    {
                                                        tempCheckBox.Enabled = false;
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            int kkkk = con.xulydulieu("Delete from R_Bill where ID='" + id + "'");
                        }
                    }
                    if (ggg == 1)
                    {
                        con.Ghilog("Thêm hóa đơn cho bàn:'" + nametable + "'", userid);
                    }
                }
                else if (btn1.BackColor == Color.Red)
                {
                    if (status == "True" && order == "False")
                    {
                        DataTable dt = new DataTable();

                        dt = con.ExecStoreTable("RES_Select_BillID", new string[] { "@idtable" }, new object[] { Idtable(nametable) });

                        if (dt.Rows[0].ItemArray[0].ToString() != "")
                        {
                            int id = Convert.ToInt32(dt.Rows[0].ItemArray[0].ToString());
                            lbltable.Text          = nametable;
                            lblStatus.Text         = "Bàn đã có khách";
                            lblStatus.ForeColor    = Color.Red;
                            lblTableName.Text      = btn1.Text;
                            lblTableName.ForeColor = Color.Red;
                            BillDish frmdetail = new BillDish(id, userid, nametable);
                            frmdetail.passControl = new BillDish.PassControl(GetTable);
                            DialogResult dr = frmdetail.ShowDialog(this);

                            if (dr == DialogResult.Cancel)
                            {
                                frmdetail.Close();
                            }
                            else if (dr == DialogResult.OK)
                            {
                                frmdetail.Close();
                            }
                        }
                    }
                }
                else
                {
                    if (status == "False" && order == "True")
                    {
                        if (btn1.BackColor == Color.Yellow)
                        {
                            DataTable dt = new DataTable();
                            dt = con.laybang("select MAX(CustomerID) from R_CustomerTable where TableID=(Select ID from R_Tables where TableNumber='" + nametable + "'and TableOrder=1)");
                            if (dt.Rows[0]["Column1"].ToString() != "")
                            {
                                int      idd      = Convert.ToInt32(dt.Rows[0]["Column1"].ToString());
                                Customer customer = new Customer(idd, nametable, userid);
                                //frmdetaol.MdiParent = this;
                                DialogResult dr = customer.ShowDialog(this);
                                if (dr == DialogResult.Cancel)
                                {
                                    customer.Close();
                                }
                                else if (dr == DialogResult.OK)
                                {
                                    customer.Close();
                                }
                            }
                        }
                    }
                }
            }
        }