public List <reader> getReaders() { ReaderDAL readerDAL = new ReaderDAL(); List <reader> readerList; readerList = readerDAL.getReaderList(); return(readerList); }
private void btnAdd_Click(object sender, EventArgs e) { ReaderBLL readerBLL = new ReaderBLL(); readerBLL.Name = this.txtDocgia.Text; readerBLL.Code = Convert.ToInt64(this.txtMadocgia.Text); readerBLL.Phone = this.txtPhone.Text; readerBLL.Email = this.txtEmail.Text; readerBLL.Address = this.txtDc.Text; readerBLL.Allocateddate = Convert.ToDateTime(this.txtNgaycap.Text); readerBLL.Enddate = Convert.ToDateTime(this.txtNgahet.Text); readerBLL.Birthday = Convert.ToDateTime(this.txtBirthday.Text); readerBLL.IsStaff = Convert.ToBoolean(this.cboStaff.Text); readerBLL.Granduation = Convert.ToInt32(this.cboGranduationyear.Text); if (readerBLL.Name == "" || readerBLL.Code == null || readerBLL.Phone == "" || readerBLL.Email == "" || readerBLL.Address == "" || readerBLL.Allocateddate == null || readerBLL.Enddate == null || readerBLL.Birthday == null) { MessageBox.Show("You mustn't empty any fields", "Notice"); return; } if (!IsNumber(readerBLL.Code.ToString()) || !IsNumber(readerBLL.Granduation.ToString())) { MessageBox.Show("Both of \"Reader Code\" and \"Granduation year\" must be the number format!"); return; } if (!IsAllAlphabetic(readerBLL.Name)) { MessageBox.Show("The \"Reader Name\" must be the character format!"); return; } if (!IsNumber(readerBLL.Phone)) { MessageBox.Show("the \"Phone Number\" mustn't have the letters!"); return; } /*if(ReaderDAL.getReaderItem(readerBLL) != null) * { * MessageBox.Show("The \"Reader Code\" Existed!"); * return; * }*/ List <ReaderBLL> readerList = new List <ReaderBLL>(); readerList = ReaderDAL.getReaderList(); foreach (ReaderBLL row in readerList) { //MessageBox.Show(row.IsStaff.ToString()); if (readerBLL.Code == row.Code) { MessageBox.Show("The \"Reader Code\" Existed!"); return; } } //isExist("123"); ReaderDAL.addReader(readerBLL); MessageBox.Show("Add success!", "Success"); this.LoadDataToDataGridView(); }
private void LoadDataToDataGridView() { this.dgvReader.Rows.Clear(); List <ReaderBLL> readerList = new List <ReaderBLL>(); readerList = ReaderDAL.getReaderList(); foreach (ReaderBLL row in readerList) { //MessageBox.Show(row.IsStaff.ToString()); this.dgvReader.Rows.Add(row.Code, row.Name, row.Address, row.Phone, row.Email, row.Allocateddate.ToShortDateString(), row.Enddate.ToShortDateString(), row.Birthday.ToShortDateString(), row.IsStaff, row.Granduation); } this.dgvReader.SelectionChanged += new EventHandler(dgvReader_SelectionChanged); GetSelectedValue(); }