コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: AdminBLL.cs プロジェクト: xmp01/Library
        public bool addReader(Dictionary <string, string> kv)
        {
            ReaderDAL readerDAL = new ReaderDAL();

            return(readerDAL.addReader(kv));
        }