示例#1
0
        public ActionResult Update(int id, FromCollection f)
        {
            ShoppingCart cart = (ShoppingCart)Session["cart"];

            if (cart == null)
            {
                cart = new ShoppingCart();
            }
            return(Redirect(Request.UrlReferrer.ToString()));
        }
示例#2
0
        // 获得检索式
        public int GetQueryString(
            FromCollection Froms,
            out string strQueryString,
            out string strError)
        {
            strError       = "";
            strQueryString = "";

            for (int i = 0; i < this.Lines.Count; i++)
            {
                Line line = this.Lines[i];

                string strLogic = line.comboBox_logicOperator.Text;
                string strWord  = line.textBox_word.Text;
                string strFrom  = line.comboBox_from.Text;

                if (strWord == "")
                {
                    continue;
                }

                if (strQueryString != "")
                {
                    strQueryString += " " + strLogic + " ";
                }

                int nRet = strFrom.IndexOf("-");
                if (nRet != -1)
                {
                    strFrom = strFrom.Substring(0, nRet).Trim();
                }

                string strValue = Froms.GetValue(strFrom);
                if (strValue == null)
                {
                    strError = "名称 '" + strFrom + "' 在use表中没有找到对应的编号";
                    return(-1);
                }

                strWord.Replace("\"", "\\\"");
                strQueryString += "\""
                                  + strWord + "\"" + "/1="
                                  + strValue;
            }

            return(0);
        }
示例#3
0
        // 获得检索式
        public int GetQueryString(
            FromCollection Froms,
            out string strQueryString,
            out string strError)
        {
            strError = "";
            strQueryString = "";

            for (int i = 0; i < this.Lines.Count; i++)
            {
                Line line = this.Lines[i];

                string strLogic = line.comboBox_logicOperator.Text;
                string strWord = line.textBox_word.Text;
                string strFrom = line.comboBox_from.Text;

                if (strWord == "")
                    continue;

                if (strQueryString != "")
                    strQueryString += " " + strLogic + " ";

                int nRet = strFrom.IndexOf("-");
                if (nRet != -1)
                    strFrom = strFrom.Substring(0, nRet).Trim();

                string strValue = Froms.GetValue(strFrom);
                if (strValue == null)
                {
                    strError = "名称 '" +strFrom+ "' 在use表中没有找到对应的编号";
                    return -1;
                }

                strWord.Replace("\"", "\\\"");
                strQueryString += "\""
                    + strWord + "\"" + "/1="
                    + strValue;

            }

            return 0;
        }
示例#4
0
        // 将 XML 检索式变化为简明格式检索式
        public static int GetQueryString(
            FromCollection Froms,
            string strQueryXml,
            IsbnConvertInfo isbnconvertinfo,
            out string strQueryString,
            out string strError)
        {
            strError       = "";
            strQueryString = "";

            if (String.IsNullOrEmpty(strQueryXml) == true)
            {
                return(0);
            }

            XmlDocument dom = new XmlDocument();

            try
            {
                dom.LoadXml(strQueryXml);
            }
            catch (Exception ex)
            {
                strError = "strQueryXml装入XMLDOM时出错: " + ex.Message;
                return(-1);
            }

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("line");

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node     = nodes[i];
                string  strLogic = DomUtil.GetAttr(node, "logic");
                string  strWord  = DomUtil.GetAttr(node, "word");
                string  strFrom  = DomUtil.GetAttr(node, "from");

                if (strWord == "")
                {
                    continue;
                }

                strLogic = GetLogicString(strLogic);    // 2011/8/30

                if (strQueryString != "")
                {
                    strQueryString += " " + strLogic + " ";
                }

                int nRet = strFrom.IndexOf("-");
                if (nRet != -1)
                {
                    strFrom = strFrom.Substring(0, nRet).Trim();
                }

                string strValue = Froms.GetValue(strFrom);
                if (strValue == null)
                {
                    strError = "名称 '" + strFrom + "' 在use表中没有找到对应的编号";
                    return(-1);
                }

                // 对ISBN检索词进行预处理
                if (strFrom == "ISBN" &&
                    isbnconvertinfo != null)
                {
                    /*
                     * // return:
                     * //      -1  出错
                     * //      0   没有必要转换
                     * //      1   已经转换
                     * nRet = isbnconvertinfo.ConvertISBN(ref strWord,
                     * out strError);
                     * if (nRet == -1)
                     * {
                     *  strError = "在处理ISBN字符串 '" + strWord + "' 过程中出错: " + strError;
                     *  return -1;
                     * }
                     * */
                    List <string> isbns = null;
                    // return:
                    //      -1  出错
                    //      0   没有必要转换
                    //      1   已经转换
                    nRet = isbnconvertinfo.ConvertISBN(strWord,
                                                       out isbns,
                                                       out strError);
                    if (nRet == -1)
                    {
                        strError = "在处理ISBN字符串 '" + strWord + "' 过程中出错: " + strError;
                        return(-1);
                    }

                    int j = 0;
                    foreach (string isbn in isbns)
                    {
                        if (j > 0)
                        {
                            strQueryString += " OR ";
                        }
                        // string strIsbn = isbn.Replace("\"", "\\\"");    // 字符 " 替换为 \"
                        string strIsbn = StringUtil.EscapeString(isbn, "\"/=");    // eacape 特殊字符
                        strQueryString += "\""
                                          + strIsbn + "\"" + "/1="
                                          + strValue;
                        j++;
                    }
                    continue;
                }

                // strWord = strWord.Replace("\"", "\\\""); // 字符 " 替换为 \"
                strWord         = StringUtil.EscapeString(strWord, "\"/="); // eacape 特殊字符
                strQueryString += "\""
                                  + strWord + "\"" + "/1="
                                  + strValue;
            }

            return(1);
        }
示例#5
0
        // 将XML检索式变化为简明格式检索式
        public static int GetQueryString(
            FromCollection Froms,
            string strQueryXml,
            IsbnConvertInfo isbnconvertinfo,
            out string strQueryString,
            out string strError)
        {
            strError = "";
            strQueryString = "";

            if (String.IsNullOrEmpty(strQueryXml) == true)
                return 0;

            XmlDocument dom = new XmlDocument();
            try
            {
                dom.LoadXml(strQueryXml);
            }
            catch (Exception ex)
            {
                strError = "strQueryXml装入XMLDOM时出错: " + ex.Message;
                return -1;
            }

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("line");


            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];
                string strLogic = DomUtil.GetAttr(node, "logic");
                string strWord = DomUtil.GetAttr(node, "word");
                string strFrom = DomUtil.GetAttr(node, "from");

                if (strWord == "")
                    continue;

                strLogic = GetLogicString(strLogic);    // 2011/8/30

                if (strQueryString != "")
                    strQueryString += " " + strLogic + " ";

                int nRet = strFrom.IndexOf("-");
                if (nRet != -1)
                    strFrom = strFrom.Substring(0, nRet).Trim();



                string strValue = Froms.GetValue(strFrom);
                if (strValue == null)
                {
                    strError = "名称 '" + strFrom + "' 在use表中没有找到对应的编号";
                    return -1;
                }

                // 对ISBN检索词进行预处理
                if (strFrom == "ISBN"
                    && isbnconvertinfo != null)
                {
                    /*
                    // return:
                    //      -1  出错
                    //      0   没有必要转换
                    //      1   已经转换
                    nRet = isbnconvertinfo.ConvertISBN(ref strWord,
                out strError);
                    if (nRet == -1)
                    {
                        strError = "在处理ISBN字符串 '" + strWord + "' 过程中出错: " + strError;
                        return -1;
                    }
                     * */
                    List<string> isbns = null;
                    // return:
                    //      -1  出错
                    //      0   没有必要转换
                    //      1   已经转换
                    nRet = isbnconvertinfo.ConvertISBN(strWord,
                        out isbns,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "在处理ISBN字符串 '" + strWord + "' 过程中出错: " + strError;
                        return -1;
                    }

                    int j = 0;
                    foreach (string isbn in isbns)
                    {
                        if (j > 0)
                            strQueryString += " OR ";
                        string strIsbn = isbn.Replace("\"", "\\\"");
                        strQueryString += "\""
                            + strIsbn + "\"" + "/1="
                            + strValue;
                        j++;
                    }
                    continue;
                }

                strWord = strWord.Replace("\"", "\\\"");
                strQueryString += "\""
                    + strWord + "\"" + "/1="
                    + strValue;
            }

            return 1;
        }