Beispiel #1
0
        private void timKiem_Click(object sender, EventArgs e)
        {
            int               i = 0, finder = 0;
            string            sKeyword    = maCayTB.Text.Trim();
            List <CaycanhDTO> listcayCanh = cayBus.selectByKeyWord(sKeyword);

            for (i = 0; i < listcayCanh.Count(); i++)
            {
                if (listcayCanh[i].MaCayCanhPT == sKeyword)
                {
                    finder = i;
                    break;
                }
                else
                {
                    finder = -1;
                }
            }
            if (listcayCanh == null)
            {
                finder = -1;
            }
            if (finder != -1)
            {
                MessageBox.Show("Có cây cần tìm trong danh sách");
                maChamSocTB.ReadOnly = false;
                gioTB.ReadOnly       = false;
                PhutTB.ReadOnly      = false;
                soLuongTB.ReadOnly   = false;
                ghiChuTB.ReadOnly    = false;
                soLuongTB.ReadOnly   = false;
                loadMaVatTu_Combobox();
                Donvi_Combobox();
            }
            else
            {
                MessageBox.Show("Không có cây cần tìm trong danh sách. Vui lòng kiểm tra lại trong danh sách");
                maChamSocTB.ReadOnly = true;
                gioTB.ReadOnly       = true;
                PhutTB.ReadOnly      = true;

                soLuongTB.ReadOnly = true;
                ghiChuTB.ReadOnly  = true;
                soLuongTB.ReadOnly = true;
            }
        }
        private void TimButton_Click(object sender, EventArgs e)
        {
            int               i           = 0;
            string            sKeyword    = MaCayTB.Text.Trim();
            List <CaycanhDTO> listcayCanh = cayBus.selectByKeyWord(sKeyword);

            if (listcayCanh == null || listcayCanh.Count == 0)
            {
                MessageBox.Show("Không tìm thấy cây cảnh cần cập nhận");
                return;
            }
            if (sKeyword == "")
            {
                MessageBox.Show("Vui lòng nhập mã cây");
                return;
            }
            for (i = 0; i < listcayCanh.Count; i++)
            {
                if (listcayCanh[i].MaCayCanhPT == sKeyword)
                {
                    vitricu = i;
                    TenCaytb.ResetText();
                    loadViTriVao_Combobox(listcayCanh[i].MaViTriPT - 1);
                    loadLoaiCayVao_Combobox(listcayCanh[i].MaLoaiCayCanhPT - 1);
                    loadTinhTrangVao_Combobox(listcayCanh[i].TinhTrangPT - 1);
                    TenCaytb.AppendText(listcayCanh[i].TenCayPT);
                    TenCaytb.ReadOnly = false;
                    MaCayTB.ReadOnly  = true;
                    MessageBox.Show("Tìm được cần sửa.Đã sẵn sàng cập nhận");
                    break;
                }
                else
                {
                    MessageBox.Show("Không tìm thấy cây cảnh cần cập nhận");
                }
            }
        }