コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: ddw1234/EmpMan
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            objbel.USERNAME = txtUsername.Text;
            objbel.PASSWORD = txtPassword.Text;
            DataSet ds = new DataSet();

            try
            {
                ds = objbll.Loginuser(objbel);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Session["userid"] = Convert.ToInt32(ds.Tables[0].Rows[0]["userid"].ToString());
                    Response.Redirect("EmpDetail.aspx", false);
                }
                else
                {
                    lblstatus.Text      = "Invalid Username or Password";
                    lblstatus.ForeColor = System.Drawing.Color.Red;
                }
            }
            catch (Exception ex)
            {
                Response.Write("Error in code :" + ex.Message.ToString());
            }
            finally
            {
                objbel = null;
                objbll = null;
            }
        }
コード例 #2
0
        public DataSet Loginuser(Register_BEL objBEL)
        {
            DataSet ds = new DataSet();

            try
            {
                SqlCommand cmd = new SqlCommand("Select_Login_Details", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@username", objBEL.USERNAME);
                cmd.Parameters.AddWithValue("@password", objBEL.PASSWORD);
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(ds);
                cmd.Dispose();
                return(ds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }

                ds.Dispose();
            }
        }
コード例 #3
0
ファイル: Register.aspx.cs プロジェクト: ddw1234/EmpMan
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     objbel.USERNAME  = txtUsername.Text;
     objbel.PASSWORD  = txtPassword.Text;
     objbel.FIRSTNAME = Convert.ToString(txtfirstname.Text);
     try
     {
         int result = objbll.Saveuserpass(objbel);
         if (result > 0)
         {
             lblstatus.Text      = "Your login created successfully";
             lblstatus.ForeColor = System.Drawing.Color.Blue;
             ClearControl();
         }
         else
         {
             lblstatus.Text      = "Your login gets failed";
             lblstatus.ForeColor = System.Drawing.Color.Red;
         }
     }
     catch (Exception ex)
     {
         Response.Write("Error occured : " + ex.Message.ToString());
     }
     finally
     {
         objbel = null;
         objbll = null;
     }
 }
コード例 #4
0
ファイル: Register_BLL.cs プロジェクト: ddw1234/EmpMan
        public DataSet Loginuser(Register_BEL objbel)
        {
            Register_DAL objdal = new Register_DAL();

            try
            {
                return(objdal.Loginuser(objbel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objdal = null;
            }
        }
コード例 #5
0
ファイル: Register_BLL.cs プロジェクト: ddw1234/EmpMan
        public Int32 Saveuserpass(Register_BEL objbel)
        {
            Register_DAL objdal = new Register_DAL();

            try
            {
                return(objdal.Saveuserpass(objbel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objdal = null;
            }
        }
コード例 #6
0
        public Int32 Saveuserpass(Register_BEL objBEL)
        {
            int result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand("Insert_login_user", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@username", objBEL.USERNAME);
                cmd.Parameters.AddWithValue("@password", objBEL.PASSWORD);
                cmd.Parameters.AddWithValue("@firstname", Convert.ToString(objBEL.FIRSTNAME));
                SqlParameter inuserid = new SqlParameter("@userid", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                };
                cmd.Parameters.Add(inuserid);
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                result = cmd.ExecuteNonQuery();
                cmd.Dispose();
                if (result > 0)
                {
                    int userid = Convert.ToInt32(inuserid.Value);
                    return(result);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }