Exemplo n.º 1
0
        /// <summary>
        /// 获取销售任务码洋限制
        /// </summary>
        public void getlimt()
        {
            DataSet limtds = saletaskbll.SelectBysaleTaskId(saleId);
            string  copy   = limtds.Tables[0].Rows[0]["defaultCopy"].ToString();

            if (copy == "" || copy == null)
            {
                defaultCopy = 0;
            }
            else
            {
                defaultCopy = double.Parse(copy);
            }
            numberLimit = int.Parse(limtds.Tables[0].Rows[0]["numberLimit"].ToString());
            priceLimit  = double.Parse(limtds.Tables[0].Rows[0]["priceLimit"].ToString());
        }
Exemplo n.º 2
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();
            }
        }