Exemple #1
0
        private void CommitLinqtoDb(List <Pendidikan_Pengajaran> VarPenelitianPengajaran)
        {
            string errMsg = "";

            _connection = _connect.Connect(_configurationManager, ref errMsg, "GhY873LhT");
            if (errMsg != "")
            {
                MessageBox.Show(errMsg);
                return;
            }
            var query = (from theThings in VarPenelitianPengajaran select theThings);
            MySqlTransaction _mysqlTrans = _connection.BeginTransaction();

            foreach (var things in query)
            {
                _sqlQuery = "insert into t_pendidikan_pengajaran values (null, " +
                            things.NoUrut + ",'" +
                            things.Unsur + "','" +
                            things.Waktu + "','" +
                            things.Sks + "','" +
                            things.Jam_sks + "','" +
                            things.Jam_smt + "','" +
                            things.Jam_bln + "','" +
                            things.H1 + "','" +
                            things.H2 + "','" +
                            things.H3 + "','" +
                            things.H4 + "','" +
                            things.H5 + "','" +
                            things.H6 + "','" +
                            things.H7 + "','" +
                            things.H8 + "','" +
                            things.H9 + "','" +
                            things.H10 + "','" +
                            things.H11 + "','" +
                            things.H12 + "','" +
                            things.H13 + "','" +
                            things.H14 + "','" +
                            things.H15 + "','" +
                            things.H16 + "','" +
                            things.H17 + "','" +
                            things.H18 + "','" +
                            things.H19 + "','" +
                            things.H20 + "','" +
                            things.H21 + "','" +
                            things.H22 + "','" +
                            things.IdUser + "','" +
                            things.Tanggal + "', '" +
                            things.Nama_bulan + "','" +
                            things.Nama_tahun + "', " +
                            things.StatusTP + ");";
                Clipboard.SetText(_sqlQuery);

                _connect.Insertion(_sqlQuery, _connection, _mysqlTrans, ref errMsg);
            }

            if (errMsg != "")
            {
                _mysqlTrans.Rollback();
                MessageBox.Show(errMsg);
                return;
            }
            _mysqlTrans.Commit();
            MessageBox.Show("Data Tersimpan");
            _connection.Close();
        }
Exemple #2
0
        private void CommitLinqtoDb(List <Pendidikan_Pengajaran_Init> VarPenelitianPengajaran)
        {
            string errMsg = "";

            _connection = _connect.Connect(_configurationManager, ref errMsg, "GhY873LhT");
            if (errMsg != "")
            {
                MessageBox.Show(errMsg);
                return;
            }
            var query = (from theThings in VarPenelitianPengajaran select theThings);
            MySqlTransaction _mysqlTrans = _connection.BeginTransaction();
            int noUrut = lvTampil.Items.Count + 1;

            foreach (var things in query)
            {
                _sqlQuery = "insert into t_pendidikan_pengajaran_init (noUrut, unsur, waktu, sks, jam_sks, jam_smt, jam_bln, idUser, tanggal, nama_bulan, nama_tahun, status) " +
                            "values (" + noUrut++ + ",'" + things.Unsur + "','" + things.Waktu + "','" + things.Sks + "','" + things.Jam_sks + "','" + things.Jam_smt +
                            "','" + things.Jam_bln + "','" + things.IdUser + "','" + things.Tanggal + "', '" + things.Nama_bulan + "','" + things.Nama_tahun + "', " + things.StatusTP + ");";
                //Clipboard.SetText(_sqlQuery);

                _connect.Insertion(_sqlQuery, _connection, _mysqlTrans, ref errMsg);

                //_sqlQuery = "insert into t_pendidikan_pengajaran_init (noUrut, unsur, waktu, sks, jam_sks, jam_smt, jam_bln, idUser, tanggal, nama_bulan, nama_tahun, status) " +
                //    "values (@noUrut, @unsur, @waktu, @sks, @jam_sks, @jam_smt, @jam_bln, @idUser, @tanggal, @nama_bulan, @nama_tahun, @status);";

                //MySqlCommand insertCommand = new MySqlCommand(_sqlQuery, _connection, _mysqlTrans);
                //MySqlParameter param1 = new MySqlParameter("@noUrut", MySqlDbType.Int16);
                //param1.Value = noUrut++;
                //insertCommand.Parameters.Add(param1);

                //MySqlParameter param2 = new MySqlParameter("@unsur", MySqlDbType.VarChar);
                //param1.Value = things.Unsur;
                //insertCommand.Parameters.Add(param2);

                //MySqlParameter param3 = new MySqlParameter("@waktu", MySqlDbType.Int16);
                //param1.Value = things.Waktu;
                //insertCommand.Parameters.Add(param3);

                //MySqlParameter param4 = new MySqlParameter("@sks", MySqlDbType.Decimal);
                //param1.Value = things.Sks;
                //insertCommand.Parameters.Add(param4);

                //MySqlParameter param5 = new MySqlParameter("@jam_sks", MySqlDbType.Decimal);
                //param1.Value = things.Jam_sks;
                //insertCommand.Parameters.Add(param5);

                //MySqlParameter param6 = new MySqlParameter("@jam_smt", MySqlDbType.Decimal);
                //param1.Value = things.Jam_smt;
                //insertCommand.Parameters.Add(param6);

                //MySqlParameter param7 = new MySqlParameter("@jam_bln", MySqlDbType.Decimal);
                //param1.Value = things.Jam_bln;
                //insertCommand.Parameters.Add(param7);

                //MySqlParameter param8 = new MySqlParameter("@idUser", MySqlDbType.Int16);
                //param1.Value = things.IdUser;
                //insertCommand.Parameters.Add(param8);

                //MySqlParameter param9 = new MySqlParameter("@tanggal", MySqlDbType.DateTime);
                //param1.Value = things.Tanggal;
                //insertCommand.Parameters.Add(param9);

                //MySqlParameter param10 = new MySqlParameter("@nama_bulan", MySqlDbType.VarChar);
                //param1.Value = things.Nama_bulan;
                //insertCommand.Parameters.Add(param10);

                //MySqlParameter param11 = new MySqlParameter("@nama_tahun", MySqlDbType.VarChar);
                //param1.Value = things.Nama_tahun;
                //insertCommand.Parameters.Add(param11);

                //MySqlParameter param12 = new MySqlParameter("@status", MySqlDbType.Int16);
                //param1.Value = things.StatusTP;
                //insertCommand.Parameters.Add(param12);

                //insertCommand.ExecuteNonQuery();
            }

            if (errMsg != "")
            {
                _mysqlTrans.Rollback();
                MessageBox.Show(errMsg);
                return;
            }
            _mysqlTrans.Commit();
            MessageBox.Show("Data Tersimpan");
            _connection.Close();
        }