Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string insertQuery = "INSERT INTO tblEmployees(FirstName, MiddleName, LastName, PositionID, " +
                                 "BDate, Gender, HomeAddress, TelNo, MobileNo, EmailAddress)" +
                                 "VALUES('" + txtFirstName.Text + "','" + txtMiddleName.Text + "'," +
                                 "'" + txtLastName.Text + "','" + getPositionID(cmbPosition.Text) + "'," +
                                 "'" + Convert.ToDateTime(dtBDate.Text).ToString("yyyy/MM/dd") + "'," +
                                 "'" + cmbGender.Text + "','" + txtAddress.Text + "','" + txtTelephoneNo.Text + "'," +
                                 "'" + txtMobileNo.Text + "', '" + txtEmailAddress.Text + "'); ";

            DialogResult res = MessageBox.Show("Are you sure you want to save a new employee?",
                                               "Save Employee", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                int result = utilities.RunSQLCommand(insertQuery);
                if (result > 0)
                {
                    MessageBox.Show("New Employee added.", "Add Employee",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmShowEmployees.isNewEmployeeAdded = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("There is a problem saving a new employee.", "Add Employee",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtPositionName.Text.Trim().Equals(""))
            {
                MessageBox.Show("Please enter position name.", "Add Position",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string query = "INSERT into tblPosition(PositionName)" +
                    "VALUES('" + txtPositionName.Text + "')";

                int result = utilities.RunSQLCommand(query);

                if (result > 0)
                {
                    MessageBox.Show("New Position Name Added Successfully!", "Add Position",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                       txtPositionName.Text = "";
                }else
                {
                    MessageBox.Show("There is a problem saving a new Position", "Add Position",

                       MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
              
                }
            }

        }