コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dgvReader.SelectedCells.Count > 0)
            {
                int selectedrowindex = dgvReader.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = dgvReader.Rows[selectedrowindex];

                ReaderBLL readerBLL = new ReaderBLL(this.txtDocgia.Text, Convert.ToInt64(this.txtMadocgia.Text), this.txtDc.Text, this.txtPhone.Text, this.txtEmail.Text, Convert.ToDateTime(this.txtNgaycap.Text), Convert.ToDateTime(this.txtNgahet.Text), Convert.ToDateTime(this.txtBirthday.Text), Convert.ToBoolean(this.cboStaff.Text), Convert.ToInt32(this.cboGranduationyear.Text));
                //Int64 readerId = Int64.Parse(this.txtMadocgia.Text);
                if (this.txtDocgia.Text == "" || this.txtPhone.Text == "" || this.txtEmail.Text == "" || this.txtDc.Text == "" || this.txtNgaycap.Text == "" || this.txtNgahet.Text == "" || this.txtBirthday.Text == "")
                {
                    MessageBox.Show("You mustn't empty any fields", "Notice");
                    return;
                }
                if (!IsNumber(this.cboGranduationyear.Text))
                {
                    MessageBox.Show("Both of \"Reader Code\" and \"Granduation year\" must be the number format!");
                    return;
                }
                if (!IsAllAlphabetic(this.txtDocgia.Text))
                {
                    MessageBox.Show("The \"Reader Name\" must be the character format!");
                    return;
                }
                if (!IsNumber(this.txtPhone.Text))
                {
                    MessageBox.Show("the \"Phone Number\" mustn't have the letters!");
                    return;
                }
                ReaderDAL.updateReader(readerBLL); //MessageBox.Show(readerBLL.Code.ToString());
                MessageBox.Show("Update success!", "Success");
                this.LoadDataToDataGridView();
            }
        }