예제 #1
0
        private void DeleteBtnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "";
                if (AddStafID.Text.Trim() == "")
                {
                    MessageBox.Show("Please Enter Employee ID");
                    AddStafID.Focus();
                    return;
                }
                query = "DELETE FROM Educational_Info WHERE StaffID = " + stfID;

                if (DbAccess.ExecuteToDB(query))
                {
                    if (stfID != 0)
                    {
                        MessageBox.Show("Delete Successfully!!!");
                    }
                    else
                    {
                        MessageBox.Show("Failed To Delete!!!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection Error!!!");
            }
            finally
            {
                Reset();
            }
        }
예제 #2
0
        private void SAveAdd_Click(object sender, EventArgs e)
        {
            string query = ""; int AnnonceKey = ((KeyValuePair <int, string>)AnnonceCombo.SelectedItem).Key;
            String AnnounceValue = ((KeyValuePair <int, string>)AnnonceCombo.SelectedItem).Value;

            if (AddStafID.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Staff ID");
                AddStafID.Focus();
                return;
            }

            if (AnnonceKey < 1)
            {
                MessageBox.Show("Please Enter Announce Type");
                AnnonceCombo.Focus();
                return;
            }
            if (AddDate.Text == "")
            {
                MessageBox.Show("Please Enter Announce Date");
                AddDate.Focus();
                return;
            }


            if (Addsubject.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Subject");
                Addsubject.Focus();
                return;
            }
            if (AddDescription.Text.Trim() == "")
            {
                MessageBox.Show("Please  Add Description ");
                AddDescription.Focus();
                return;
            }

            try
            {
                if (hidebox.Text == "")
                {
                    query = "INSERT INTO Announcement_Info(StaffID,AnnounceType,Date,Subject,Description) VALUES(" + Convert.ToInt32(AddStafID.Text) + ",  '" + AnnounceValue + "',  '" + AddDate.Value.ToString("yyyy/MM/dd") + "', '" + Addsubject.Text + "', '" + AddDescription.Text + "' )";
                }


                else
                {
                    query = "UPDATE Announcement_Info SET AnnounceType = '" + AnnounceValue + "', Date = '" + AddDate.Text + "', Subject= '" + Addsubject.Text + "',Description = '" + Addsubject.Text + "' WHERE Id = " + Convert.ToInt32(hidebox.Text);
                }

                if (DbAccess.ExecuteToDB(query))
                {
                    if (hidebox.Text == "")
                    {
                        MessageBox.Show("Saved Successfully!!!");
                    }
                    else
                    {
                        MessageBox.Show("Updated Successfully!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Failed To Save!!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection Error!!!");
            }
            finally
            {
                Reset();
            }
        }