Пример #1
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            imzaSistemiDBContext ctx = new imzaSistemiDBContext();

            if (Session["id"] != null)
            {
                int id = int.Parse(Session["id"].ToString());
                if (resimyukle.HasFile)
                {
                    string fileName = resimyukle.FileName;
                    Guid   G        = Guid.NewGuid();
                    string yol      = G + "-u-" + resimyukle.FileName;
                    Image1.ImageUrl = "~/Forms/images/" + yol;
                    resimyukle.SaveAs(Server.MapPath("~/Forms/images/" + yol));

                    var resim = ctx.tblUsers.First(x => x.Id == id);
                    resim.Fotograf = "~/Forms/images/" + yol;
                    ctx.SaveChanges();
                }
                else
                {
                    Response.Write("Lütfen Yüklenecek Bir Resim Seçiniz.");
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Page.Form.DefaultButton = btnVisible.UniqueID;

            imzaSistemiDBContext ctx = new imzaSistemiDBContext();

            if (Session["iid"] != null && Session["Login_onay1"].ToString() == "OK")
            {
                int id    = int.Parse(Session["iid"].ToString());
                var qUser = ctx.tbIdariPersonels.Where(x => x.PID == id).FirstOrDefault();
                labAdSoyad.Text = " " + qUser.Ad + "  " + qUser.Soyad;

                //hocanın Ad Soyad Tc Bilgilerini al ve dizilere aktar-->
                string[] foto = new string[1];

                var fot = from f in ctx.tbIdariPersonels where (f.PID == id)select new { fotograf = f.Fotograf };
                foreach (var qf in fot)
                {
                    foto[0] = qf.fotograf.ToString();
                }//<--
                imFoto.ImageUrl = foto[0];
            }
            else
            {
                Response.Redirect("idariLogin.aspx");
            }
        }
        private bool IsvalidUser(string userName, string password)
        {
            imzaSistemiDBContext ctx = new imzaSistemiDBContext();

            var q1 = from p in ctx.tbIdariPersonels
                     where p.Kullanici_Ad == userName &&
                     p.Password == password
                     select p;

            if (q1.Any())
            {
                var q2 = ctx.tbIdariPersonels.Where(x => x.Kullanici_Ad == userName && x.Password == password).FirstOrDefault();
                Session["iid"] = q2.PID;

                return(true);
            }
            else
            {
                return(false);
            }
        }