protected void Page_Load(object sender, EventArgs e)
    {
        msg.Visible    = false;
        userid.Visible = false;
        if (!IsPostBack)
        {
            description.Attributes.Add("maxlength", description.MaxLength.ToString());

            AddFranchise cat = new AddFranchise();
            db.dt = cat.showCategory();
            category.DataSource     = db.dt;
            category.DataTextField  = ("name");
            category.DataValueField = ("id");
            category.DataBind();


            if (Session["username"] != null)
            {
                if (Session["role"] == "franchiser")
                {
                    string         query = "select* from users where username ='******'";
                    SqlDataAdapter da    = new SqlDataAdapter(query, db.con);
                    DataSet        ds    = new DataSet();
                    da.Fill(ds, "user123");
                    DataTable dt = ds.Tables[0];
                    DataRow   dr = dt.Rows[0];

                    userid.Text = dr["id"].ToString();
                }
            }
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        uid.Visible     = false;
        user_id.Visible = false;
        dbConnection db = new dbConnection();

        if (!Page.IsPostBack)
        {
            msg.Visible = false;
            AddFranchise cat = new AddFranchise();
            db.dt = cat.showCategory();
            category.DataSource     = db.dt;
            category.DataTextField  = ("name");
            category.DataValueField = ("id");
            category.DataBind();
            if (Session["username"] != null)
            {
                string query = "select* from users where username ='******'";
                db.cmd = new System.Data.SqlClient.SqlCommand(query, db.con);
                db.openConnection();
                db.dr = db.cmd.ExecuteReader();
                while (db.dr.Read())
                {
                    string id = db.dr[0].ToString();
                    user_id.Text = id;
                }
                db.closeConnection();
            }
            if (Request.QueryString["id"] != null)
            {
                string         data = "select * from franchise where id='" + Request.QueryString["id"] + "'";
                SqlDataAdapter da   = new SqlDataAdapter(data, db.con);
                DataSet        ds   = new DataSet();
                da.Fill(ds, "franchise");
                DataTable dt = ds.Tables[0];
                DataRow   dr = dt.Rows[0];
                franchise_name.Text      = dr["franchise_name"].ToString();
                description.Text         = dr["description"].ToString();
                email.Text               = dr["email"].ToString();
                established_date.Text    = dr["established_date"].ToString();
                started_date.Text        = dr["started_date"].ToString();
                concept.Text             = dr["concept"].ToString();
                investment_required.Text = dr["investment_required"].ToString();
                no_of_units.Text         = dr["no_of_units"].ToString();
                category.Text            = dr["catid"].ToString();
                uid.Text = dr["uid"].ToString();

                if (dr["logo"] != null)
                {
                    string str = logo.FileName;
                    lbllogo.Text      = "<img id='id' src='uploads/" + dr["logo"] + "' width='100' height='100' />";
                    hiddenimage.Value = dr["logo"].ToString();
                }

                if (uid.Text != user_id.Text)
                {
                    Response.Redirect("login.aspx");
                    msg.Visible = true;
                    msg.Text    = "wrong login credentials";
                }
                else
                {
                }
            }
            if (Session["username"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
            }
        }
    }