public void Save2019(Ciftci ciftci) { Validation(ciftci, () => { Database.EF.Dal2019 n = new Database.EF.Dal2019(); Entities.EF.liste2019 kayit = n.Where(I => I.tc == ciftci.tc).FirstOrDefault(); Entities.EF.liste2019 Sonkayit = n.GetAll().OrderByDescending(I => I.dilekceno).FirstOrDefault(); if (kayit == null) { n.CUDOperation(new Entities.EF.liste2019() { aciklama = ciftci.aciklama, dilekceno = Sonkayit.dilekceno + 1, isim = ciftci.isim, kayitdurumu = ciftci.KayitDurumu, mahalle = ciftci.mahalle, soyisim = ciftci.soyisim, tarih = Convert.ToDateTime(DateTime.Now.ToShortDateString()), tc = ciftci.tc, telefon = ciftci.telefon }, System.Data.Entity.EntityState.Added); int ReturnValue = n.SaveChange(); if (ReturnValue == 1) { MesajKutusu.information($"Kayıt işleminiz başarılı.\n2019 ÇKS Dilekçe Numarasi : {Sonkayit.dilekceno + 1}"); } } else { MesajKutusu.error("Aynı Tc Numarası ile kayıt mevcuttur."); } }); }
public void Delete(Ciftci Entity, string nameOfList) { DialogResult dr = MesajKutusu.Question($"{Entity.dilekceno} dilekce numaralı kaydı {nameOfList} listesinden silmek istiyor musunuz?"); if (dr == DialogResult.Yes) { string sql = "delete from " + nameOfList + " where dilekceno=@dilekceno"; _sqlCommand = new SqlCommand(sql); _sqlCommand.Parameters.AddWithValue("@dilekceno", SqlDbType.Int).Value = Entity.dilekceno; dll.AddUpdateDelete(_sqlCommand); } }
public void Save(Ciftci ciftci, string nameOfList) { Validation(ciftci, () => { //oncelikle gelen ciftci daha önce kayıt olmuş mu kontrolü yapılmalı. _data = Get(ciftci.tc, nameOfList); if (_data.tc == null) { _returnInt = 0; string sql = "insert into " + nameOfList + " (dilekceno,tc,isim,soyisim,mahalle,tarih,aciklama,telefon,kayitdurumu) values (@dilekceno,@tc,@isim,@soyisim,@mahalle,@tarih,@aciklama,@telefon,@kayitdurumu)"; string sql2 = "select max(dilekceno) from " + nameOfList + ""; _sqlCommand = new SqlCommand(sql2); _returnObject = dll.Get(_sqlCommand); int dilekceNumarasi = 0; if (_returnObject != null) { dilekceNumarasi = (int)_returnObject; } if (dilekceNumarasi >= 0) { _sqlCommand = new SqlCommand(sql); if (nameOfList != "DILEKCE2018" && nameOfList != "DILEKCE2019") { ciftci.dilekceno = dilekceNumarasi + 1; _sqlCommand.Parameters.AddWithValue("@dilekceno", SqlDbType.Int).Value = ciftci.dilekceno; } else { _sqlCommand.Parameters.AddWithValue("@dilekceno", SqlDbType.Int).Value = ciftci.dilekceno; } _sqlCommand.Parameters.AddWithValue("@tc", SqlDbType.NVarChar).Value = ciftci.tc; _sqlCommand.Parameters.AddWithValue("@isim", SqlDbType.NVarChar).Value = ciftci.isim; _sqlCommand.Parameters.AddWithValue("@soyisim", SqlDbType.NVarChar).Value = ciftci.soyisim; _sqlCommand.Parameters.AddWithValue("@mahalle", SqlDbType.NVarChar).Value = ciftci.mahalle; _sqlCommand.Parameters.AddWithValue("@tarih", SqlDbType.Date).Value = DateTime.Now; _sqlCommand.Parameters.AddWithValue("@aciklama", SqlDbType.NVarChar).Value = ciftci.aciklama.ToLower(); _sqlCommand.Parameters.AddWithValue("@telefon", SqlDbType.NVarChar).Value = ciftci.telefon; _sqlCommand.Parameters.AddWithValue("@kayitdurumu", SqlDbType.SmallInt).Value = ciftci.KayitDurumu; _returnInt = dll.AddUpdateDelete(_sqlCommand); } if (_returnInt > 0) { MesajKutusu.information($"Kayıt işleminiz başarılı.\n{nameOfList} Dilekçe Numarasi : {ciftci.dilekceno}"); } } else { MesajKutusu.error("Aynı Tc Numarası ile kayıt mevcuttur."); } }); }
public ActionResult MesajYaz(int id, int?mesajAtan, FormCollection form) { ViewBag.Id = id; ViewBag.mesajAtan = mesajAtan; string mesajım = Request.Form["mesaj"]; MesajKutusu mesaj = new MesajKutusu(); mesaj.ProfilNo = id; mesaj.MesajıAtan = (int)mesajAtan; mesaj.Mesaj = mesajım; db.MesajKutusus.Add(mesaj); db.SaveChanges(); return(View()); }
private void Validation(Ciftci ciftci, Action action) { try { var result = ciftciValidator.Validate(ciftci); if (result.Errors.Count > 0) { throw new ValidationException(result.ToString()); } action.Invoke(); } catch (Exception exception) { Logger.LogTryCatch.TryCatch(exception, "CiftciService-Save Method"); MesajKutusu.warning(exception.Message); } }
public void RestoreDBFromSQL() { OpenFileDialog OFD = new OpenFileDialog(); DialogResult dr = OFD.ShowDialog(); string KaynakYolu = OFD.FileName; if (!string.IsNullOrEmpty(KaynakYolu) && dr == DialogResult.OK) { string restoreCommand = @"USE master ALTER DATABASE Db_Tarim SET SINGLE_USER WITH ROLLBACK IMMEDIATE RESTORE DATABASE Db_Tarim FROM DISK = '" + KaynakYolu + "'";// --This rolls back all uncommitted transactions in the db. _sqlCommand = new SqlCommand(restoreCommand); _returnInt = dll.AddUpdateDelete(_sqlCommand); if (_returnInt > 0) { MesajKutusu.information("Restore işlemi başarıyla gerçekleşti"); } } }
public JsonResult mesajListele(int sayi, int mesajAtan, FormCollection form) { DatabaseContext db = new DatabaseContext(); //ViewBag.Id = sayi; //ViewBag.mesajAtan = mesajAtan; string mesajım = Request.Form["mesaj"]; MesajKutusu mesaj = new MesajKutusu(); mesaj.ProfilNo = sayi; mesaj.MesajıAtan = (int)mesajAtan; mesaj.Mesaj = mesajım; db.MesajKutusus.Add(mesaj); db.SaveChanges(); // var mesajKutusuList = db.MesajKutusus.Where(i => i.ProfilNo == sayi || i.ProfilNo == mesajAtan).OrderBy(i => i.Id).ToList(); List <MesajKutusu> Listem = db.MesajKutusus.ToList(); MesajKutusu MesajKutusus = Listem.LastOrDefault(); // MesajKutusus.Mesaj = mesajım; return(Json(MesajKutusus, JsonRequestBehavior.AllowGet)); }