コード例 #1
0
        private void AdmSavebutton_Click(object sender, EventArgs e)
        {
            if (AdmBranchCodetextBox.Text == "" && StudentNametextBox.Text == "")
            {
                MessageBox.Show("Please Enter Branch Code and Student Name.");
            }
            else
            {
                try
                {
                    SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=lingo_Database;Integrated Security=True");
                    con.Open();
                    SqlCommand cmd = new SqlCommand("insert into Lingo$(Branch_Code,Adm_Date,Student_Name,Father_Name,Gender,Contact_No,Whatsapp_no,Fecebook_Id,Department,Program,Teacher,Timing,Due_Date,StudentStatus)values('" + AdmBranchCodetextBox.Text + "','" + DateOfAdmissiondateTimePicker.Text + "','" + StudentNametextBox.Text + "','" + FatherNametextBox.Text + "','" + GendercomboBox.Text + "','" + ContactNotextBox.Text + "','" + WhatsAppNotextBox.Text + "','" + FaceBookIDtextBox.Text + "','" + DepartmentcomboBox.Text + "','" + ProgramNamecomboBox.Text + "','" + TeacherNamecomboBox.Text + "','" + ClassTimingcomboBox.Text + "','" + DueDatedateTimePicker.Text + "','" + AdmStudentStatuscomboBox.Text + "')", con);
                    cmd.ExecuteNonQuery();
                    SqlDataAdapter sda = new SqlDataAdapter("select * from Lingo$ where Student_Id='" + AdmStudentIdextBox.Text + "'", con);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    dataGridView1.DataSource = dt;

                    SqlCommand cmd1 = new SqlCommand("SELECT top(1)Student_Id from Lingo$ ORDER BY Student_Id DESC", con);

                    var a1 = cmd1.ExecuteScalar();
                    LastIDlabel.Text = a1.ToString();

                    MessageBox.Show("Data Saved into Database");

                    AdmStudentIdextBox.Text            = "";
                    AdmBranchCodetextBox.Text          = "";
                    DateOfAdmissiondateTimePicker.Text = "";
                    StudentNametextBox.Text            = "";
                    FatherNametextBox.Text             = "";
                    GendercomboBox.Text           = "";
                    ContactNotextBox.Text         = "";
                    WhatsAppNotextBox.Text        = "";
                    FaceBookIDtextBox.Text        = "";
                    DepartmentcomboBox.Text       = "";
                    ProgramNamecomboBox.Text      = "";
                    TeacherNamecomboBox.Text      = "";
                    ClassTimingcomboBox.Text      = "";
                    DueDatedateTimePicker.Text    = "";
                    AdmStudentStatuscomboBox.Text = "";

                    con.Close();

                    CollectionForm s = new CollectionForm();
                    s.Show();
                }
                catch
                {
                    MessageBox.Show("Record Already Saved");
                }
            }
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            CollectionForm s = new CollectionForm();

            s.Show();
        }