コード例 #1
0
ファイル: PersonelDb.cs プロジェクト: eceyildirim/FindIt
        public override void Insert(IEntity entity)
        {
            Personel newEmployee = (Personel)entity;

            Connect();
            command             = new SqlCommand("sp_SignUp", connection);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@name", newEmployee.Ad);
            command.Parameters.AddWithValue("@surname", newEmployee.Soyad);
            command.Parameters.AddWithValue("@tc", newEmployee.Tc);
            command.Parameters.AddWithValue("@password", newEmployee.Parola);
            command.Parameters.AddWithValue("@statu", 2);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (SqlException hata)
            {
                throw new Exception(hata.Message);
            }
            connection.Close();
            connection.Dispose();
        }
コード例 #2
0
        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["UserInformation"];

            if (cookie == null)
            {
                Personel p = new Personel();
                p.Tc     = textKullaniciAd.Text;
                p.Parola = textPasswordP.Text;
                PersonelDb db = new PersonelDb();
                db.Connect();
                db.command             = new SqlCommand("sp_LogIn", db.connection);
                db.command.CommandType = CommandType.StoredProcedure;
                db.command.Parameters.AddWithValue("@personelTC", p.Tc);
                db.command.Parameters.AddWithValue("@personelParola", p.Parola);

                SqlParameter kullaniciId = new SqlParameter("@personelID", SqlDbType.Int);
                kullaniciId.Direction = ParameterDirection.Output;
                db.command.Parameters.Add(kullaniciId);

                SqlParameter kullaniciStatu = new SqlParameter("@personelStatu", SqlDbType.Int);
                kullaniciStatu.Direction = ParameterDirection.Output;
                db.command.Parameters.Add(kullaniciStatu);

                SqlParameter kullaniciName = new SqlParameter("@personelAd", SqlDbType.NVarChar, 50);
                kullaniciName.Direction = ParameterDirection.Output;
                db.command.Parameters.Add(kullaniciName);

                SqlParameter kullaniciSurName = new SqlParameter("@personelSoyad", SqlDbType.NVarChar, 50);
                kullaniciSurName.Direction = ParameterDirection.Output;
                db.command.Parameters.Add(kullaniciSurName);

                try
                {
                    db.command.ExecuteNonQuery();
                }
                catch (Exception hata)
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('" + hata.Message.ToString() + "')</script>");
                }

                name      = kullaniciName.Value.ToString();
                surName   = kullaniciSurName.Value.ToString();
                userId    = kullaniciId.Value.ToString();
                userStatu = kullaniciStatu.Value.ToString();

                if (Convert.ToInt32(userId) > 0)
                {
                    HttpCookie cookies = new HttpCookie("UserInformation");
                    cookies["name"]      = name;
                    cookies["surname"]   = surName;
                    cookies["userID"]    = userId;
                    cookies["userStatu"] = userStatu;
                    cookies.Expires      = DateTime.Now.AddDays(1);
                    Response.Cookies.Add(cookies);
                    Response.Redirect("ProductOperations.aspx");
                }
                else
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Hatalı giriş! Tekrar Deneyin.')</script>");
                }
            }
            else
            {
                Response.Redirect("Search.aspx");
            }
        }