Ejemplo n.º 1
0
        public string Post(Tb_Penerima_Sertifikat tbps)
        {
            try
            {
                string query = @"
                        INSERT INTO [dbo].[Tb_Penerima_Sertifikat]
                              ([Kode_Penerima_Sertifikat]
                              ,[Nomer_Lisensi]
                              ,[Kode_KK]
                              ,[Tahun_pelajaran]
                              ,[Jumlah_penerima_sertifikat])
                        VALUES"
                               + "('" + tbps.Kode_Penerima_Sertifikat + "','" + tbps.Nomer_Lisensi + "','" + tbps.Kode_KK + "','" + tbps.Tahun_pelajaran + "','" + tbps.Jumlah_penerima_sertifikat + "')";

                DataTable table = new DataTable();
                using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LSPdb"].ConnectionString))
                {
                    using (var cmd = new SqlCommand(query, conn))
                    {
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }
                    }
                }
                return("Insert Successfully");
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }
Ejemplo n.º 2
0
        public string Put(Tb_Penerima_Sertifikat tbps)
        {
            try
            {
                string query = @"
                        UPDATE [dbo].[Tb_Penerima_Sertifikat] SET "
                               + "           ,[Nomer_Lisensi] = '" + tbps.Nomer_Lisensi + "'"
                               + "           ,[Kode_KK] = '" + tbps.Kode_KK + "'"
                               + "           ,[Tahun_pelajaran] = '" + tbps.Tahun_pelajaran + "'"
                               + "           ,[Jumlah_penerima_sertifikat] = '" + tbps.Jumlah_penerima_sertifikat + "'"
                               + "      WHERE [Kode_Penerima_Sertifikat] = '" + tbps.Kode_Penerima_Sertifikat + "' ";

                DataTable table = new DataTable();
                using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LSPdb"].ConnectionString))
                {
                    using (var cmd = new SqlCommand(query, conn))
                    {
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }
                    }
                }

                return("Update Successfully");
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }