コード例 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var en = new ManageAdminEntity();
            var re = new ManageAdminRepo();

            if (ValidateToUpdate() == true)
            {
                en.Id        = txtAid.Text;
                en.Name      = txtAname.Text;
                en.Age       = txtAage.Text;
                en.Sex       = txtAsex.Text;
                en.Reference = txtAreference.Text;
                en.Phone     = txtAphone.Text;
                en.Address   = txtAaddress.Text;

                if (MessageBox.Show("Are you sure ??", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                else
                {
                    re.Update(en);
                }
            }
            else
            {
                MessageBox.Show("Invalid Input");
            }
        }
コード例 #2
0
        public void Update(ManageAdminEntity en)
        {
            var sql = "update admin set name = '" + en.Name + "', age = '" + en.Age + "', sex = '" + en.Sex + "', reference = '" + en.Reference + "', phone = '" + en.Phone + "', address = '" + en.Address + "' where id = '" + en.Id + "';";
            var ex  = DataAccess.ExecuteQuery(sql);

            if (ex == 1)
            {
                MessageBox.Show("Updated");
            }
        }
コード例 #3
0
        public void Delete(ManageAdminEntity en)
        {
            var sql = "delete from admin where id = '" + en.Id + "';";
            var ex  = DataAccess.ExecuteQuery(sql);

            if (ex == 1)
            {
                MessageBox.Show("Deleted");
            }
        }
コード例 #4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var en = new ManageAdminEntity();
            var re = new ManageAdminRepo();

            if (ValidateToSave() == true)
            {
                en.Id    = txtId.Text;
                en.Name  = txtName.Text;
                en.Phone = txtPhone.Text;

                re.Search(en, mgvAdmin);
            }
            else
            {
                MessageBox.Show("Invalid Input");
            }
        }
コード例 #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (mgvAdmin.SelectedRows.Count != 1)
            {
                MessageBox.Show("Please select a row first.");
            }
            else
            {
                var en = new ManageAdminEntity();
                var re = new ManageAdminRepo();

                en.Id = mgvAdmin.CurrentRow.Cells["id"].Value.ToString();

                if (MessageBox.Show("Are you sure ??", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                else
                {
                    re.Delete(en);
                }
            }
        }
コード例 #6
0
        public void Search(ManageAdminEntity en, MetroGrid mgv)
        {
            var sql = "select id,name,age,sex,reference,address,phone from admin where id ='" + en.Id + "' or name ='" + en.Name + "' or phone = '" + en.Phone + "';  ";

            DataAccess.PopulateGridView(mgv, sql);
        }