コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string msg = "";

            if (txt_Name.Text.Trim() == "" || txt_Name.Text.Trim() == " ")
            {
                msg = "Invalid name";
            }
            else
            {
                if (current_action == "add")
                {
                    msg = SchoolYear.Add(txt_Name.Text.Trim());
                }
                else if (current_action == "edit")
                {
                    msg = SchoolYear.Edit(lst_schoolyear.SelectedItem.ToString(), txt_Name.Text);
                }
            }

            MessageBox.Show(msg, "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);

            if (msg.ToLower().Contains("success"))
            {
                current_action = "cancel";
                txt_Name.Clear();
                txtSearch.Clear();
                txtSearch.Focus();
                lst_schoolyear.SelectedIndex = -1;
                btn_setup(true, false, false, false, false);
                txt_lst_enable_disable(true, true, false);
                Get_schoolyear("");
            }
        }
コード例 #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            current_action = "delete";
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this School year?", "Deleting School year", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                string msg = SchoolYear.Delete(txt_Name.Text.Trim());
                if (msg.Contains("success"))
                {
                    MessageBox.Show(msg, "Deleted");
                    txt_Name.Clear();
                    txtSearch.Clear();
                    txtSearch.Focus();
                    lst_schoolyear.SelectedIndex = -1;
                    btn_setup(true, false, false, false, false);
                    txt_lst_enable_disable(true, true, false);
                    Get_schoolyear("");
                }
            }
        }