示例#1
0
        public static void silMarka(int m1id)
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                List <int> query1 = (from mo in db.aracmodels
                                     where mo.markaID == m1id
                                     select mo.modelID).ToList();

                if (query1.Count == 0)
                {
                    var x = db.aracmarkas.Find(m1id);
                    db.aracmarkas.Remove(x);
                    db.SaveChanges();
                }

                else if (query1.Count != 0)
                {
                    int count1 = query1.Count;

                    for (int i = 0; i < count1; i++)
                    {
                        silModel(m1id, query1[i]);
                    }

                    var x = db.aracmarkas.Find(m1id);
                    db.aracmarkas.Remove(x);
                    db.SaveChanges();
                }
            }
        }
示例#2
0
        public static void silMusteri(int id)
        {
            Proje.DataAccess.otoservisdbEntities db = new Proje.DataAccess.otoservisdbEntities();
            using (db)
            {
                List <int> query1 = (from arac in db.aracs
                                     where arac.musteriID == id
                                     select arac.aracID).ToList();

                if (query1.Count == 0)
                {
                    musteri m = new musteri();
                    var     x = db.musteris.Find(id);
                    db.musteris.Remove(x);
                    db.SaveChanges();
                }

                else if (query1.Count != 0)
                {
                    int count1 = query1.Count;

                    for (int i = 0; i < count1; i++)
                    {
                        arackayit.silAracKayit(query1[i]);
                    }

                    var x = db.musteris.Find(id);
                    db.musteris.Remove(x);
                    db.SaveChanges();
                }
            }
        }
示例#3
0
        //*************************sadece markadaki islemler*****************************
        public static int ekleMarka(string m1)
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                List <int> query1 = (from ma in db.aracmarkas
                                     where ma.marka.Contains(m1)
                                     select ma.markaID).ToList();

                if (query1.Count == 0)
                {
                    aracmarka markaekle = new aracmarka();
                    markaekle.marka = m1;

                    db.aracmarkas.Add(markaekle);
                    db.SaveChanges();

                    return(1);
                }

                else
                {
                    return(2);
                }
            }
        }
示例#4
0
        public static int ekleModel(string m1, string m2)
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                List <int> query1 = (from ma in db.aracmarkas
                                     where ma.marka.Contains(m1)
                                     select ma.markaID).ToList();

                int m1id = Convert.ToInt32(query1[0]);

                List <string> query2 = (from mo in db.aracmodels
                                        where mo.model.Contains(m2)
                                        select mo.model).ToList();

                if (query2.Count == 0)
                {
                    aracmodel y = new aracmodel();
                    y.model   = m2;
                    y.markaID = m1id;

                    //db.aracmarkas.Add(x);
                    db.aracmodels.Add(y);
                    db.SaveChanges();

                    return(1);
                }
                else
                {
                    return(2);
                }
            }
        }
示例#5
0
        public static void silModel(int m1id, int m2id)
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                var x = db.aracmodels.Find(m2id, m1id);
                db.aracmodels.Remove(x);
                db.SaveChanges();
            }
        }
示例#6
0
        public static void guncelleModel(int m1id, int m2id, string m2)
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                var y = db.aracmodels.Find(m2id, m1id);
                y.model = m2;
                db.SaveChanges();
            }
        }
示例#7
0
        public static void guncelleMusteri(int id, string tc, string ad)
        {
            Proje.DataAccess.otoservisdbEntities db = new Proje.DataAccess.otoservisdbEntities();
            using (db)
            {
                var x = db.musteris.Find(id);

                x.tckn    = tc;
                x.adSoyad = ad;
                db.SaveChanges();
            }
        }
示例#8
0
        public static object GetMarkas()
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                var sorgu = from x in db.aracmarkas
                            select new { x.marka };

                return(sorgu.ToList());
            }
        }
示例#9
0
        public static void guncelleMarka(int m1id, string m1)
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                var x = db.aracmarkas.Find(m1id);

                x.marka = m1;
                db.SaveChanges();
            }
        }
示例#10
0
 public static void AddMusteri(string tc, string ad)
 {
     Proje.DataAccess.otoservisdbEntities db = new Proje.DataAccess.otoservisdbEntities();
     using (db)
     {
         musteri m = new musteri();
         //m.musteriID = id;
         m.tckn    = tc;
         m.adSoyad = ad;
         db.musteris.Add(m);
         db.SaveChanges();
     }
 }
示例#11
0
        //*************************sadece modeldeki islemler*****************************

        public static List <string> getModel()
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                var sorgu = from x in db.aracmodels
                            select x.model;

                List <string> liste = sorgu.ToList();

                return(liste);
            }
        }
示例#12
0
        // ÖNEMLİ NOT!! eğer linq değil aşağıdaki gibi procedure ile direkt sorgu çalıştırıyorsan bunu
        // direkt bir objeye ya da listeye atamıyosun, önce aşağıdaki gibi bir var tipine atıp listeye dönüştürmen lazım.

        /* public static object GetMarkaModels1()
         * {
         *  otoservisdbEntities db = new otoservisdbEntities();
         *  using (db)
         *  {
         *      var liste = db.MARKAMODELLISTESI();
         *      return liste.ToList();
         *  }
         * } */

        //deneme

        /*public object GetMarkaModels2()
         * {
         *  otoservisdbEntities db = new otoservisdbEntities();
         *  using (db)
         *  {
         *      //return db.aracmodels.Where(x => x.model == "Clio" || x.model =="Megane").ToList();
         *      return db.aracmodels.Where(x => x.model.Contains("Cl") || x.model.Contains("Meg")).ToList();
         *  }
         * }*/



        //Bazılarında referans 0 gözüküyor ancak başta listelerin için doldurmak için kullanılıyor, silme.
        public object GetMarkaModels()
        {
            otoservisdbEntities db = new otoservisdbEntities();

            using (db)
            {
                var sorgu = from d1 in db.aracmarkas
                            join d2 in db.aracmodels
                            on d1.markaID equals d2.markaID
                            select new { d1.marka, d2.model };

                //into tumsutunlar
                //from x in tumsutunlar
                //select x;

                return(sorgu.ToList());
            }
        }