Esempio n. 1
0
        /**/
        /// <summary>
        /// 弹出对话框(弹出对话框后css会失效)
        /// </summary>
        /// <param name="message">提示信息</param>
        public static void ShowMessage(string message)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + message.Trim() + "\"); \n");
            sb.Append("</script>");

            System.Web.HttpContext.Current.Response.Write(sb.ToString());
        }

        /**/
        /// <summary>
        /// 弹出对话框(不影响css样式)
        /// </summary>
        /// <param name="page">页面指针,一般为this</param>
        /// <param name="scriptKey">脚本键,唯一</param>
        /// <param name="message">提示信息</param>
        public static void ShowMessage(System.Web.UI.Page page, string scriptKey, string message)
        {
            System.Web.UI.ClientScriptManager csm = page.ClientScript;
            if (!csm.IsClientScriptBlockRegistered(scriptKey))
            {
                string strScript = "alert('" + message + "');";
                csm.RegisterClientScriptBlock(page.GetType(), scriptKey, strScript, true);
            }
        }
Esempio n. 2
0
        /// <summary>返回默认的reloadForm实现,配合Box.js中的Dialog.CloseAndRefresh</summary>
        /// <returns></returns>
        public static bool RegisterReloadFormJs(ClientScriptManager script, bool isPostback)
        {
            if (!script.IsClientScriptBlockRegistered(typeof(LinkBox), "ReloadFormJs"))
            {
                script.RegisterClientScriptBlock(typeof(LinkBox), "ReloadFormJs", Helper.JsMinSimple(!XControlConfig.Debug, @"
function reloadForm(){
    if(!" + ("" + isPostback).ToLower() + @"){
        location.reload();
        return true;
    }
    var buttons = document.getElementsByTagName('input');
    for(var i=0;i<buttons.length;i++){
        var ele = buttons[i];
        if((ele.type === 'submit' || ele.type === 'button') && ele.value === '查询'){
            if(ele.click){
                ele.click();
            }else if(document.createEvent && ele.dispatchEvent){
                var event = document.createEvent('MouseEvent');
                event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                ele.dispatchEvent(event);
            }else{
                break;
            }
            return true;
        }
    }
    return false;
}"), true);
                return true;
            }
            return false;
        }
        /// <summary>
        /// Injects the specified manager.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="validationType">Type of the validation.</param>
        /// <param name="cssClass">The CSS class.</param>
        /// <param name="containerControl">The container control.</param>
        /// <param name="controlToValidate">The control to validate.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="selectionLimit">The selection limit.</param>
        /// <param name="maxLength">Length of the max.</param>
        public override void RegisterValidator(ClientScriptManager manager, ValidationType validationType, string cssClass, Control containerControl, string controlToValidate, string errorMessage, int selectionLimit, int maxLength)
        {
            if (validationType == ValidationType.RequiredField)
            {
                containerControl.Controls.Add(new RequiredFieldValidator
                    {
                        Display = ValidatorDisplay.Dynamic,
                        ControlToValidate = controlToValidate,
                        ValidationGroup = this.ValidationGroup,
                        ErrorMessage = "<span class=\"error-text\">" + errorMessage + "</span>",
                        CssClass = cssClass
                    });
            }

            if (validationType == ValidationType.EmailField)
            {
                containerControl.Controls.Add(new RegularExpressionValidator
                    {
                        Display = ValidatorDisplay.Dynamic,
                        ControlToValidate = controlToValidate,
                        ValidationGroup = this.ValidationGroup,
                        ValidationExpression = Engage.Utility.EmailsRegEx,
                        ErrorMessage = "<span class=\"error-text\">" + errorMessage + "</span>",
                        CssClass = cssClass
                    });
            }

            if (validationType == ValidationType.LimitedLengthField)
            {
                containerControl.Controls.Add(new TextBoxLengthValidator
                    {
                        Display = ValidatorDisplay.Dynamic,
                        ControlToValidate = controlToValidate,
                        ValidationGroup = this.ValidationGroup,
                        ErrorMessage = "<span class=\"error-text\">" + errorMessage + "</span>",
                        MaxLength = maxLength,
                        CssClass = cssClass
                    });
            }

            if (validationType == ValidationType.LimitedSelection)
            {
                if (selectionLimit > 0)
                {
                    var gnarlyScriptBuilder = new StringBuilder(128);
                    gnarlyScriptBuilder.Append("<script type=\"text/javascript\">");
                    gnarlyScriptBuilder.Append(Environment.NewLine);

                    gnarlyScriptBuilder.Append("var checkBoxesSelected = 0;");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("var checkBoxLimit = ");
                    gnarlyScriptBuilder.Append(selectionLimit);
                    gnarlyScriptBuilder.Append(";");
                    gnarlyScriptBuilder.Append(Environment.NewLine);

                    gnarlyScriptBuilder.Append("function CheckSelectedCount(val)");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("{");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			    jQuery('.limit-reached').hide(); ");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		var allowCheck = true;");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		if (val.checked)");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		{");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			if ((checkBoxesSelected + 1) <= checkBoxLimit)");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			{");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("				checkBoxesSelected++;");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			}");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			else");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			{");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			    jQuery('.limit-reached').show(); ");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("				allowCheck = false;");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			}");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		}");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		else ");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		{");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("			checkBoxesSelected--;");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		}");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("		return allowCheck;");
                    gnarlyScriptBuilder.Append(Environment.NewLine);
                    gnarlyScriptBuilder.Append("}");
                    gnarlyScriptBuilder.Append(Environment.NewLine);

                    gnarlyScriptBuilder.Append("</script>");
                    gnarlyScriptBuilder.Append(Environment.NewLine);

                    if (!manager.IsClientScriptBlockRegistered("CheckBoxLimitCheck"))
                    {
                        manager.RegisterClientScriptBlock(this.GetType(), "CheckBoxLimitCheck", gnarlyScriptBuilder.ToString());
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the Click event of the btnResendInfotoFulfillmentAPI control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnResendInfotoFulfillmentAPI_Click(object sender, EventArgs e)
        {
            string message = AppLogic.GetString("SentFulfillmentAPI.Success", SkinID, ThisCustomer.LocaleSetting.ToString());

            try
            {
                using (var conn = DB.dbConn())
                {
                    conn.Open();
                    using (var cmd = new SqlCommand("aspdnsf_GetOrderItemsDetail", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ORDERNUMBER", OrderNumber);
                        reader2 = cmd.ExecuteReader();
                        int totalRRDRow = 0;
                        while (reader2.Read())
                        {
                            if ((reader2["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor RRD", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader2["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor CDS Publications", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader2["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor Wetzel Brothers", SkinID, ThisCustomer.LocaleSetting)))
                            {
                                totalRRDRow++;
                            }
                        }
                        reader2.Close();
                        reader = cmd.ExecuteReader();
                        orderService.brandstore.ws.orderService    os = new orderService.brandstore.ws.orderService();
                        orderService.brandstore.ws.Credentials     c  = new orderService.brandstore.ws.Credentials();
                        orderService.brandstore.ws.BillingAddress  Ba = new orderService.brandstore.ws.BillingAddress();
                        orderService.brandstore.ws.ShippingAddress Sa = new orderService.brandstore.ws.ShippingAddress();
                        orderService.brandstore.ws.Product         p;
                        orderService.brandstore.ws.Product[]       pa = new orderService.brandstore.ws.Product[totalRRDRow];

                        // Set the authentication
                        c.Username = AppLogic.AppConfig("fullfillmentapi_username");
                        c.Token    = AppLogic.AppConfig("fullfillmentapi_password");
                        SetBillingAndShippingAddresses(ref Ba, ref Sa, OrderNumber);
                        int    index              = 0;
                        bool   hasproducts        = false;
                        string shippingMethodCode = string.Empty;
                        string shippingMethod     = string.Empty;

                        while (reader.Read())
                        {
                            if ((reader["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor RRD", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor CDS Publications", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor Wetzel Brothers", SkinID, ThisCustomer.LocaleSetting)))
                            {
                                p = new orderService.brandstore.ws.Product();
                                // set the product
                                p.ID          = reader["ProductID"].ToString();
                                p.Quantity    = reader["Quantity"].ToString();
                                p.SKU         = reader["SKU"].ToString();
                                p.Description = reader["OrderedProductName"].ToString();
                                pa[index]     = p;
                                index++;
                                hasproducts        = true;
                                shippingMethodCode = reader["ShippingMethodCode"].ToString();
                                shippingMethod     = reader["ShippingMethod"].ToString();
                            }
                        }
                        // call the service after verification if the shopping cart has RRD Product
                        if (hasproducts)
                        {
                            orderService.brandstore.ws.ReturnStatus rs = os.processOrder(c, OrderNumber.ToString(), OrderNumber.ToString(), Ba, Sa, DateTime.Now, pa, AppLogic.GetString("Fullfilment Vendor RRDParam", SkinID, ThisCustomer.LocaleSetting), shippingMethodCode, shippingMethod);
                            bool isok = rs.status.Equals(0) ? false : true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                message = AppLogic.GetString("SentFulfillmentAPI.Error", SkinID, ThisCustomer.LocaleSetting.ToString());
                SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                                  ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""),
                                  MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
            }
            finally
            {
                string script = "alert('" + message + "')";
                System.Web.UI.ClientScriptManager cs = this.ClientScript;
                cs.RegisterClientScriptBlock(this.GetType(), "alertMessage", script, true);
            }
        }