Exemple #1
0
        protected void CommandEvent(object source, RepeaterCommandEventArgs e)
        {
            var  c     = ((HiddenField)e.Item.FindControl("idkey")).Value;
            Cart cart1 = Cart; //Tao bien local de gan

            switch (e.CommandName)
            {
            case "Update":
                var quantity = ConvertUtility.ToInt16(((TextBox)e.Item.FindControl("txtQuantity")).Text.Trim());
                UpdateQuantity(c, ref cart1, quantity);
                break;

            case "Remove":
                RemoveProduct(c, ref cart1);
                break;
            }

            if (cart1.LstProduct.Count == 0)
            {
                Session.Remove(Constant.SESSION_KEY_CART);
                Cart = null;
                Response.Redirect(Request.Url.ToString());
            }
            else
            {
                Session[Constant.SESSION_KEY_CART] = cart1;
                Cart = cart1;
                rptCart.DataSource = cart1.LstProduct;
                rptCart.DataBind();
                Sum = cart1.TotalPrice();
            }
        }
Exemple #2
0
 protected void UpdateCartRpt(object sender, EventArgs e)
 {
     for (var i = 0; i < rptCart.Items.Count; i++)
     {
         var id       = ((HiddenField)rptCart.Items[i].FindControl("idkey")).Value;
         var quantity = ((TextBox)rptCart.Items[i].FindControl("txtQuantity")).Text;
         Cart.UpdateQuantity(ConvertUtility.ToInt32(id), ConvertUtility.ToInt16(quantity));
     }
     Session[Constant.SESSION_KEY_CART] = Cart;
     rptCart.DataSource = Cart.LstProduct;
     rptCart.DataBind();
     Sum = Cart.TotalPrice();
 }
Exemple #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var id = Request.QueryString["id"];
         if (!string.IsNullOrEmpty(id) && ConvertUtility.ToInt16(id) > 0)
         {
             Info = PartnerImpl.Instance.GetInfo(ConvertUtility.ToInt16(id));
             if (Info != null)
             {
                 Id = ConvertUtility.ToInt16(id);
                 txtPartner.Text     = Info.Name;
                 txtAlt.Text         = Info.Alt;
                 txtDescription.Text = Info.Description;
                 txtLinks.Text       = Info.Link;
             }
         }
     }
 }
Exemple #4
0
        private object TryConvert(object value, string toType, ref bool succes)
        {
            object retval = null;

            if (toType == typeof(Object).Name)
            {
                succes = true;
                return((object)value);
            }

            if (toType == typeof(Guid?).Name)
            {
                succes = true;
                return(ConvertUtility.ToGuidNullable(value));
            }

            if (toType == typeof(Guid).Name)
            {
                succes = true;
                return(ConvertUtility.ToGuid(value, Guid.Empty));
            }

            if (toType == typeof(Byte?).Name)
            {
                succes = true;
                return(ConvertUtility.ToByteNullable(value));
            }
            if (toType == typeof(Byte).Name)
            {
                succes = true;
                return(ConvertUtility.ToByte(value, 0));
            }
            if (toType == typeof(int?).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt32Nullable(value));
            }
            if (toType == typeof(int).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt32(value, 0));
            }
            if (toType == typeof(decimal?).Name)
            {
                succes = true;
                return(ConvertUtility.ToDecimalNullable(value));
            }
            if (toType == typeof(decimal).Name)
            {
                succes = true;
                return(ConvertUtility.ToDecimal(value, 0));
            }

            if (toType == typeof(Int16?).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt16Nullable(value));
            }
            if (toType == typeof(Int16).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt16(value, 0));
            }
            if (toType == typeof(Int32?).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt32Nullable(value));
            }
            if (toType == typeof(Int32).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt32(value, 0));
            }
            if (toType == typeof(Int64?).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt64Nullable(value));
            }
            if (toType == typeof(Int64).Name)
            {
                succes = true;
                return(ConvertUtility.ToInt64(value, 0));
            }
            if (toType == typeof(float?).Name)
            {
                succes = true;
                return(ConvertUtility.ToSingleNullable(value));
            }
            if (toType == typeof(float).Name)
            {
                succes = true;
                return(ConvertUtility.ToSingle(value, 0));
            }
            if (toType == typeof(Single?).Name)
            {
                succes = true;
                return(ConvertUtility.ToSingleNullable(value));
            }
            if (toType == typeof(Single).Name)
            {
                succes = true;
                return(ConvertUtility.ToSingle(value, 0));
            }
            if (toType == typeof(double?).Name)
            {
                succes = true;
                return(ConvertUtility.ToDoubleNullable(value));
            }
            if (toType == typeof(double).Name)
            {
                succes = true;
                return(ConvertUtility.ToDouble(value, 0));
            }
            if (toType == typeof(Double?).Name)
            {
                succes = true;
                return(ConvertUtility.ToDoubleNullable(value));
            }
            if (toType == typeof(Double).Name)
            {
                succes = true;
                return(ConvertUtility.ToDouble(value, 0));
            }

            if (toType == typeof(bool?).Name)
            {
                succes = true;
                return(ConvertUtility.ToBooleanNullable(value));
            }
            if (toType == typeof(bool).Name)
            {
                succes = true;
                return(ConvertUtility.ToBoolean(value, false));
            }

            if (toType == typeof(DateTime).Name)
            {
                DateTime DateTimeValue = DateTime.Now;
                succes = DateTime.TryParse(ConvertUtility.HandleNull(value, string.Empty).ToString(), out DateTimeValue);
                retval = DateTimeValue;
            }
            if (toType == typeof(DateTime?).Name)
            {
                DateTime DateTimeValue = DateTime.Now;
                succes = DateTime.TryParse(ConvertUtility.HandleNull(value, string.Empty).ToString(), out DateTimeValue);
                if (!succes)
                {
                    retval = null;
                }
                retval = DateTimeValue;
            }

            return(retval);
        }