protected void btnKaydet1(object sender, EventArgs e) { pid = int.Parse(Request.QueryString["pid"]); using (stokEntities db = new stokEntities()) { // int varMi = db.users.Where(a => a.users_fname == txtad.Text && a.users_lname == txtsoyad.Text).Count(); if (string.IsNullOrWhiteSpace(txtad.Text) || string.IsNullOrWhiteSpace(txtPassword.Text) || string.IsNullOrWhiteSpace(txtsoyad.Text) || string.IsNullOrWhiteSpace(drpUsertype.SelectedValue)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); } else { users u = db.users.Find(pid); u.users_fname = txtad.Text; u.users_lname = txtsoyad.Text; u.users_mail = txtmail.Text; u.users_type = drpUsertype.SelectedValue; u.password = txtPassword.Text; u.degistirme_tarihi = Convert.ToDateTime(DateTime.Now); db.SaveChanges(); Response.Redirect("~/KullaniciYonetim.aspx"); } } }
protected void btnKaydet1(object sender, EventArgs e) { pid = int.Parse(Request.QueryString["pid"]); using (stokEntities db = new stokEntities()) { // int varMi = db.users.Where(a => a.users_fname == txtad.Text && a.users_lname == txtsoyad.Text).Count(); if (string.IsNullOrWhiteSpace(txtad.Text)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); } else { depo d = db.depo.Find(pid); d.depo_name = txtad.Text; db.SaveChanges(); Response.Redirect("~/DepoYonetim.aspx"); } } }
protected void btnKaydet1(object sender, EventArgs e) { pid = int.Parse(Request.QueryString["pid"]); using (stokEntities db = new stokEntities()) { // int varMi = db.users.Where(a => a.users_fname == txtad.Text && a.users_lname == txtsoyad.Text).Count(); if (string.IsNullOrWhiteSpace(txtad.Text)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); } else { product p = db.product.Find(pid); p.product_name = txtad.Text; // p.product_date = Convert.ToDateTime(txttarih.Text); p.degistirme_tarihi = Convert.ToDateTime(DateTime.Now); p.product_detail = txtdetay.Text; db.SaveChanges(); Response.Redirect("~/StokYonetim.aspx"); } } }
protected void btnsifre_Click(object sender, EventArgs e) { if (Session["ad"] == null) { Response.Redirect("Giris.aspx"); } kullaniciid = int.Parse(Session["id"].ToString()); using (stokEntities db = new stokEntities()) { if (string.IsNullOrWhiteSpace(txtpassword.Text)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); } else { users u = db.users.Find(kullaniciid); u.password = txtpassword.Text.Trim(); db.SaveChanges(); Session.Abandon(); ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Şifreniz başarılı bir şekilde değiştirildi.\\nGiriş sayfasına yönlendiriliyorsunuz.');window.location.assign('Giris.aspx')", true); } } }
protected void btnKaydet1(object sender, EventArgs e) { if (Session["ad"] == null) { Response.Redirect("Giris.aspx"); } kullaniciid = int.Parse(Session["id"].ToString()); using (stokEntities db = new stokEntities()) { if (string.IsNullOrWhiteSpace(txtad.Text) || string.IsNullOrWhiteSpace(txtsoyad.Text)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); } else { users u = db.users.Find(kullaniciid); u.users_fname = txtad.Text.Trim(); u.users_lname = txtsoyad.Text.Trim(); u.users_mail = txtmail.Text.Trim(); // u.password = txtPassword.Text.Trim(); u.degistirme_tarihi = Convert.ToDateTime(DateTime.Now); db.SaveChanges(); // Session.Abandon(); ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Bilgiler başarılı bir şekilde değiştirildi.')", true); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["ad"] != null) { kullaniciid = int.Parse(Session["id"].ToString()); if (!AdminMi()) { Response.Redirect("Giris.aspx"); } if (Request.QueryString["islem"] == "sil" && !string.IsNullOrEmpty(Request.QueryString["pid"].ToString())) { try { pid = int.Parse(Request.QueryString["pid"]); using (stokEntities db = new stokEntities()) { users u = db.users.Find(pid); if (u.users_type != "admin") { db.users.Remove(u); db.SaveChanges(); ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('İlgili Kullanıcı başarılı bir şekilde silindi.');window.location.assign('KullaniciYonetim.aspx')", true); } } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Veritabanı bağlantı hatası: " + ex.Message + "')", true); } } using (stokEntities db = new stokEntities()) { users usr = db.users.Find(kullaniciid); if (usr.users_type == "admin") { rptStok.DataSource = db.users.ToList(); rptStok.DataBind(); } else { rptStok.DataSource = db.users.Where(a => a.users_type == "misafir").ToList(); rptStok.DataBind(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["ad"] != null) { kullaniciid = int.Parse(Session["id"].ToString()); if (Request.QueryString["islem"] == "sil" && !string.IsNullOrEmpty(Request.QueryString["pid"].ToString())) { try { pid = int.Parse(Request.QueryString["pid"]); using (stokEntities db = new stokEntities()) { users u2 = db.users.Find(kullaniciid); if (u2.users_type != "admin") { ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('İlgili Kullanıcı Misafir olduğundan silemez.')", true); } else { product p = db.product.Find(pid); db.product.Remove(p); db.SaveChanges(); Response.Redirect("~/StokYonetim.aspx"); } } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Veritabanı bağlantı hatası: " + ex.Message + "')", true); } } } using (stokEntities db = new stokEntities()) { rptStok.DataSource = db.product.ToList(); rptStok.DataBind(); } }
protected void btnKaydet1(object sender, EventArgs e) { using (stokEntities db = new stokEntities()) { depo d = new depo(); d.depo_name = txtad.Text.Trim(); db.depo.Add(d); //var abc = db1.product.ToList(); db.SaveChanges(); Response.Write("Kayıt başarılı"); temizle(); Response.Redirect("~/DepoYonetim.aspx"); } }
protected void btnKaydet1(object sender, EventArgs e) { using (stokEntities db = new stokEntities()) { users u = new users(); int varMi = db.users.Where(a => a.users_fname == txtad.Text && a.users_lname == txtsoyad.Text).Count(); if (string.IsNullOrWhiteSpace(txtad.Text) || string.IsNullOrWhiteSpace(txtPassword.Text) || string.IsNullOrWhiteSpace(txtsoyad.Text) || string.IsNullOrWhiteSpace(drpUsertype.SelectedValue)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); temizle(); } else if (varMi == 1) { Response.Write("<script>alert('Kayıtlı zaten');</script>"); temizle(); } else { u.users_fname = txtad.Text.Trim(); u.users_lname = txtsoyad.Text.Trim(); u.users_mail = txtmail.Text.Trim(); u.users_type = drpUsertype.SelectedValue; u.password = txtPassword.Text.Trim(); u.u_tarih = Convert.ToDateTime(DateTime.Now); db.users.Add(u); //var abc = db1.product.ToList(); db.SaveChanges(); Response.Write("Kayıt başarılı"); temizle(); Response.Redirect("~/KullaniciYonetim.aspx"); } } }
protected void btnKaydet1(object sender, EventArgs e) { using (stokEntities db1 = new stokEntities()) { product p1 = new product(); p1.product_name = txtad.Text.Trim(); p1.product_date = Convert.ToDateTime(DateTime.Now); p1.degistirme_tarihi = Convert.ToDateTime(DateTime.Now); p1.product_detail = txtdetay.Text.Trim(); db1.product.Add(p1); //var abc = db1.product.ToList(); db1.SaveChanges(); Response.Write("Kayıt başarılı"); temizle(); Response.Redirect("~/StokYonetim.aspx"); } }
protected void btnKaydet1(object sender, EventArgs e) { using (stokEntities db = new stokEntities()) { users usr = new users(); int varMi = db.users.Where(a => a.users_fname == txtad.Text && a.users_lname == txtsoyad.Text).Count(); if (string.IsNullOrWhiteSpace(txtad.Text) || string.IsNullOrWhiteSpace(txtPassword.Text) || string.IsNullOrWhiteSpace(txtsoyad.Text) || string.IsNullOrWhiteSpace(drpUsertype.SelectedValue)) { Response.Write("<script>alert('Boşlukları Doldurun!');</script>"); temizle(); } else if (varMi == 1) { Response.Write("<script>alert('Kayıtlı zaten');</script>"); temizle(); } else { usr.users_fname = txtad.Text; usr.users_lname = txtsoyad.Text; usr.users_mail = txtmail.Text; usr.users_type = drpUsertype.SelectedValue; usr.password = txtPassword.Text; db.users.Add(usr); db.SaveChanges(); temizle(); Response.Redirect("~/Giris.aspx"); Response.Write("<script>alert('Kayıt Başarılı!');</script>"); } } }
protected void btnKaydet1(object sender, EventArgs e) { using (stokEntities db = new stokEntities()) { StkHareket stkHareket = new StkHareket(); //ölçü birimi ve hareket türü seçimleri yapılmamışsa hata ver if (string.IsNullOrWhiteSpace(drpHareket.SelectedValue) || string.IsNullOrWhiteSpace(drpStok.SelectedValue) || string.IsNullOrWhiteSpace(drpDepo.SelectedValue)) { ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Lütfen seçim yapınız!')", true); } //boş kalan alan yoksa... else { stkHareket.product_id = int.Parse(drpStok.SelectedValue); stkHareket.depo_id = int.Parse(drpDepo.SelectedValue); stkHareket.user_name = Session["ad"].ToString(); stkHareket.hareket_tarih = Convert.ToDateTime(DateTime.Now); stkHareket.stk_miktar = Convert.ToInt32(txtmiktar.Text); stkHareket.hareket_turu = drpHareket.SelectedValue; stkHareket.stk_olcu = txtolcubirim.Text; // stkdurum tablosunu güncelle int stkDurumVarMi = db.StkDurum.Where(a => a.depo_id == stkHareket.depo_id && a.product_id == stkHareket.product_id).Count(); // kayıt var mı diye kontrol et if (stkDurumVarMi > 0) { //önceki kaydın id sini bul int durumid = db.StkDurum.Where(a => a.depo_id == stkHareket.depo_id && a.product_id == stkHareket.product_id).FirstOrDefault().durum_id; StkDurum d = db.StkDurum.Find(durumid); //eğer işlem çıkışsa ve stoktaki miktardan fazlaysa işlemi yaptırma if (stkHareket.hareket_turu == "Cıkıs" && d.stk_miktar < stkHareket.stk_miktar) { string hatamesaj = "alert('En fazla " + d.stk_miktar.ToString() + " " + stkHareket.stk_olcu + " çıkış yapabilirsiniz');"; ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", hatamesaj, true); } //işlem çıkışsa ve stoktaki miktardan azsa miktarı güncelle else if (stkHareket.hareket_turu == "Cıkıs" && d.stk_miktar >= stkHareket.stk_miktar) { //Aynı üründen aynı ölçü birimiyle çıkış yapılırsa... //if (d.durum_olcu == stkHareket.stk_olcu) //{ d.stk_miktar = d.stk_miktar - stkHareket.stk_miktar; //stkHareket.stk_olcu = d.durum_olcu; db.StkHareket.Add(stkHareket); // stok hareketi eklendi db.SaveChanges(); ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Stok başarılı bir şekilde güncellendi.');window.location.assign('StokHareketListe.aspx')", true); // } //Aynı üründen farklı ölçü birimiyle çıkış yapılırsa... //else //{ // ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Ölçü Birimi Hatalı!')", true); //} } //işlem girişse güncelle else { //Aynı üründen aynı ölçü birimiyle giriş yapılırsa.. //if (d.durum_olcu == stkHareket.stk_olcu) //{ d.stk_miktar = d.stk_miktar + stkHareket.stk_miktar; //stkHareket.stk_olcu = d.durum_olcu; db.StkHareket.Add(stkHareket); // stok hareketi eklendi db.SaveChanges(); ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Stok başarılı bir şekilde güncellendi.');window.location.assign('StokHareketListe.aspx')", true); // } //Aynı üründen farklı ölçü birimiyle giriş yapılırsa... //else //{ // ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Ölçü Birimi Hatalı!')", true); //} } } // yeni stkDurum kaydı oluştur, girilen değeri miktara yaz else { //daha önce kayıt yok ve işlem girişse işlemi yaptır if (stkHareket.hareket_turu != "Cıkıs") { string mesaj = "alert('Stok eklendi!');"; StkDurum durum = new StkDurum(); durum.product_id = stkHareket.product_id; durum.depo_id = stkHareket.depo_id; durum.stk_miktar = stkHareket.stk_miktar; //durum.durum_olcu = stkHareket.stk_olcu; db.StkHareket.Add(stkHareket); // stok hareketi eklendi db.StkDurum.Add(durum); db.SaveChanges(); ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", mesaj + " window.location.assign('StokHareketListe.aspx');", true); } //yeni kayıt ve işlem çıkışsa işlemi yaptırma else { ClientScript.RegisterStartupScript(this.GetType(), "Bilgi", "alert('Depoda bu malzemeden bulunmadığından çıkış yapılamaz!')", true); } } } db.SaveChanges(); // Response.Redirect("StokHareketListe.aspx"); } }