Exemple #1
0
        private void btAddRoom_Click_1(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            errorProvider2.Clear();
            errorProvider3.Clear();
            errorProvider4.Clear();

            if (txtNameRoom.Text == "")
            {
                errorProvider1.SetError(txtNameRoom, "not null!");
            }
            else if (txtKindRoom.Text == "")
            {
                errorProvider2.SetError(txtKindRoom, "not null!");
            }
            else if (txtBedsAmount.Text == "")
            {
                errorProvider3.SetError(txtBedsAmount, "not null!");
            }
            else if (txtCost.Text == "")
            {
                errorProvider4.SetError(txtCost, "not null!");
            }

            else
            {
                rmBus = new RoomBUS();
                RoomDTO rm = new RoomDTO();
                rm.Idr       = txtNameRoom.Text;
                rm.Name      = txtNameRoom.Text;
                rm.Roomkind  = txtKindRoom.Text;
                rm.Status    = "Empty";
                rm.Bedamount = int.Parse(txtBedsAmount.Text);
                rm.Cost      = Decimal.Parse(txtCost.Text);
                bool kq = rmBus.add(rm);
                if (kq == false)
                {
                    MessageBox.Show("Fail!");
                }
                else
                {
                    MessageBox.Show("Sussces");
                }
                this.loadData();
            }
        }