Ejemplo n.º 1
0
        private void BtnChair_Click(object sender, EventArgs e)
        {
            lbl_NameChair.Text = (sender as SimpleButton).Text;
            SimpleButton btn = (SimpleButton)sender;

            btn.ForeColor = System.Drawing.SystemColors.Highlight;
            txt_Number.Clear();
            txt_NameCus.Clear();
            dgv_DetailReceipt.Rows.Clear();
            string idChair = lbl_NameChair.Text.Substring(lbl_NameChair.Text.Length - 3, 3);

            //Kiem tra neu ghe dang mo thi cac button tuong ung se mo va load du lieu tuong ung
            if (CheckChairOpen("btnChair" + idChair))
            {
                ChairOpen_EnableControls();
                for (int i = 0; i < _listReceipt.Count; i++)
                {
                    if (_listReceipt[i].Chair.Equals(idChair))
                    {
                        //Load hoa don
                        txt_Number.Text = _listReceipt[i].Id;
                        Receipt temp = _receipt.GetReceipt(_listReceipt[i].Id);
                        txt_NameCus.Text = _cus.GetNameCus(temp.IDACCOUNT.ToString());

                        //Load chi tiet hoa don tuong ung
                        DataTable listDt = _dtreceipt.GetDTReceipt(_listReceipt[i].Id);
                        for (int j = 0; j < listDt.Rows.Count; j++)
                        {
                            string   idItem    = listDt.Rows[j][2].ToString();;
                            string   product   = _item.GetNameItem(listDt.Rows[j][2].ToString());                  //Lay ten san pham
                            string   unit      = _unit.GetNameUnit(_item.GetIdUnit(listDt.Rows[j][2].ToString())); //Lay ten don vi
                            string   price     = listDt.Rows[j][5].ToString();
                            string   idStaff   = listDt.Rows[j][1].ToString();
                            string   nameStaff = _staff.GetNameStaff(listDt.Rows[j][1].ToString());//Lay ten nhan vien
                            string   num       = listDt.Rows[j][4].ToString();;
                            string   saleoff   = listDt.Rows[j][3].ToString();
                            string   total     = listDt.Rows[j][6].ToString();
                            string[] row       = new string[] { idItem, product, unit, num, price, saleoff, total, idStaff, nameStaff };
                            dgv_DetailReceipt.Rows.Add(row);
                        }
                        break;
                    }
                }
                //Tinh tien lai
                SumMoney();
            }
            else
            {
                ChairClose_EnableControls();
                txt_IntoMoney.Text = "0";
                txt_Sale.Text      = "0";
                txt_MoneySale.Text = (float.Parse(txt_IntoMoney.Text) * (float.Parse(txt_Sale.Text) / 100)).ToString();
                txt_Total.Text     = (float.Parse(txt_IntoMoney.Text) - float.Parse(txt_MoneySale.Text)).ToString();
            }
            //nguoc lai neu ghe dang dong thi cac button tuong ung se dong
        }