Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user   = (User)Session["user"];
            type   = Session["saleType"].ToString();
            saleId = Session["saleId"].ToString();
            //getData();
            getlimt();
            SaleTask task = saletaskbll.selectById(saleId);

            defaultdiscount = task.DefaultDiscount.ToString();
            SaleHeadId      = Session["saleheadId"].ToString();

            //更新单头
            updateSalehead();
            string op = Request["op"];

            //isbn回车
            if (op == "search")
            {
                string ISBN = Request["ISBN"];
                bookds = bookbll.SelectByIsbn(ISBN);
                if (bookds != null)
                {
                    //如果有两条及两条以上显示表格
                    if (bookds.Tables[0].Rows.Count > 1)
                    {
                        getbook();
                    }
                    //只有一条数据
                    else
                    {
                        backbook();
                    }
                }
                else
                {
                    Response.Write("无数据");
                    Response.End();
                }
            }
            //一书多号选择后执行
            if (op == "add")
            {
                showBook();
            }
            //添加销售
            if (op == "addsale")
            {
                SaleHeadBll saleheadbll   = new SaleHeadBll();
                string      saletaskId    = saleheadbll.SelectTaskByheadId(SaleHeadId);
                string      customerId    = saletaskbll.getCustomerId(saletaskId);
                int         AlreadyBought = user.ReginId.RegionId;
                //判断馆藏
                LibraryCollectionBll library = new LibraryCollectionBll();
                bookISBN = Request["bookISBN"];
                Result libresult = library.Selectbook(customerId, bookISBN);
                if (libresult == Result.记录不存在)
                {
                    bookISBN = Request["bookISBN"];
                    disCount = double.Parse(Request["discount"]);
                    number   = Convert.ToInt32(Request["number"]);
                    bookNum  = Request["bookNum"].ToString();
                    if (number < 0)
                    {
                        number = Math.Abs(number);
                        DataSet bookNumds = salemonbll.getsalemonDetail(SaleHeadId, saleId, bookNum);
                        if (bookNumds != null)
                        {
                            int booknumber = int.Parse(bookNumds.Tables[0].Rows[0]["number"].ToString());
                            if (number > booknumber)
                            {
                                msg.Messege = "输入的负数不能大于已购数量,已购数为:" + booknumber;
                                Response.Write(ObjectToJson(msg));
                                Response.End();
                            }
                            else
                            {
                                number = number * -1;
                                addsalemon();
                            }
                        }
                        else
                        {
                            msg.Messege = "该书籍没有购买过,数量不能为负数";
                            Response.Write(ObjectToJson(msg));
                            Response.End();
                        }
                    }
                    else
                    {
                        addsalemon();
                    }
                }
                else
                {
                    msg.Messege = "客户馆藏已存在";
                    Response.Write(ObjectToJson(msg));
                    Response.End();
                }
            }
            //客户馆藏已存在,继续录入
            if (op == "addRsMon")
            {
                bookISBN = Request["bookISBN"];
                disCount = double.Parse(Request["discount"]);
                number   = Convert.ToInt32(Request["number"]);
                bookNum  = Request["bookNum"].ToString();
                if (number < 0)
                {
                    number = Math.Abs(number);
                    DataSet bookNumds = salemonbll.getsalemonDetail(SaleHeadId, saleId, bookNum);
                    if (bookNumds != null)
                    {
                        int booknumber = int.Parse(bookNumds.Tables[0].Rows[0]["number"].ToString());
                        if (number > booknumber)
                        {
                            msg.Messege = "输入的负数不能大于已购数量,已购数为:" + booknumber;
                            Response.Write(ObjectToJson(msg));
                            Response.End();
                        }
                        else
                        {
                            number = number * -1;
                            addsalemon();
                        }
                    }
                    else
                    {
                        msg.Messege = "该书籍没有购买过,数量不能为负数";
                        Response.Write(ObjectToJson(msg));
                        Response.End();
                    }
                }
                else
                {
                    addsalemon();
                }
            }
            //完成单据
            if (op == "success")
            {
                //判断是否有单体
                int row = salemonbll.SelectBySaleHeadId(SaleHeadId);
                if (row > 0)
                {
                    //修改单头状态为2
                    Result result = salemonbll.updateHeadstate(saleId, SaleHeadId, 2);
                    if (result == Result.更新成功)
                    {
                        Response.Write("状态修改成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("状态修改失败");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("没有数据");
                    Response.End();
                }
            }
            //返回按钮
            if (op == "back")
            {
                updateSalehead();
                int row = salemonbll.SelectBySaleHeadId(SaleHeadId);
                if (row > 0)
                {
                    string state = salemonbll.getsaleHeadState(SaleHeadId, saleId);
                    if (state == "0")
                    {
                        Result res = salemonbll.updateHeadstate(saleId, SaleHeadId, 1);
                        if (res == Result.更新成功)
                        {
                            Response.Write("更新成功");
                            Response.End();
                        }
                        else
                        {
                            Response.Write("更新失败");
                            Response.End();
                        }
                    }
                    else
                    {
                        Response.Write("无数据");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("无数据");
                    Response.End();
                }
            }
        }
Exemple #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();
            }
        }
Exemple #3
0
        protected void selectIsbn()
        {
            //货架
            GoodsShelvesBll goodsShelvesBll = new GoodsShelvesBll();
            User            user            = (User)Session["user"];
            int             regionId        = user.ReginId.RegionId;

            dsGoods = goodsShelvesBll.Select(regionId);

            string    action   = Request["action"];
            string    isbn     = Request["isbn"];
            DataTable monTable = new DataTable();
            DataRow   dr       = monTable.NewRow();

            if (action == "isbn")
            {
                long    monId  = Convert.ToInt64(Request["sid"]);
                DataSet dsBook = basicBll.SelectByIsbn(isbn);
                if (dsBook == null || dsBook.Tables[0].Rows.Count <= 0)
                {
                    Response.Write("ISBN不存在");
                    Response.End();
                }
                else
                {
                    int billCount = Convert.ToInt32(Request["billCount"]);

                    string bookName = dsBook.Tables[0].Rows[0]["bookName"].ToString();
                    string bookNum  = dsBook.Tables[0].Rows[0]["bookNum"].ToString();
                    string supplier = dsBook.Tables[0].Rows[0]["supplier"].ToString();
                    double uPrice   = Convert.ToDouble(dsBook.Tables[0].Rows[0]["price"]);
                    if (dsBook.Tables[0].Rows[0]["author"].ToString() == null || dsBook.Tables[0].Rows[0]["author"].ToString() == "")
                    {
                        discount = 100;
                    }
                    else
                    {
                        discount = Convert.ToDouble(dsBook.Tables[0].Rows[0]["author"]);
                        if (discount < 1)
                        {
                            discount = discount * 100;
                        }
                    }
                    double totalPrice = Convert.ToDouble((billCount * uPrice).ToString("0.00"));
                    double realPrice  = Convert.ToDouble((totalPrice * discount * 0.01).ToString("0.00"));

                    monTable.Columns.Add("ISBN", typeof(string));
                    monTable.Columns.Add("uPrice", typeof(double));
                    monTable.Columns.Add("bookName", typeof(string));
                    monTable.Columns.Add("bookNum", typeof(string));
                    monTable.Columns.Add("discount", typeof(double));
                    monTable.Columns.Add("monId", typeof(long));
                    monTable.Columns.Add("number", typeof(string));
                    monTable.Columns.Add("totalPrice", typeof(double));
                    monTable.Columns.Add("realPrice", typeof(double));
                    monTable.Columns.Add("singleHeadId", typeof(string));
                    monTable.Columns.Add("supplier", typeof(string));

                    dr["ISBN"]         = isbn;
                    dr["uPrice"]       = uPrice;
                    dr["bookName"]     = bookName;
                    dr["bookNum"]      = bookNum;
                    dr["discount"]     = discount;
                    dr["monId"]        = monId;
                    dr["number"]       = billCount;
                    dr["totalPrice"]   = totalPrice;
                    dr["realPrice"]    = realPrice;
                    dr["singleHeadId"] = singleHeadId;
                    dr["supplier"]     = supplier;
                    monTable.Rows.Add(dr);
                    int           count = dsBook.Tables[0].Rows.Count;
                    StringBuilder sb    = new StringBuilder();
                    if (count == 1)
                    {
                        for (int i = 0; i < monTable.Rows.Count; i++)
                        {
                            bookNumList = (List <string>)Session["List"];
                            foreach (string bookNums in bookNumList)
                            {
                                if (bookNums == monTable.Rows[i]["bookNum"].ToString())
                                {
                                    Response.Write("已添加过此图书");
                                    Response.End();
                                }
                            }
                            bookNumList.Add(monTable.Rows[i]["bookNum"].ToString());
                            Session["List"] = bookNumList;
                            sb.Append("<tr><td>" + monTable.Rows[i]["monId"] + "</td>");
                            sb.Append("<td><textarea class='isbn textareaISBN' row='1' maxlength='13'>" + monTable.Rows[i]["ISBN"] + "</textarea></td>");
                            sb.Append("<td style='display:none'>" + monTable.Rows[i]["bookNum"] + "</td>");
                            sb.Append("<td>" + monTable.Rows[i]["bookName"] + "</td>");
                            sb.Append("<td>" + monTable.Rows[i]["supplier"] + "</td>");
                            sb.Append("<td><textarea class='count textareaCount' row='1'>" + 0 + "</textarea></td>");
                            sb.Append("<td>" + monTable.Rows[i]["uPrice"] + "</td>");
                            sb.Append("<td><textarea class='discount textareaDiscount' row='1'>" + monTable.Rows[i]["discount"] + "</textarea></td>");
                            sb.Append("<td>" + monTable.Rows[i]["totalPrice"] + "</td>");
                            sb.Append("<td>" + monTable.Rows[i]["realPrice"] + "</td>");
                            sb.Append("<td><button class='btn btn-danger btn-sm'><i class='fa fa-trash'></i></button></td></tr>");
                        }
                        Response.Write(sb.ToString());
                        Response.End();
                    }
                    else
                    {
                        sb.Append("<tbody>");
                        for (int i = 0; i < dsBook.Tables[0].Rows.Count; i++)
                        {
                            sb.Append("<tr><td><div class='pretty inline much'><input type = 'radio' name='radio' value='" + dsBook.Tables[0].Rows[i]["bookNum"].ToString() + "'><label><i class='mdi mdi-check'></i></label></div></td>");
                            sb.Append("<td>" + dsBook.Tables[0].Rows[i]["bookNum"].ToString() + "</td>");
                            sb.Append("<td>" + dsBook.Tables[0].Rows[i]["ISBN"].ToString() + "</td>");
                            sb.Append("<td>" + dsBook.Tables[0].Rows[i]["bookName"].ToString() + "</td>");
                            sb.Append("<td>" + dsBook.Tables[0].Rows[i]["price"].ToString() + "</td>");
                            sb.Append("<td>" + dsBook.Tables[0].Rows[i]["supplier"].ToString() + "</td></tr>");
                        }
                        sb.Append("</tbody>");
                        Response.Write(sb.ToString());
                        Response.End();
                        //Response.Write("一号多书");
                        //Response.End();
                    }
                }
            }
            else if (action == "add")
            {
                long monId = Convert.ToInt64(Request["sid"]);
                monTable.Columns.Add("ISBN", typeof(string));
                monTable.Columns.Add("uPrice", typeof(double));
                monTable.Columns.Add("bookName", typeof(string));
                monTable.Columns.Add("bookNum", typeof(string));
                monTable.Columns.Add("discount", typeof(double));
                monTable.Columns.Add("monId", typeof(long));
                monTable.Columns.Add("number", typeof(string));
                monTable.Columns.Add("totalPrice", typeof(double));
                monTable.Columns.Add("realPrice", typeof(double));
                monTable.Columns.Add("singleHeadId", typeof(string));
                monTable.Columns.Add("supplier", typeof(string));

                string        bookNum       = Request["bookNum"].ToString();
                BookBasicData bookBasicData = basicBll.SelectById(bookNum);
                string        supplier      = bookBasicData.Publisher;
                string        bookName      = bookBasicData.BookName;
                string        publisher     = bookBasicData.Publisher;
                double        price         = bookBasicData.Price;
                string        _isbn         = bookBasicData.Isbn;
                string        discount      = bookBasicData.Author;
                if (discount == "" || discount == null)
                {
                    discount = "100";
                }

                bookNumList = (List <string>)Session["List"];
                foreach (string bookNums in bookNumList)
                {
                    if (bookNums == bookNum)
                    {
                        Response.Write("已添加过此图书");
                        Response.End();
                    }
                }

                dr["ISBN"]         = _isbn;
                dr["uPrice"]       = price;
                dr["bookName"]     = bookName;
                dr["bookNum"]      = bookNum;
                dr["discount"]     = discount;
                dr["monId"]        = monId;
                dr["number"]       = 0;
                dr["totalPrice"]   = 0;
                dr["realPrice"]    = 0;
                dr["singleHeadId"] = singleHeadId;
                dr["supplier"]     = supplier;
                monTable.Rows.Add(dr);
                for (int k = 0; k < monTable.Rows.Count; k++)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < monTable.Rows.Count; i++)
                    {
                        sb.Append("<tr><td>" + monTable.Rows[i]["monId"] + "</td>");
                        sb.Append("<td><textarea class='isbn textareaISBN' row='1' maxlength='13'>" + monTable.Rows[i]["ISBN"] + "</textarea></td>");
                        sb.Append("<td style='display:none'>" + monTable.Rows[i]["bookNum"] + "</td>");
                        sb.Append("<td>" + monTable.Rows[i]["bookName"] + "</td>");
                        sb.Append("<td>" + monTable.Rows[i]["supplier"] + "</td>");
                        sb.Append("<td><textarea class='count textareaCount' row='1'>" + monTable.Rows[i]["number"] + "</textarea></td>");
                        sb.Append("<td>" + monTable.Rows[i]["uPrice"] + "</td>");
                        sb.Append("<td><textarea class='discount textareaDiscount' row='1'>" + monTable.Rows[i]["discount"] + "</textarea></td>");
                        sb.Append("<td>" + monTable.Rows[i]["totalPrice"] + "</td>");
                        sb.Append("<td>" + monTable.Rows[i]["realPrice"] + "</td>");
                        sb.Append("<td><button class='btn btn-danger btn-sm'><i class='fa fa-trash'></i></button></td></tr>");
                        bookNumList.Add(bookNum);
                        Session["List"] = bookNumList;
                    }
                    Response.Write(sb.ToString());
                    Response.End();
                }
            }
            else if (action == "save")
            {
                string        json = Request["json"];
                DataTable     dataTable = jsonToDt(json);
                int           Count = dataTable.Rows.Count;
                Monomers      monomers = new Monomers();
                BookBasicData book = new BookBasicData();
                int           count = 0, counts = 0;
                double        total, allTotal = 0, real, allReal = 0;
                for (int i = 0; i < Count; i++)
                {
                    DataRow drow = dataTable.Rows[i];


                    string bookNum = drow["书号"].ToString();
                    count = Convert.ToInt32(drow["数量"]);
                    int     billCount = Convert.ToInt32(drow["数量"]);
                    string  goodsId   = "0";                                                      //货架ID
                    DataSet dsGoods   = stockBll.SelectByBookNum(bookNum, user.ReginId.RegionId); //出库组织库存量
                    int     rgId      = int.Parse(Session["jsRegionId"].ToString());              //接收组织ID
                    DataSet jsGoods   = stockBll.SelectByBookNum(bookNum, rgId);                  //接收组织库存量
                    for (int j = 0; j < dsGoods.Tables[0].Rows.Count; j++)
                    {
                        billCount = count;
                        int stockNum = Convert.ToInt32(dsGoods.Tables[0].Rows[j]["stockNum"]); //原库存量

                        goodsId = dsGoods.Tables[0].Rows[j]["goodsShelvesId"].ToString();      //获取货架ID
                        if (billCount <= stockNum)
                        {
                            int    a      = stockNum - billCount;
                            Result result = stockBll.update(a, goodsId, bookNum);
                            if (result == Result.更新失败)
                            {
                                Response.Write("添加失败");
                                Response.End();
                            }
                            //if (jsGoods.Tables[0].Rows.Count > 0)//判断库存中是否有数据
                            //{
                            //    int jsstockNum = Convert.ToInt32(jsGoods.Tables[0].Rows[0]["stockNum"]);//接收组织原库存量
                            //    int jsgoodsId = Convert.ToInt32(jsGoods.Tables[0].Rows[0]["goodsShelvesId"]);//接收组织库存Id
                            //    int jsNewStock = jsstockNum + billCount;//获取接收组织新的库存
                            //    result = stockBll.update(jsNewStock, jsgoodsId, bookNum);//更新入库库存
                            //    if (result == Result.更新失败)
                            //    {
                            //        Response.Write("更新失败");
                            //        Response.End();
                            //    }
                            //}
                            //else//没有数据时,直接添加
                            //{
                            //    //int jsgoodsId = Convert.ToInt32(jsGoods.Tables[0].Rows[0]["goodsShelvesId"]);//接收组织库存Id
                            //    int jsstockNum = billCount;//库存量
                            //    Region reg = new Region();
                            //    reg.RegionId = rgId;
                            //    DataSet gds = goodsShelvesBll.Select(rgId);
                            //    int gid = int.Parse(gds.Tables[0].Rows[0]["goodsShelvesId"].ToString());
                            //    GoodsShelves goods = new GoodsShelves();
                            //    goods.GoodsShelvesId = gid;
                            //    BookBasicData jsbook = new BookBasicData();
                            //    jsbook.BookNum = bookNum;
                            //    jsbook.Isbn = drow["ISBN号"].ToString();
                            //    Stock stock = new Stock();//库存实体
                            //    stock.BookNum = jsbook;
                            //    stock.ISBN = jsbook;
                            //    stock.RegionId = reg;
                            //    stock.StockNum = billCount;
                            //    stock.GoodsShelvesId = goods;
                            //    result = stockBll.insert(stock);//写入库存
                            //    if (result == Result.添加失败)
                            //    {
                            //        Response.Write("添加失败");
                            //        Response.End();
                            //    }
                            //}
                            Session["List"] = null;
                            break;
                        }
                        else
                        {
                            if (stockNum != 0)
                            {
                                Result result;
                                count = billCount - stockNum;
                                if (count > 0)
                                {
                                    result = stockBll.update(0, goodsId, bookNum);//记录存在且库存不为0
                                    if (result == Result.更新失败)
                                    {
                                        Response.Write("添加失败");
                                        Response.End();
                                    }
                                    count = billCount - stockNum;
                                    continue;
                                }
                                if (count == 0)
                                {
                                    Session["List"] = null;
                                    break;
                                }
                            }
                            //Response.Write("库存不足");
                            //Response.End();
                        }
                    }
                    //添加出库单体
                    book.Isbn           = drow["ISBN号"].ToString();
                    book.Price          = Convert.ToDouble(drow["单价"]);
                    book.BookNum        = drow["书号"].ToString();
                    monomers.Isbn       = book;
                    monomers.UPrice     = book;
                    monomers.BookNum    = book;
                    monomers.Discount   = Convert.ToDouble(drow["折扣"]);
                    monomers.MonomersId = Convert.ToInt32(drow["单据编号"]);
                    monomers.Number     = Convert.ToInt32(drow["数量"]);
                    monomers.TotalPrice = Convert.ToDouble(drow["码洋"]);
                    monomers.RealPrice  = Convert.ToDouble(drow["实洋"]);
                    monomers.ShelvesId  = goodsId;//货架ID
                    SingleHead single = new SingleHead();
                    single.SingleHeadId   = Session["singleHeadId"].ToString();
                    monomers.SingleHeadId = single;
                    count    = Convert.ToInt32(drow["数量"]);
                    counts   = counts + count;
                    total    = Convert.ToDouble(drow["码洋"]);
                    allTotal = allTotal + total;
                    real     = Convert.ToDouble(drow["实洋"]);
                    allReal  = allReal + real;
                    Result row = warehousingBll.insertMono(monomers);
                    if (row == Result.添加失败)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }



                    //book.Isbn = drow["ISBN号"].ToString();
                    //book.Price = Convert.ToDouble(drow["单价"]);
                    //book.BookNum = drow["书号"].ToString();
                    //monomers.Isbn = book;
                    //monomers.UPrice = book;
                    //monomers.BookNum = book;
                    //monomers.Discount = Convert.ToDouble(drow["折扣"]);
                    //monomers.MonomersId = Convert.ToInt32(drow["单据编号"]);
                    //monomers.Number = Convert.ToInt32(drow["商品数量"]);
                    //monomers.TotalPrice = Convert.ToDouble(drow["码洋"]);
                    //monomers.RealPrice = Convert.ToDouble(drow["实洋"]);
                    //SingleHead single = new SingleHead();
                    //single.SingleHeadId = Session["singleHeadId"].ToString();
                    //monomers.SingleHeadId = single;
                    //count = Convert.ToInt32(drow["商品数量"]);
                    //counts = counts + count;
                    //total = Convert.ToDouble(drow["码洋"]);
                    //allTotal = allTotal + total;
                    //real = Convert.ToDouble(drow["实洋"]);
                    //allReal = allReal + real;
                    //Result row = warehousingBll.insertMono(monomers);
                    //if (row == Result.添加失败)
                    //{
                    //    Response.Write("添加失败");
                    //    Response.End();
                    //}
                    //else if (row == Result.添加成功)
                    //{
                    //    string bookNum = drow["书号"].ToString();
                    //    int billCount = Convert.ToInt32(drow["商品数量"]);
                    //    DataSet dsGoods = stockBll.SelectByBookNum(bookNum, user.ReginId.RegionId);
                    //    for (int j = 0; j < dsGoods.Tables[0].Rows.Count; j++)
                    //    {
                    //        billCount = count;
                    //        int stockNum = Convert.ToInt32(dsGoods.Tables[0].Rows[j]["stockNum"]);
                    //        int goodsId = Convert.ToInt32(dsGoods.Tables[0].Rows[j]["goodsShelvesId"]);
                    //        if (billCount <= stockNum)
                    //        {
                    //            int a = stockNum - billCount;
                    //            Result result = stockBll.update(a, goodsId, bookNum);
                    //            if (result == Result.更新失败)
                    //            {
                    //                Response.Write("添加失败");
                    //                Response.End();
                    //            }
                    //        }
                    //        else
                    //        {
                    //            count = billCount - stockNum;
                    //            Result result = stockBll.update(0, goodsId, bookNum);
                    //            if (count == 0)
                    //            {
                    //                Session["List"] = null;
                    //                Response.Write("添加成功");
                    //                Response.End();
                    //            }
                    //            if (result == Result.更新失败)
                    //            {
                    //                Response.Write("添加失败");
                    //                Response.End();
                    //            }
                    //        }
                    //    }
                    //}
                }
                SingleHead singleHead = new SingleHead();
                singleHead.SingleHeadId  = Session["singleHeadId"].ToString();
                singleHead.AllBillCount  = counts;
                singleHead.AllRealPrice  = allReal;
                singleHead.AllTotalPrice = allTotal;
                Result head = warehousingBll.updateHead(singleHead);
                if (head == Result.更新成功)
                {
                    Response.Write("添加成功");
                    Response.End();
                }
                else
                {
                    Response.Write("添加失败");
                    Response.End();
                }
            }
            else if (action == "changeDiscount")
            {
                double discount = Convert.ToDouble(Request["discount"]);
                Result result   = warehousingBll.updateDiscount(discount);
                if (result == Result.更新成功)
                {
                    Response.Write("更新成功");
                    Response.End();
                }
                else
                {
                    Response.Write("更新失败");
                    Response.End();
                }
            }
            else if (action == "checkNum")
            {
                int     regId     = user.ReginId.RegionId;
                string  bookNum   = Request["bookNum"].ToString();
                int     billCount = Convert.ToInt32(Request["count"]);
                DataSet dsGoods   = stockBll.SelectByBookNum(bookNum, regId);
                int     j         = dsGoods.Tables[0].Rows.Count;
                if (dsGoods != null && dsGoods.Tables[0].Rows.Count > 0)
                {
                    int count = billCount;
                    int allCount = 0, allCounts = 0;
                    for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++)
                    {
                        allCount  = Convert.ToInt32(dsGoods.Tables[0].Rows[i]["stockNum"]);
                        allCounts = allCounts + allCount;
                    }
                    if (billCount > allCounts)
                    {
                        Response.Write("库存不足");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("库存不足");
                    Response.End();
                }
            }
        }
Exemple #4
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);
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sellId = Session["sellId"].ToString();
            string op     = Request["op"];

            //GetData();
            if (op == "paging")
            {
                GetData();
            }
            if (op == "search")
            {
                //string bookNum = Request["bookNum"];
                string ISBN      = Request["ISBN"];
                string bookNum   = Request["bookNO"];
                int    bookCount = smBll.getBookCount(bookNum);
                if (bookNum == "" || bookNum == null)
                {
                    bookds = bookBll.SelectByIsbn(ISBN);
                    if (bookds != null && bookds.Tables[0].Rows.Count > 0)
                    {
                        //如果有两条及两条以上显示表格
                        if (bookds.Tables[0].Rows.Count > 1)
                        {
                            getbook();
                        }
                        Response.Write(GetData());
                        Response.End();
                    }
                    else
                    {
                        Response.Write("暂无此数据");
                        Response.End();
                    }
                }
                else if (bookCount == 0)
                {
                    Response.Write("销售单据中无此数据");
                    Response.End();
                }
                else
                {
                    Response.Write(GetData());
                    Response.End();
                }
            }
            if (op == "add")
            {
                addSalemon();
            }
            //保存单据
            if (op == "sure")
            {
                int row = smBll.GetCount(sellId);
                if (row > 0)
                {
                    string result = updateSellHead();
                    Session["type"] = "search";
                    if (result == "更新成功")
                    {
                        Response.Write("更新成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("保存失败");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("该单据没有任何数据,无法保存");
                    Response.End();
                }
            }
            string exportOp = Request.QueryString["op"];

            if (exportOp == "export")
            {
                export();
            }
            DataSet   headDs = shBll.Select(sellId);
            DataTable tRows  = headDs.Tables[0];

            if (tRows.Rows.Count > 0 && headDs != null)
            {
                DataRow dr = tRows.Rows[0];
                staticsKinds      = Convert.ToInt32(dr["kinds"].ToString());
                staticsNumber     = Convert.ToInt32(dr["count"].ToString());
                staticsTotalPrice = Convert.ToDouble(dr["totalPrice"].ToString());
                staticsRealPrice  = Convert.ToDouble(dr["realPrice"]);
                staticsTime       = Convert.ToDateTime(dr["makingTime"]);
            }
            //else
            //{
            //    Response.Write("没有这条数据");
            //    Response.End();
            //}
        }