private void saveButton_Click_1(object sender, EventArgs e)
        {
            try
            {
                SqlConnection connection = new SqlConnection(connectionString);

                connection.Open();

                if (fullNameTextBox.Text == String.Empty)
                {
                    fullNameTextBox.Text = "Please Enter Name";
                }

                else if (EmailValidation.CheckForMail(emailTextbox.Text))
                {
                    string query = string.Format(@"insert into administration values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')"
                                                 , idTextBox.Text,
                                                 fullNameTextBox.Text,
                                                 sexComboBox.Text,
                                                 presentTextBox.Text,
                                                 permanentTextBox.Text,
                                                 departmentComboBox.Text,
                                                 joiningdateTimePickerBox.Value.Date,
                                                 resigningdateTimePickerBox.Value.Date,
                                                 mobileTextbox.Text,
                                                 emailTextbox.Text);

                    SqlCommand command = new SqlCommand(query, connection);

                    int rows = command.ExecuteNonQuery();
                    if (rows > 0)
                    {
                        MessageBox.Show("Data Saved Succsfully !", "Successful Notice Window", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        connection.Close();
                    }

                    else
                    {
                        MessageBox.Show("Data Not Saved", "Error Window", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                else
                {
                    emaillebelBox.Visible = true;
                    exampleBox.Visible    = true;

                    emaillebelBox.Text = "Please Enter Accurate Mail Format.Example:";
                    exampleBox.Text    = "*****@*****.**";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void saveButton_Click(object sender, EventArgs e)

        {
            try
            {
                SqlConnection connection = new SqlConnection(connectionString);

                connection.Open();

                if (idTextBox.Text == String.Empty)
                {
                    idLebelBox.Visible = true;
                    idLebelBox.Text    = "Please Enter ID";
                }

                else if (TeacheremailTextBox.Text == String.Empty || EmailValidation.CheckForMail(TeacheremailTextBox.Text))
                {
                    string query = string.Format(@"insert into TeacharsEntry values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", this.idTextBox.Text, this.fullNametextBox.Text, this.permanentTextBox.Text, this.presentTextBox.Text,
                                                 this.honsTextBox.Text,
                                                 this.mscTextBox.Text, this.phdTextBox.Text, this.deptComboBox.Text, this.dateTimePickerBox.Text, this.mobileTextBox.Text,
                                                 this.TeacheremailTextBox.Text);


                    SqlCommand command = new SqlCommand();
                    command.Connection = connection;

                    command.CommandText = query;
                    DateTimePicker inputdate = dateTimePickerBox;


                    if (DateTime.Today > inputdate.Value)
                    {
                        int rows = command.ExecuteNonQuery();
                        if (rows > 0)
                        {
                            MessageBox.Show("Data Saved Succsfully");
                        }

                        else
                        {
                            MessageBox.Show("Data Not Saved");
                        }
                    }
                    else
                    {
                        MessageBox.Show("You Entered The Wrong Joning Date.\nJoining Date Does Not More Than Current Date and Time");
                    }
                }


                else
                {
                    exampleBox.Visible = true;
                    label11.Visible    = true;

                    label11.Text    = "Invalid Email:";
                    exampleBox.Text = "*****@*****.**";
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            try
            {
                int ssc;
                int hsc;


                bool sscresult = int.TryParse(sscTextBox.Text, out ssc);

                bool hscresult = int.TryParse(sscTextBox.Text, out hsc);

                SqlConnection connection = new SqlConnection(connectionString);

                connection.Open();

                if (fullNameTextBox.Text == String.Empty)
                {
                    idLebelBox.Visible = true;
                    idLebelBox.Text    = "Please Enter Name";
                }

                else if (rollTextBox.Text == String.Empty)
                {
                    idLebelBox.Visible = false;
                    rollLevel.Visible  = true;
                    rollLevel.Text     = "Please Enter Roll";
                }

                else if (registrationTextBox.Text == String.Empty)
                {
                    rollLevel.Visible = false;
                    regiLevel.Visible = true;

                    regiLevel.Text = "Please Enter Registration";
                }

                else if (ssc <= 0 || ssc > 5)
                {
                    regiLevel.Visible = false;
                    sscLevel.Visible  = true;
                    sscLevel.Text     = "Please Input upto 0 and less than 5";
                }
                else if (hsc <= 0 || hsc > 5)
                {
                    sscLevel.Visible = false;
                    HscLevel.Visible = true;
                    HscLevel.Text    = "Please Input upto 0 and less than 5";
                }


                else if (EmailValidation.CheckForMail(emailTextbox.Text))
                {
                    MemoryStream stream = new MemoryStream();

                    pictureBox3.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);

                    byte[] ima = stream.ToArray();

                    string query = string.Format(@"insert into GeneralStudent values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')"
                                                 , idTextBox.Text, fullNameTextBox.Text, @ima, sexComboBox.Text, presentTextBox.Text,
                                                 permanentTextBox.Text, rollTextBox.Text, registrationTextBox.Text,
                                                 departmentComboBox.Text, sessionComboBox.Text, sscTextBox.Text, hsctextbox.Text,
                                                 mobileTextbox.Text, familyTextBox.Text, emailTextbox.Text);

                    SqlCommand command = new SqlCommand(query, connection);
                    command.Parameters.Add(new SqlParameter("@ima", ima));

                    int rows = command.ExecuteNonQuery();
                    if (rows > 0)
                    {
                        MessageBox.Show("Data Saved Succsfully !", "Successful Notice Window", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        connection.Close();
                    }

                    else
                    {
                        MessageBox.Show("Data Not Saved", "Error Window", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                else
                {
                    emaillebelBox.Visible = true;
                    exampleBox.Visible    = true;

                    emaillebelBox.Text = "Please Enter Accurate Mail Format.Example:";
                    exampleBox.Text    = "*****@*****.**";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }