Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // if the user is logged in, obtain his current cart if it's not zero.
            // otherwise, use the ID stored in the session variable.
            if (Session["currUser"] != null)
            {
                _user = (string)Session["currUser"];

                _userCartId = DBOps.GetLatestEntry(DBOps.GetUserID(_user)) != 0 ? DBOps.GetLatestEntry(DBOps.GetUserID(_user)) :
                              Convert.ToInt32(Session["prevID"]);
                _cart.cartID = _userCartId;

                if (Session["sync"] != null)
                {
                    _cart.SyncCart(Convert.ToInt32(Session["prevID"]), _user);
                    cartDatasource.Update();
                    Session["prevID"] = _userCartId;
                    Session.Remove("sync");
                }
            }
            else
            {
                _user       = "******";
                _userCartId = Convert.ToInt32(Session["prevID"]);
            }

            if (Session["prevID"] == null)
            {
                _userCartId = Convert.ToInt32(Session["prevID"]);
            }
            else
            {
                Session["prevID"] = _userCartId;
            }

            _cart.cartID = _userCartId;
            //Session["prevID"] = _userCartId;

            lvw_items.DataSource = DBOps.BuildUserCart(_userCartId);
            lvw_items.DataBind();
            lvw_totals.DataSource = DBOps.BuildUserCartTotals(_userCartId);
            lvw_totals.DataBind();

            Button button = (Button)UpdatePanel1.FindControl("btn_checkout");

            if (DBOps.BuildUserCart(_userCartId).Rows.Count == 0)
            {
                button.Enabled  = false;
                button.CssClass = "btn btn-outline-secondary btn-block";
            }
            else
            {
                button.Enabled = true;
            }

            SiteMaster master = Page.Master as SiteMaster;

            master.UpdateTotalCounters();
        }
Exemplo n.º 2
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridView gv1    = (GridView)UpdatePanel1.FindControl("GridView1");
            int      sec_id = Int32.Parse(gv1.SelectedValue.ToString());

            campusweb.InsertSectionStudent("teststudent", sec_id);
            gv1.DataBind();
        }
Exemplo n.º 3
0
    /// <summary>
    /// 显示新消息
    /// </summary>
    protected void ShowNewMessageCount()
    {
        int       count = MessageManager.GetNewMailInfo((Session["Login"] as User));
        HtmlImage img   = UpdatePanel1.FindControl("imgNewMessage") as HtmlImage;

        if (count > 0)
        {
            img.Visible          = true;
            lblMessageCount.Text = count.ToString();
        }
        else
        {
            img.Visible          = false;
            lblMessageCount.Text = "0";
        }
    }
Exemplo n.º 4
0
        protected void lvw_items_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            string[] productDetails = ((String)e.CommandArgument).Split(',');

            try
            {
                _cart.RemoveItem(productDetails[0].Trim(), Convert.ToDecimal(productDetails[1].Trim()), Convert.ToInt32(productDetails[2].Trim()));
                cartDatasource.Update();
                _itemSKU   = productDetails[0].Trim();
                _itemQuant = DBOps.GetProductQuantity(_itemSKU) + Convert.ToInt32(productDetails[2].Trim());
                ProductsDataSource.Update();
            }
            catch (Exception)
            {
                // ignored
            }

            Button button = (Button)UpdatePanel1.FindControl("btn_checkout");

            if (DBOps.BuildUserCart(_userCartId).Rows.Count < 1)
            {
                if (_user != "-")
                {
                    //cartDatasource.Delete();
                    //DataOps.reassignUserCart(user);
                }
                button.Enabled  = false;
                button.CssClass = "btn btn-outline-secondary btn-block";
            }

            DataPager dp = (DataPager)lvw_items.FindControl("DataPager1");

            if (lvw_items.Items.Count <= 1)
            {
                dp.SetPageProperties(0, dp.MaximumRows, false);
            }

            lvw_items.DataSource  = DBOps.BuildUserCart(_userCartId);
            lvw_totals.DataSource = DBOps.BuildUserCartTotals(_userCartId);
            lvw_items.DataBind();
            lvw_totals.DataBind();

            SiteMaster master = Page.Master as SiteMaster;

            master.UpdateTotalCounters();
        }
Exemplo n.º 5
0
    private string GetServerConfigFile(string config, int i)
    {
        string    resultConfig        = config;
        ArrayList parametersArrayList = Session["ConfigParameters"] as ArrayList;
        TextBox   textbox             = null;

        foreach (string parameter in parametersArrayList)
        {
            string toBeReplacedParameter = "#" + parameter + "#";
            textbox = UpdatePanel1.FindControl(parameter) as TextBox;
            string argument = textbox.Text;
            resultConfig = resultConfig.Replace(toBeReplacedParameter, argument);
        }

        resultConfig = resultConfig.Replace("#SVR_ID#", i.ToString());

        return(resultConfig);
    }
Exemplo n.º 6
0
        protected void UpdatePanel1_PreRender(object sender, EventArgs e)
        {
            CinemaLINQDataContext dt        = new CinemaLINQDataContext();
            NguoiDung             nguoiDung = ((NguoiDung)Session["NguoiDung"]);
            var query = from binhLuan in dt.BinhLuans
                        where binhLuan.MaPhim == ((Phim)Session["CurrentPhim"]).MaPhim && binhLuan.TinhTrang == dt.DanhMucTinhTrangBinhLuans.Where(ttbl => ttbl.TenTinhTrang.CompareTo("Bình thường") == 0).Select(ttbl => ttbl.MaTinhTrang).Single()
                        select binhLuan;

            DataList1.DataSource = query;
            DataList1.DataBind();

            int _count = 0;

            foreach (BinhLuan _bl in query)
            {
                if (nguoiDung != null && (nguoiDung.MaDanhMucNguoiDung == dt.DanhMucNguoiDungs.Where(dmnd => dmnd.TenDanhMucNguoiDung.CompareTo("Admin") == 0).Select(dmnd => dmnd.MaDanhMucNguoiDung).Single() || nguoiDung.MaNguoiDung == _bl.MaNguoiDung))
                {
                    ((TextBox)DataList1.Items[_count].FindControl("Th_NoiDungBinhLuan")).ReadOnly = false;
                    DataList1.Items[_count].FindControl("Xl_Sua").Visible = true;
                    DataList1.Items[_count].FindControl("Xl_Xoa").Visible = true;
                }
                else
                {
                    ((TextBox)DataList1.Items[_count].FindControl("Th_NoiDungBinhLuan")).ReadOnly = true;
                    DataList1.Items[_count].FindControl("Xl_Sua").Visible = false;
                    DataList1.Items[_count].FindControl("Xl_Xoa").Visible = false;
                }
                Button temp = (Button)DataList1.Items[_count].FindControl("Xl_Sua");
                temp.CommandName = _count.ToString();
                _count++;
            }
            if (nguoiDung == null)
            {
                UpdatePanel1.FindControl("Xl_ThemBinhLuan").Visible = false;
                UpdatePanel1.FindControl("Th_BinhLuanMoi").Visible  = false;
            }
            else
            {
                UpdatePanel1.FindControl("Xl_ThemBinhLuan").Visible = true;
                UpdatePanel1.FindControl("Th_BinhLuanMoi").Visible  = true;
            }
        }
Exemplo n.º 7
0
        protected void btnGo_Click(object sender, EventArgs e)
        {
            //code to bind driver id to grid below databound here
            var GridResult = (GridView)UpdatePanel1.FindControl("GridResult");

            if (Page.IsPostBack)
            {
                //WHERE ([SERIAL_NUMBER] LIKE '%' + @REG_NUMBER + '%')
                var con = new SqlConnection(strConnection);
                var cmd =
                    new SqlCommand("SELECT TOP 1 ID FROM [PS28drivers] WHERE ([NAME] LIKE '%' + @DRIVER_NAME + '%')",
                                   con);
                cmd.Parameters.Add("@DRIVER_NAME", TextSearch.SelectedValue.Trim());

                //var result = cmd.ToString();
                var Adpt = new SqlDataAdapter(cmd);
                var dt   = new DataTable();
                Adpt.Fill(dt);
                GridResult.DataSource = dt;
                GridResult.DataBind();
                //LabelProduct.Text = "Volume:" + result;
            }
        }
Exemplo n.º 8
0
        protected void lnktab_Click(object sender, EventArgs e)
        {
            string id = ((LinkButton)sender).ID.Trim();

            int name = Convert.ToInt32(id.Substring(id.Length - 1, 1));

            for (int i = 1; i < 5; i++)
            {
                Panel pnl = (Panel)UpdatePanel1.FindControl("Panel" + i.ToString());
                HtmlGenericControl liItem = (HtmlGenericControl)UpdatePanel1.FindControl("li" + i);
                if (i != name)
                {
                    pnl.Visible = false;
                    liItem.Attributes.Add("class", "");
                }
                else
                {
                    pnl.Visible = true;

                    liItem.Attributes.Add("class", "active");
                }
            }
        }
Exemplo n.º 9
0
    private void SaveArgumentsAsDefaultValues()
    {
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.Load(WebConfig.WebsiteRootPath + "AddServerGroupConfigParameters.xml");
        XmlNode root = xmlDoc.DocumentElement;

        ArrayList parametersArrayList = Session["ConfigParameters"] as ArrayList;
        TextBox   textbox             = null;

        foreach (string parameter in parametersArrayList)
        {
            string toBeReplacedParameter = "#" + parameter + "#";
            textbox = UpdatePanel1.FindControl(parameter) as TextBox;
            string argument = textbox.Text;

            XmlNode parameterNode = root.SelectSingleNode("Parameter[Name='" + toBeReplacedParameter + "']");

            XmlNode defaultValueNode = parameterNode.LastChild;
            defaultValueNode.InnerText = argument;
        }

        xmlDoc.Save(WebConfig.WebsiteRootPath + "AddServerGroupConfigParameters.xml");
    }
Exemplo n.º 10
0
        public void updater(object sender, FormViewInsertedEventArgs e)
        {
            GridView GV2 = (GridView)UpdatePanel1.FindControl("GridView2");

            GV2.DataBind();
        }
Exemplo n.º 11
0
        protected void Filter_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridView gv1 = (GridView)UpdatePanel1.FindControl("GridView1");

            gv1.DataBind();
        }
Exemplo n.º 12
0
    protected void SaveButton_Click(Object Src, EventArgs E)
    {
        // Linkte "Video" id numarası gönderildiyse
        if (!string.IsNullOrEmpty(Request.QueryString["Video"]))
        {
            int    videoId  = Convert.ToInt32(Request.QueryString.Get("Video"));
            string userName = Membership.GetUser().ToString();

            VideoYorumlari yeniYorum = new VideoYorumlari();
            yeniYorum.VideoId  = videoId;
            yeniYorum.UserName = userName;
            yeniYorum.Tarih    = DateTime.Now.ToString();
            TextBox yorumTextBox = (TextBox)LoginView1.FindControl("yorumTextBox");

            // "TrimStart" ile text'in başında boş kısım varsa kesiliyor.
            if (!string.IsNullOrEmpty(yorumTextBox.Text.TrimStart()))
            {
                yeniYorum.Yorum = yorumTextBox.Text;

                using (var myEntity = new MyWebSiteDatabaseEntities())
                {
                    myEntity.VideoYorumlaris.Add(yeniYorum);
                    myEntity.SaveChanges();
                }

                // Yorum gönderildikten sonra textbox'ın içi siliniyor.
                yorumTextBox.Text = "";

                // Yeni liste, repeater'a bağlanıyor. Yeni yorum en başa ekleniyor.
                Repeater repeater = (Repeater)UpdatePanel1.FindControl("Repeater1");
                videoYorumList.Insert(0, yeniYorum);
                repeater.DataSource = videoYorumList;
                repeater.DataBind();

                repeater.Visible   = true;
                uyarıLabel.Visible = false;
            }
        }

        // Linkte "PDF" url'si gönderildiyse
        else if (!string.IsNullOrEmpty(Request.QueryString["PDF"]))
        {
            int    requestedPdfId = Convert.ToInt32(Request.QueryString.Get("PDF"));
            string userName       = Membership.GetUser().ToString();

            PdfYorumları yeniYorum = new PdfYorumları();
            yeniYorum.PdfId    = requestedPdfId;
            yeniYorum.UserName = userName;
            yeniYorum.Tarih    = DateTime.Now.ToString();
            TextBox yorumTextBox = (TextBox)LoginView1.FindControl("yorumTextBox");

            // "TrimStart" ile text'in başında boş kısım varsa kesiliyor.
            if (!string.IsNullOrEmpty(yorumTextBox.Text.TrimStart()))
            {
                yeniYorum.Yorum = yorumTextBox.Text;

                using (var myEntity = new MyWebSiteDatabaseEntities())
                {
                    myEntity.PdfYorumları.Add(yeniYorum);
                    myEntity.SaveChanges();
                }
            }

            // Yorum gönderildikten sonra textbox'ın içi siliniyor.
            yorumTextBox.Text = "";

            // Yeni liste, repeater'a bağlanıyor. Yeni yorum en başa ekleniyor.
            Repeater repeater = (Repeater)UpdatePanel1.FindControl("Repeater1");
            pdfYorumList.Insert(0, yeniYorum);
            repeater.DataSource = pdfYorumList;
            repeater.DataBind();

            repeater.Visible   = true;
            uyarıLabel.Visible = false;
        }

        // "deleteButton"ların "visible" özellikleri ayarlanıyor.
        commentDeleteButtonVisible(Repeater1);
    }