Exemplo n.º 1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (check)
     {
         Roomdb db = new Roomdb();
         room.Beds    = Convert.ToInt32(txtbed.Text);
         room.FloorNo = Convert.ToInt32(txtfloorno.Text);
         room.Vacancy = Convert.ToInt32(txtvcancy.Text);
         if (db.Update(room))
         {
             MessageBox.Show("Record Update", "Done");
         }
     }
 }
Exemplo n.º 2
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtSearch.Text))
     {
         room.Id      = Convert.ToInt32(txtSearch.Text);
         room.Beds    = 0;
         room.FloorNo = 0;
         room.Vacancy = 0;
         Roomdb db = new Roomdb();
         if (db.search(ref room))
         {
             if (room.Id > 0)
             {
                 txtSearch.Text     = "" + room.Id;
                 beds.Visible       = true;
                 floorno.Visible    = true;
                 vcancy.Visible     = true;
                 txtbed.Visible     = true;
                 txtbed.Text        = "" + room.Beds;
                 txtfloorno.Visible = true;
                 txtfloorno.Text    = "" + room.FloorNo;
                 txtvcancy.Visible  = true;
                 txtvcancy.Text     = "" + room.Vacancy;
                 btnUpdate.Visible  = true;
                 btnDelete.Visible  = true;
                 check = true;
             }
         }
         else
         {
             MessageBox.Show("No Record Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         MessageBox.Show("ID Required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        private void Savebtn_Click(object sender, EventArgs e)
        {
            try
            {
                bool check = true;
                error.BlinkRate = 0;
                if (string.IsNullOrEmpty(txtBeds.Text) || (Convert.ToInt32(txtBeds.Text) < 3 || Convert.ToInt32(txtBeds.Text) > 10))
                {
                    error.SetError(txtBeds, "Range(3-10)");
                    check = false;
                }

                if (string.IsNullOrEmpty(txtVacancy.Text) || (Convert.ToInt32(txtVacancy.Text) < 0 || Convert.ToInt32(txtVacancy.Text) > Convert.ToInt32(txtBeds.Text)))
                {
                    error.SetError(txtVacancy, "Range(0-" + txtBeds.Text + ")");
                    check = false;
                }
                if (string.IsNullOrEmpty(txtFloorNumber.Text) || (Convert.ToInt32(txtFloorNumber.Text) < 1 || Convert.ToInt32(txtFloorNumber.Text) > 5))
                {
                    error.SetError(txtFloorNumber, "Range(1-5)");
                    check = false;
                }
                if (check)
                {
                    Room room = new Room();
                    room.Beds    = Convert.ToInt32(txtBeds.Text);
                    room.FloorNo = Convert.ToInt32(txtFloorNumber.Text);
                    room.Vacancy = Convert.ToInt32(txtVacancy.Text);
                    Roomdb r = new Roomdb();
                    r.insert(room);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Missing Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }