コード例 #1
0
        private void getBook(HttpContext context)
        {
            string  ISBN   = context.Request["ISBN"];
            string  type   = context.Request["type"];
            DataSet bookds = bookbll.SelectByIsbn(ISBN);

            if (bookds != null)
            {
                string saleId                = context.Request["saletaskID"];
                string customerId            = saletaskbll.getCustomerId(saleId);
                LibraryCollectionBll library = new LibraryCollectionBll();
                Result libresult             = library.Selectbook(customerId, ISBN);
                if (libresult == Result.记录不存在 || type == "continue")
                {
                    SaleTaskBll saletaskbll = new SaleTaskBll();
                    DataSet     limtds      = saletaskbll.SelectBysaleTaskId(saleId);
                    string      copy        = limtds.Tables[0].Rows[0]["defaultCopy"].ToString();
                    //如果有两条及两条以上
                    if (bookds.Tables[0].Rows.Count > 1)
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("bookNum", typeof(string));
                        dt.Columns.Add("rownum", typeof(int));
                        dt.Columns.Add("bookName", typeof(string));
                        dt.Columns.Add("unitPrice", typeof(double));
                        dt.Columns.Add("count", typeof(int));
                        dt.Columns.Add("color", typeof(string));
                        for (int i = 0; i < bookds.Tables[0].Rows.Count; i++)
                        {
                            int regionid = saletaskbll.GetregionidBysaleid(saleId);
                            int count    = stobll.selectStockNum(bookds.Tables[0].Rows[i]["bookNum"].ToString(), regionid);
                            if (count == 0)
                            {
                                continue;
                            }
                            dt.Rows.Add(bookds.Tables[0].Rows[i]["bookNum"].ToString(), Convert.ToInt32((i + 1)), bookds.Tables[0].Rows[i]["bookName"].ToString(), Convert.ToDouble(bookds.Tables[0].Rows[i]["price"].ToString()), count, "");
                        }
                        if (dt.Rows.Count == 1)
                        {
                            book book = new book();
                            //bookNum,ISBN,price,author,bookName,supplier
                            int regionid = saletaskbll.GetregionidBysaleid(saleId);
                            int count    = stobll.selectStockNum(dt.Rows[0]["bookNum"].ToString(), regionid);
                            if (count != 0)
                            {
                                book.BookNum  = bookds.Tables[0].Rows[0]["bookNum"].ToString();
                                book.BookName = bookds.Tables[0].Rows[0]["bookName"].ToString();
                                book.Price    = double.Parse(bookds.Tables[0].Rows[0]["price"].ToString());
                                book.count    = count;
                                if (copy == "" || copy == null)
                                {
                                    book.number = "0";
                                }
                                else
                                {
                                    book.number = copy;
                                }
                                string json = JsonHelper.JsonSerializerBySingleData(book);
                                context.Response.Write(json);
                                context.Response.End();
                            }
                            else
                            {
                                context.Response.Write("无库存");
                                context.Response.End();
                            }
                        }
                        else if (dt.Rows.Count != 0)
                        {
                            Page page = new Page();
                            if (copy == "" || copy == null)
                            {
                                page.number = "0";
                            }
                            else
                            {
                                page.number = copy;
                            }
                            page.data = JsonHelper.ToJson(dt, "book");
                            page.type = "books";
                            string json = JsonHelper.JsonSerializerBySingleData(page);
                            context.Response.Write(json);
                            context.Response.End();
                        }
                        else
                        {
                            context.Response.Write("无库存");
                            context.Response.End();
                        }
                    }
                    //只有一条数据
                    else
                    {
                        book book = new book();
                        //bookNum,ISBN,price,author,bookName,supplier
                        int regionid = saletaskbll.GetregionidBysaleid(saleId);
                        int count    = stobll.selectStockNum(bookds.Tables[0].Rows[0]["bookNum"].ToString(), regionid);
                        if (count != 0)
                        {
                            book.BookNum  = bookds.Tables[0].Rows[0]["bookNum"].ToString();
                            book.BookName = bookds.Tables[0].Rows[0]["bookName"].ToString();
                            book.Price    = double.Parse(bookds.Tables[0].Rows[0]["price"].ToString());
                            book.count    = count;
                            if (copy == "" || copy == null)
                            {
                                book.number = "0";
                            }
                            else
                            {
                                book.number = copy;
                            }
                            string json = JsonHelper.JsonSerializerBySingleData(book);
                            context.Response.Write(json);
                            context.Response.End();
                        }
                        else
                        {
                            context.Response.Write("无库存");
                            context.Response.End();
                        }
                    }
                }
                else
                {
                    context.Response.Write("馆藏存在");
                    context.Response.End();
                }
            }
            else
            {
                context.Response.Write("无数据");
                context.Response.End();
            }
        }
コード例 #2
0
ファイル: retail.ashx.cs プロジェクト: kiritobin/bms
        /// <summary>
        /// 第一次扫描isbn
        /// </summary>
        /// <param name="context"></param>
        public void isbn(HttpContext context)
        {
            string isbn     = context.Request["isbn"];
            string regionId = context.Request["regionId"];

            if (isbn != null && isbn != "")
            {
                DataTable bookDs = retailBll.SelectByIsbn(isbn);
                if (bookDs == null)
                {
                    retailM.type = "ISBN不存在";
                    string json = JsonHelper.JsonSerializerBySingleData(retailM);
                    context.Response.Write(json);
                    context.Response.End();
                }
                else
                {
                    int count = bookDs.Rows.Count;
                    if (bookDs != null && count > 0)
                    {
                        if (count == 1)
                        {
                            string bookNum  = bookDs.Rows[0]["bookNum"].ToString();
                            int    stockNum = stockBll.selectStockNum(bookNum, Convert.ToInt32(regionId));
                            if (stockNum <= 0)
                            {
                                retailM.type = "无库存信息";
                                string json = JsonHelper.JsonSerializerBySingleData(retailM);
                                context.Response.Write(json);
                                context.Response.End();
                            }
                            else
                            {
                                retailM.type = "一号一书";
                                double discount = 100;
                                if (bookDs.Rows[0]["discount"].ToString() != null && bookDs.Rows[0]["discount"].ToString() != "")
                                {
                                    discount = Convert.ToDouble(bookDs.Rows[0]["discount"]);
                                }
                                bookDs.Columns.Add("number", typeof(string));
                                bookDs.Rows[0]["number"] = "1";
                                bookDs.Columns.Add("focus", typeof(bool));
                                bookDs.Rows[0]["focus"] = false;
                                bookDs.Columns.Add("totalPrice", typeof(string));
                                bookDs.Rows[0]["totalPrice"] = bookDs.Rows[0]["price"].ToString();
                                bookDs.Columns.Add("totalReal", typeof(string));
                                bookDs.Rows[0]["totalReal"] = (Convert.ToDouble(bookDs.Rows[0]["price"]) * discount * 0.01).ToString();
                                bookDs.Columns.Add("stockNum", typeof(string));
                                bookDs.Rows[0]["stockNum"] = stockNum.ToString();
                                string data = JsonHelper.ToJson(bookDs, "retail");
                                retailM.data = data;
                                string json = JsonHelper.JsonSerializerBySingleData(retailM);
                                context.Response.Write(json);
                                context.Response.End();
                            }
                        }
                        else
                        {
                            retailM.type = "一号多书";
                            string strJson = JsonHelper.JsonSerializerBySingleData(retailM);
                            context.Response.Write(strJson);
                            context.Response.End();
                        }
                    }
                    else
                    {
                        retailM.type = "ISBN不存在";
                        string strJson = JsonHelper.JsonSerializerBySingleData(retailM);
                        context.Response.Write(strJson);
                        context.Response.End();
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 客户选择图书
        /// </summary>
        /// <returns></returns>
        public string getIsbn()
        {
            string op        = Request["op"];
            string isbn      = Request["isbn"];
            double disCount  = Convert.ToDouble(Request["disCount"]);
            int    billCount = Convert.ToInt32(Request["billCount"]);

            if (isbn != null && isbn != "")
            {
                BookBasicBll bookBasicBll = new BookBasicBll();
                DataSet      bookDs       = bookBasicBll.SelectByIsbn(isbn);
                if (bookDs != null && bookDs.Tables[0].Rows.Count > 0)
                {
                    int count = bookDs.Tables[0].Rows.Count;
                    if (count == 1)
                    {
                        string headId = "", bookNum = "";
                        if (op == "isbn")
                        {
                            headId  = Request["headId"];
                            bookNum = bookDs.Tables[0].Rows[0]["bookNum"].ToString();
                        }
                        else if (op == "newRetail")
                        {
                            headId  = insertHead();
                            bookNum = bookDs.Tables[0].Rows[0]["bookNum"].ToString();
                        }
                        add(bookNum, headId, "one");
                    }
                    if (op == "choose" || op == "newChoose")
                    {
                        int           counts = bookDs.Tables[0].Rows.Count;
                        StringBuilder sb     = new StringBuilder();
                        int           i      = 0;
                        while (i < counts)
                        {
                            DataRow dr       = bookDs.Tables[0].Rows[i];
                            User    user     = (User)Session["user"];
                            string  bookNum  = dr["bookNum"].ToString();
                            int     stockNum = stockBll.selectStockNum(dr["bookNum"].ToString(), user.ReginId.RegionId);
                            if (stockNum <= 0)
                            {
                                bookDs.Tables[0].Rows.RemoveAt(i);
                                counts--;
                            }
                            else
                            {
                                i++;
                            }
                        }
                        if (counts == 0)
                        {
                            Response.Write("无库存|:");
                            Response.End();
                        }
                        else if (counts == 1)
                        {
                            string headId = "";
                            if (op == "choose")
                            {
                                headId = Request["headId"];
                            }
                            else if (op == "newChoose")
                            {
                                headId = insertHead();
                            }
                            add(bookDs.Tables[0].Rows[0]["bookNum"].ToString(), headId, "other");
                        }
                        else
                        {
                            counts = bookDs.Tables[0].Rows.Count;
                            for (int j = 0; j < counts; j++)
                            {
                                DataRow dr = bookDs.Tables[0].Rows[j];
                                sb.Append("<tr><td><div class='pretty inline'><input type = 'radio' name='radio' value='" + dr["bookNum"].ToString() + "'><label><i class='mdi mdi-check'></i></label></div></td>");
                                sb.Append("<td>" + dr["ISBN"].ToString() + "</td>");
                                sb.Append("<td>" + dr["bookNum"].ToString() + "</td>");
                                sb.Append("<td>" + dr["bookName"].ToString() + "</td>");
                                sb.Append("<td>" + dr["price"].ToString() + "</td>");
                                sb.Append("<td>" + dr["supplier"].ToString() + "</td></tr>");
                            }
                            Response.Write("|:" + sb.ToString());
                            Response.End();
                        }
                    }
                    Response.Write("一号多书");
                    Response.End();
                }
                else
                {
                    Response.Write("ISBN不存在");
                    Response.End();
                }
            }
            return(null);
        }