Exemple #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataView dv     = SqlDataSource1.Select(DataSourceSelectArguments.Empty) as DataView;
        bool     exists = false;

        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (username.Text == dv.Table.Rows[i]["Username"].ToString() &&
                    password.Text == dv.Table.Rows[i]["Password"].ToString())
                {
                    Session["username"] = dv.Table.Rows[i]["Username"].ToString();
                    Session["type"]     = dv.Table.Rows[i]["Type"].ToString();
                    exists = true;
                    break;
                }
            }
            if (exists)
            {
                Response.Redirect("AdminHome.aspx");
            }
            else
            {
                msg.Text     = "Invalid username or password";
                msg.CssClass = "text-danger";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var fb_id   = (string)(Session["fb_id"]);
        var fb_name = (string)(Session["fb_name"]);
        var page    = System.IO.Path.GetFileName(Request.PhysicalPath);

        if (fb_id == null || fb_name == null)
        {
            if (page != "login.aspx")
            {
                Response.Redirect("login.aspx");
            }
        }
        else
        {
            SqlDataSource1.SelectParameters["fb_id"].DefaultValue = fb_id;
            DataView result = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            l_fb_name.Text = result[0]["fb_name"].ToString();
            l_money.Text   = result[0]["money"].ToString();
            if (result[0]["user_group"].ToString() != "1")
            {
                add_money.Visible = false;
                //system.Visible = false;
            }
        }
    }
Exemple #3
0
    protected void GvCompany_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label lb = (Label)GvCompany.SelectedRow.FindControl("Label1");

        ViewState["EditId"]   = lb.Text.Trim();
        Session["Department"] = ViewState["EditId"];
        class1.RecordId       = int.Parse(ViewState["EditId"].ToString());
        DataView MyDv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        MyDv.RowFilter = "DepartmentID='" + ViewState["EditId"].ToString() + "' ";
        if (MyDv.Count > 0)
        {
            _DIVDescriptionText.Text  = MyDv[0].Row["DepartmentDescription"].ToString();
            _DepartmentNameText.Text  = MyDv[0].Row["DepartmentName"].ToString();
            _CMPlist.SelectedValue    = MyDv[0].Row["CompanyId"].ToString();
            _BranchList.SelectedValue = MyDv[0].Row["BranchID"].ToString();


            Session["Status"] = MyDv[0].Row["IsActive"].ToString().Trim();
            if (Session["Status"].ToString() == "True")
            {
                LblStatus.Text      = "Active";
                LblStatus.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                LblStatus.Text      = "Not Active";
                LblStatus.ForeColor = System.Drawing.Color.Red;
            }
            BtnSave.Visible         = false;
            BtnChangeStatus.Visible = true;
            BtnUpdate.Visible       = true;
            //accountantCls.Cmd.Parameters.Add("@DefaultPassword", SqlDbType.NVarChar).Value = Midwest.Security.RijndaelEncryptionAlg.RijndaelEncryption.Encrypt(_PasswordText.Text);
        }
    }
Exemple #4
0
    public void login()
    {
        dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        if ((DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty) != null)
        {
            if (dview.Table.Rows[0]["u_blokada"].Equals("1"))
            {
                LabelBan.Text = "You have been banned!";
            }
            else
            {
                Session["LogedNick"] = ((DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty)).Table.Rows[0]["u_nick"];
                Response.Redirect("index.aspx");
            }
        }
        //dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        //for (int i = 0; i < dview.Count; i++)
        //{
        //    if (dview.Table.Rows[i]["u_nick"].Equals(TextBoxLogNick.Text))
        //    {
        //        for (int j = 0; j < dview.Count; j++)
        //        {
        //            if (dview.Table.Rows[j]["u_password"].Equals(TextBoxLogPassword.Text))
        //            {
        //                Session["LogedNick"] = dview.Table.Rows[i]["u_nick"];
        //                Response.Redirect("index.aspx");
        //            }
        //        }
        //    }
        //}
    }
        /// <summary>
        /// DataList分页数据绑定
        /// </summary>
        protected void DataListBind()
        {
            int PageNumber = 1;

            if (ViewState["Page"] != null)      //判断状态视图数据是否为空
            {
                PageNumber = Convert.ToInt16(ViewState["Page"]);
            }
            PagedDataSource pds = new PagedDataSource();

            pds.DataSource  = SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            pds.AllowPaging = true;
            pds.PageSize    = 3;
            if (PageNumber > pds.PageCount)
            {
                PageNumber = 1;
            }
            pds.CurrentPageIndex   = PageNumber - 1;
            dlstGoods.DataSourceID = null;
            dlstGoods.DataSource   = pds;   //pds对象作为DataList控件的数据源
            dlstGoods.DataBind();
            lblCurPage.Text   = "第" + (pds.CurrentPageIndex + 1) + "页";
            lblTotalPage.Text = "/共" + pds.PageCount.ToString() + "页";
            ViewState["Page"] = PageNumber;
            lbtnPre.Enabled   = true;
            lbtnNext.Enabled  = true;
            if (pds.IsFirstPage)
            {
                lbtnPre.Enabled = false;
            }
            if (pds.IsLastPage)
            {
                lbtnNext.Enabled = false;
            }
        }
Exemple #6
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         DataView dView = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
         if (dView.Count == 1)
         {
             Session["Email_ID"] = TextBox1.Text;
             String em = Session["Email_ID"].ToString();
             if (em == "*****@*****.**")
             {
                 Response.Redirect("~/Customer/Sitemanage.aspx");
             }
             else
             {
                 Response.Redirect("~/Customer/Welcome.aspx");
             }
         }
         else
         {
             Label3.Text = "Incorrect username or password!";
         }
     }
     catch (SqlException ex)
     {
         Label3.Text = ex.Message;
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Password pwd = new Password();
            DataView dv  = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());

            if (dv.Count == 1)
            {
                HttpCookie c1, c2;
                c1         = new HttpCookie("userid", txtUserName.Text);
                c2         = new HttpCookie("pwd", pwd.Encrypt(txtPassword.Text.Trim()));
                c1.Expires = DateTime.Now.AddYears(1);
                c2.Expires = DateTime.Now.AddYears(1);
                Response.AppendCookie(c1);
                Response.AppendCookie(c2);
                Session.Add("Name", dv[0][0]);
                Session.Add("Gender", dv[0][1]);
                Session.Add("UserId", dv[0][2]);
                Session.Add("Password", dv[0][3]);
                if (dv[0][4] == DBNull.Value)
                {
                    Session.Add("EmailId", "-");
                }
                Session.Add("EmailId", dv[0][4]);
                Server.Transfer("UserPanel.aspx");
            }
            else
            {
                Response.Write("<script>alert('Invalid UserName or Password...')</script>");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         Session["Filter"] = null;
     }
     if (Session["Filter"] != null)
     {
         SqlDataSource1.FilterExpression = Session["Filter"].ToString();
         SqlDataSource1.DataBind();
         DataView dv       = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
         int      rowCount = dv.Count;
         if (dv.Count > 0)
         {
         }
         else
         {
             Session["Filter"] = null;
             ImgControlsHidden();
         }
     }
     else
     {
         SqlDataSource1.FilterExpression = "";
         SqlDataSource1.DataBind();
         //ImgControlsHidden();
     }
 }
    /// <summary>
    /// this code gets the customer information from the database and populates the customer data fields
    /// </summary>
    /// <returns></returns>
    private ProjectCustomer GetSelectedRecord()
    {
        ProjectCustomer p = new ProjectCustomer();

        DataView customersTable = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        customersTable.RowFilter = string.Format("CustomerEmail = '{0}'", txtEmail.Text);

        try
        {
            DataRowView row = customersTable[0];
            p.CustomerID            = Convert.ToInt32(row["CustomerID"]);
            p.CustomerFname         = row["CustomerFName"].ToString();
            p.CustomerLName         = row["CustomerLName"].ToString();
            p.CustomerStreetAddress = row["CustomerStreetAddress"].ToString();
            p.CustomerCity          = row["CustomerCity"].ToString();
            p.CustomerState         = row["CustomerState"].ToString();
            p.CustomerZipCode       = row["CustomerZipCode"].ToString();
            p.CustomerPhone         = row["CustomerPhone"].ToString();
        }
        catch (IndexOutOfRangeException)
        {
        }
        return(p);
    }
        public Product DisplayProduct(Int32 product_id)
        {
            //Product getid = new Product();
            DataView ProductTable = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

            ProductTable.RowFilter = string.Format("id = '" + product_id + "'");
            if (ProductTable.Count > 0)
            {
                DataRowView row = ProductTable[0];
                Product     p   = new Product();
                p.product_id          = row["id"].ToString();
                p.product_name        = row["product_name"].ToString();
                p.product_image       = row["product_image"].ToString();
                p.product_price       = row["product_price"].ToString();
                p.product_description = row["product_desc"].ToString();
                p.product_spec        = row["product_spec"].ToString();
                p.product_color       = row["product_color"].ToString();
                //p.product_warranty = row["product_warranty"].ToString();
                return(p);
            }
            else
            {
                return(null);
            }
        }
Exemple #11
0
    protected void GvCompany_SelectedIndexChanged(object sender, EventArgs e)
    {
        ViewState["EditId"]  = GvCompany.SelectedRow.Cells[1].Text.Trim();
        Session["CompanyID"] = ViewState["EditId"];
        class1.RecordId      = int.Parse(ViewState["EditId"].ToString());
        DataView MyDv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        MyDv.RowFilter = "CompanyID='" + ViewState["EditId"].ToString() + "' ";
        if (MyDv.Count > 0)
        {
            _CMPCompanyNameText.Text = MyDv[0].Row["CMPCompanyName"].ToString();

            TextBoxLength.Text = MyDv[0].Row["ChartLastLevelLength"].ToString();
            _TextBoxCount.Text = MyDv[0].Row["NoOfChartLevels"].ToString();
            Session["Status"]  = MyDv[0].Row["IsActive"].ToString().Trim();
            if (Session["Status"].ToString() == "True")
            {
                LblStatus.Text      = "Active";
                LblStatus.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                LblStatus.Text      = "Not Active";
                LblStatus.ForeColor = System.Drawing.Color.Red;
            }
        }
    }
Exemple #12
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataView view = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

                DataTable table = view.ToTable("tarea");

                DataSet ds = new DataSet("tareas");
                ds.Tables.Add(table);

                ds.WriteXml(Server.MapPath("app_data/" + DropDownList1.SelectedValue + "_E.xml"));

                XmlDocument document = new XmlDocument();
                document.Load(Server.MapPath("app_data/" + DropDownList1.SelectedValue + "_E.xml"));

                XmlNodeList tareas = document.GetElementsByTagName("tareas");

                XmlAttribute attr = document.CreateAttribute("xmlns:has");
                attr.Value = "http://ji.ehu.es/has";
                tareas[0].Attributes.Append(attr);

                document.Save(Server.MapPath("app_data/" + DropDownList1.SelectedValue + "_E.xml"));
                HyperLink1.NavigateUrl = "app_data/" + DropDownList1.SelectedValue + "_E.xml";
                HyperLink1.Visible     = true;
                Label1.ForeColor       = System.Drawing.Color.Green;
                Label1.Text            = "Exportado correctamente.";
            }
            catch (Exception ex)
            {
                Label1.ForeColor   = System.Drawing.Color.Red;
                Label1.Text        = "Ha ocurrido un error al exportar las tareas.";
                HyperLink1.Visible = false;
            }
        }
Exemple #13
0
    private void getCustomerInstance()
    {
        DataView IncidentsTable = (DataView)
                                  SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        IncidentsTable.RowFilter = "DateClosed IS NOT NULL AND CustomerID = ' " + cusId + " ' ";
        ListIncidents.Items.Add(new ListItem("--Select an Incident--"));

        foreach (DataRowView rows in IncidentsTable)
        {
            DataRow row = rows.Row;


            incident             = new Incident();
            incident.IncidentID  = (int)row["IncidentID"];
            incident.CustomerID  = (int)row["CustomerID"];
            incident.ProductCode = row["ProductCode"].ToString();
            incident.TechID      = (int)row["TechID"];
            incident.Title       = row["Title"].ToString();
            incident.DateOpened  = (DateTime)row["DateOpened"];
            incident.DateClosed  = (DateTime)row["DateClosed"];
            incident.Description = row["Description"].ToString();
            ListIncidents.Items.Add(incident.CustDisplay());
        }
    }
    //Query Student table, return query results
    protected DataView getStudentData(String studentID)
    {
        DataView studentsTable = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        studentsTable.RowFilter = string.Format("Id= {0}", studentID);
        return(studentsTable);
    }
Exemple #15
0
    protected void submit_Click(object sender, EventArgs e)
    {
        DataView x;
        Boolean  flag = false;

        x = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        for (Int32 i = 0; i <= x.Table.Rows.Count - 1; i++)
        {
            if (email.Text.ToLower() == x.Table.Rows[i]["email"].ToString().ToLower())
            {
                flag = true;
                break;
            }
        }
        if (flag == true)
        {
            name.Focus();

            Response.Redirect("inf.aspx");
        }
        else
        {
            SqlDataSource1.Insert();
            Response.Redirect("info/City table.aspx");
        }
    }
Exemple #16
0
    private void loadData2TreeView()
    {
        //测试无法转换为DataSet
        //DataSet ds = (DataSet)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        //dt = ds.Tables[0];
        DataView  ds = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        DataTable dt = new DataTable();

        dt = ds.Table;
        TreeNode root = new TreeNode(dt.Rows[0][1].ToString());//定义一个根节点

        root.NavigateUrl = dt.Rows[0][2].ToString();
        TreeNode softdipartment = null;

        for (int i = 1; i < dt.Rows.Count; i++)
        {
            int no = (int)dt.Rows[i][0];
            if (no == 3 && softdipartment != null)
            {
                TreeNode netdirection = new TreeNode(dt.Rows[i][1].ToString());
                netdirection.NavigateUrl = dt.Rows[i][2].ToString();
                softdipartment.ChildNodes.Add(netdirection);//将子节点添加到父节(softdipartment)点中
            }
            else
            {
                softdipartment             = new TreeNode(dt.Rows[i][1].ToString());
                softdipartment.NavigateUrl = dt.Rows[i][2].ToString();
                root.ChildNodes.Add(softdipartment);//将子节点添加到父节点中
            }
        }
        this.TreeView1.Nodes.Add(root);//将根节点添加到treeview中(就将根节点及子节点都装到了treeview中)
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataView dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

            if (dview.Table.Rows.Count > 0)
            {
                string MetaTitle       = (string)dview.Table.Rows[0]["MetaTitle"];
                string MetaKey         = (string)dview.Table.Rows[0]["MetaKey"];
                string MetaDescription = (string)dview.Table.Rows[0]["MetaDescription"];

                string page = Request.Url.Segments[Request.Url.Segments.Length - 1];


                //Add Page Title

                this.Page.Title = MetaTitle.ToString();

                //Add Keywords Meta Tag
                HtmlMeta keywords = new HtmlMeta();
                keywords.HttpEquiv = "keywords";
                keywords.Name      = "keywords";
                keywords.Content   = MetaKey.ToString();
                this.Page.Header.Controls.Add(keywords);

                //Add Description Meta Tag
                HtmlMeta description = new HtmlMeta();
                description.HttpEquiv = "description";
                description.Name      = "description";
                description.Content   = MetaDescription.ToString();
                this.Page.Header.Controls.Add(description);
            }
        }
    }
        protected void admin_Click(object sender, EventArgs e)
        {
            if (MUsername.Text != "")
            {
                DataView obstaja = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

                //ListBox1.Items.Add(obstaja[0][0].ToString()+" "+ obstaja[0][1].ToString()+" "+ obstaja[0][2].ToString()+" "+ obstaja[0][3].ToString());

                if (!((obstaja[0][0].ToString()).Equals(null)))
                {
                    SqlDataSource5.UpdateParameters["username"].DefaultValue = MUsername.Text;
                    SqlDataSource5.UpdateParameters["admin"].DefaultValue    = "1";
                    SqlDataSource5.Update();
                    Label1.Text = "Uporabnik " + MUsername.Text + " ima administratorske pravice.";
                }
                else
                {
                    Label1.Text = "Uporabnik ne obstaja.";
                }
            }
            else
            {
                Label1.Text = "Prosim dopolnite polje.";
            }
        }
Exemple #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] == null)
        {
            Response.Redirect("ViewCategory.aspx");
        }

        if (!IsPostBack)
        {
            DataView dv = SqlDataSource1.Select(DataSourceSelectArguments.Empty) as DataView;

            if (dv != null)
            {
                for (int i = 0; i < dv.Table.Rows.Count; i++)
                {
                    if (Request.QueryString["id"] == dv.Table.Rows[i]["Category_Id"].ToString())
                    {
                        category_name.Text = dv.Table.Rows[i]["Category_Name"].ToString();
                        description.Text   = dv.Table.Rows[i]["Description"].ToString();
                        break;
                    }
                }
            }
        }
    }
        protected void Btnchangepass_Click(object sender, EventArgs e)
        {
            DataView dv   = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            bool     flag = false;
            string   pass = TBoldpass.Text;
            string   user = Session["username"].ToString();

            for (int i = 0; i <= dv.Table.Rows.Count - 1; i++)
            {
                if (dv.Table.Rows[i]["username"].ToString() == user &&
                    dv.Table.Rows[i]["password"].ToString() == pass)
                {
                    flag = true;
                }
            }
            if (flag == false)
            {
                Lblmsg.Text = "Invalid Old password";
            }
            else
            {
                SqlDataSource1.Update();
                Response.Redirect("adminlogin.aspx");
            }
        }
        protected void btncatadd_Click(object sender, EventArgs e)
        {
            DataView dv        = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            bool     flag      = false;
            string   maincat   = Ddlcategory.SelectedItem.Text;
            string   brandname = TBbrandname.Text;

            for (int i = 0; i <= dv.Table.Rows.Count - 1; i++)
            {
                if (dv.Table.Rows[i]["maincategory"].ToString() == maincat &&
                    dv.Table.Rows[i]["brandname"].ToString().ToLower() == brandname)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            if (flag == true)
            {
                Lblmessage.Text = "Brand already exits!!";
            }
            else
            {
                SqlDataSource1.Insert();
                Lblmessage.Text = "Brand added successfully";
            }
        }
Exemple #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hfDate.Value       = DateTime.Today.ToString();
            hfYes.Value        = "Yes";
            hfHold.Value       = "Hold";
            hfFlatStatus.Value = "Yes";
            hfConfirm.Value    = "No";
            hfDisable.Value    = "No";
            DataView dv = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());

            if (dv.Count == 1)
            {
                DateTime date   = (DateTime)dv[0][0];
                String   Scheme = (String)dv[0][1];
                DateTime d2;
                if (Scheme.Equals("3 Months"))
                {
                    d2 = date.AddDays(90);
                }
                else
                {
                    d2 = date.AddDays(150);
                }
                if (DateTime.Compare(date, d2) > 0)
                {
                    SqlDataSource1.Update();
                    btnUpload.Visible = true;
                }
            }
        }
Exemple #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HiddenField1.Value = Page.User.Identity.Name;

        if (!IsPostBack)
        {
            DataView dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            if (dview.Table.Rows.Count > 0)
            {
                string FullName        = (string)dview.Table.Rows[0]["FullName"];
                string ContactNumber   = (string)dview.Table.Rows[0]["ContactNumber"];
                string Shippingaddress = (string)dview.Table.Rows[0]["Shippingaddress"];
                string City            = (string)dview.Table.Rows[0]["City"];
                string PostCode        = (string)dview.Table.Rows[0]["PostCode"];
                string Country         = (string)dview.Table.Rows[0]["Country"];


                TextBox1.Text = FullName.ToString();
                TextBox2.Text = ContactNumber.ToString();
                TextBox3.Text = Country.ToString();
                TextBox4.Text = City.ToString();
                TextBox5.Text = Shippingaddress.ToString();
            }
        }
    }
Exemple #24
0
    protected void GvCompany_SelectedIndexChanged(object sender, EventArgs e)
    {//SqlDataSource1
        foreach (TreeNode node in TreeView1.Nodes)
        {
            node.Checked = false;
        }
        Session["UserRoleId"] = GvCompany.SelectedRow.Cells[1].Text.Trim();
        SqlDataSource1.DataBind();
        DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

        dv.RowFilter = "UserRoleId ='" + Session["UserRoleId"].ToString() + "' ";
        if (dv.Count > 0)
        {
            foreach (TreeNode parent in TreeView1.Nodes)
            {
                foreach (TreeNode child in parent.ChildNodes)
                {
                    for (int j = 0; j < dv[0].DataView.Count; j++)
                    {
                        if (child.Value.Trim() == dv[0].DataView[j]["MenuId"].ToString().Trim())
                        {
                            child.Checked  = true;
                            parent.Checked = true;
                            break;
                        }
                    }
                }
            }
        }
    }
Exemple #25
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (commentBox.Text == "")
     {
         msg.Text = "Enter a comment.";
         return;
     }
     else
     {
         DataView dv         = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
         DateTime localDate  = DateTime.Now;
         String   now        = localDate.ToString("MM'/'dd'/'yyyy hh':'mm tt");
         String   commString = commentBox.Text;
         commString = commString.Replace("\r\n", "<br /> ");
         SqlConnection conn = new SqlConnection(connString);
         conn.Open();
         String     user      = User.Identity.Name;
         SqlCommand insertcmd = new SqlCommand("Insert INTO Posts (UserName, DateTime, Comment) VALUES(@username,@date,@comment)", conn);
         insertcmd.Parameters.AddWithValue("@username", user);
         insertcmd.Parameters.AddWithValue("@date", now);
         insertcmd.Parameters.AddWithValue("@comment", commString);
         insertcmd.ExecuteNonQuery();
         conn.Close();
         FormsAuthentication.RedirectFromLoginPage(user, false);
     }
 }
Exemple #26
0
    protected void LinkButton2_Click1(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            string folder = Server.MapPath("~/Images/" + Page.User.Identity.Name + "/");
            if (!System.IO.Directory.Exists(folder))
            {
                System.IO.Directory.CreateDirectory(folder);
            }

            string filename_save = "";
            string path          = "";

            do
            {
                filename_save = Path.GetFileNameWithoutExtension(FileUpload1.FileName) + "_" + Path.GetRandomFileName().Replace(".", "") + Path.GetExtension(FileUpload1.FileName);
                path          = Path.Combine(folder, filename_save);
            } while (System.IO.File.Exists(path));

            FileUpload1.SaveAs(path);
            string relative_path = "~/Images/" + Page.User.Identity.Name + "/" + filename_save;
            profile_pic.ImageUrl = relative_path;

            SqlDataSource1.SelectCommand = "select image from users where username = '******'";
            DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            if (dv.Table.Rows[0][0].ToString() != "")
            {
                File.Delete(Server.MapPath("..") + dv.Table.Rows[0][0].ToString().TrimStart('~'));
            }
            SqlDataSource1.UpdateCommand = "Update users set image = '" + relative_path + "' where username = '******'";
            SqlDataSource1.Update();
        }
    }
Exemple #27
0
    private void consultar()
    {
        SqlDataSource1.SelectParameters["usuario"].DefaultValue = Label1.Text;
        SqlDataSource1.DataSourceMode = SqlDataSourceMode.DataReader;
        SqlDataReader datos;

        datos = (SqlDataReader)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        if (datos.Read())
        {
            Email.Text       = datos["Email"].ToString();
            Session["email"] = Email.Text;

            EmpleadoID.Text        = datos["id_Empleado"].ToString();
            Session["id_empleado"] = EmpleadoID.Text;

            EmpresaID.Text        = datos["id_empresa"].ToString();
            Session["id_Empresa"] = EmpresaID.Text;

            Nombres.Text       = datos["Nombres"].ToString();
            Session["nombres"] = Nombres.Text;

            Apellidos.Text       = datos["Apellidos"].ToString();
            Session["apellidos"] = Apellidos.Text;
        }
        else
        {
            Email.Text = "nadaaa";
        }
    }
        private void Fill_Reply(List <Post_Model> PostObj, Repeater RPT)
        {
            PagedDataSource pds = new PagedDataSource();

            pds.DataSource  = SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            pds.AllowPaging = true;
            pds.PageSize    = 20;

            int currentPage;

            if (Request.QueryString["Pageindex"] != null)
            {
                currentPage = Int32.Parse(Request.QueryString["Pageindex"]);
            }
            else
            {
                currentPage = 1;
            }

            pds.CurrentPageIndex = currentPage - 1;
            Label1.Text          = "Page  " + currentPage + " of " + pds.PageCount;

            if (!pds.IsFirstPage)
            {
                linkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Pageindex=" + (currentPage - 1) + "&ID=" + hdn_PostID.Value;
            }

            if (!pds.IsLastPage)
            {
                linkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Pageindex=" + (currentPage + 1) + "&ID=" + hdn_PostID.Value;
            }

            RPT.DataSource = pds;
            RPT.DataBind();
        }
Exemple #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                Response.Redirect("~/LogIn.aspx");
            }

            if (!IsPostBack) //works during first page load
            {
                try
                {
                    String idx = Session["id"].ToString();
                    Label1.Text = idx;
                    DataView  dv    = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
                    DataTable dt    = dv.ToTable();
                    String    name1 = dt.Rows[0][0].ToString();
                    name.Value = name1;
                    String email1 = dt.Rows[0][1].ToString();
                    email.Text = email1;
                    String pd = dt.Rows[0][2].ToString();
                    password.Value = pd;
                }
                catch (Exception g)
                {
                    Response.Redirect("~/sample.aspx");
                }
            }
        }
Exemple #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataView dv1 = (DataView)SqlDataSource2.Select(new DataSourceSelectArguments());

            if (dv1[0][0] != DBNull.Value && dv1[0][1] != DBNull.Value && dv1[0][2] != DBNull.Value && dv1[0][3] != DBNull.Value && dv1[0][4] != DBNull.Value)
            {
                DataView dv = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());
                if (dv.Count == 1)
                {
                    Server.Transfer("UserList.aspx");
                }
                else
                {
                    int n = SqlDataSource1.Insert();
                    if (n == 1)
                    {
                        Server.Transfer("UserList.aspx");
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('Please Fill Up Your Profile Details First...')</script>");
                Server.Transfer("~/Account/Profile.aspx");
            }
        }