//untuk insert atau update data tabel pedagang public static void insertorupdatepedagang(int idpedagang, string namapedagang, string alamatpedagang) { DataClasses1DataContext dc = new DataClasses1DataContext(); var caripedagang = (from p in dc.GetTable <pedagang>() where p.id == idpedagang select p).SingleOrDefault(); if (caripedagang == null) { try { Table <pedagang> datapedagang = accesor.Getpedagangtable(); pedagang pdg = new pedagang(); pdg.id = idpedagang; pdg.nama = namapedagang; pdg.alamat = alamatpedagang; datapedagang.InsertOnSubmit(pdg); datapedagang.Context.SubmitChanges(); } catch (Exception ex) { throw ex; } } else { try { caripedagang.nama = namapedagang; caripedagang.alamat = alamatpedagang; dc.SubmitChanges(); } catch (Exception ex) { throw ex; } } }
partial void Updatepedagang(pedagang instance);
partial void Deletepedagang(pedagang instance);
partial void Insertpedagang(pedagang instance);