Ejemplo n.º 1
0
        /// <summary>
        /// 添加销退单头
        /// </summary>
        /// <param name="sm"></param>
        /// <returns></returns>
        public int Insert(SellOffMonomer sm)
        {
            string cmdText = "insert into T_SellOffMonomer(sellOffMonomerId,sellOffHead,bookNum,isbn,price,count,totalPrice,realPrice,dateTime,realDiscount) values(@sellOffMonomerId,@sellOffHeadID,@bookNum,@isbn,@price,@count,@totalPrice,@realPrice,@dateTime,@realDiscount)";

            string[] param  = { "@sellOffMonomerId", "@sellOffHeadID", "@bookNum", "@isbn", "@price", "@count", "@totalPrice", "@realPrice", "@dateTime", "@realDiscount" };
            object[] values = { sm.SellOffMonomerId, sm.SellOffHeadId, sm.BookNum, sm.ISBN1, sm.Price, sm.Count, sm.TotalPrice, sm.RealPrice, sm.Time, sm.Discount };
            int      row    = db.ExecuteNoneQuery(cmdText, param, values);

            return(row);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sm"></param>
        /// <returns></returns>
        public Result Insert(SellOffMonomer sm)
        {
            int row = dao.Insert(sm);

            if (row > 0)
            {
                return(Result.添加成功);
            }
            else
            {
                return(Result.添加失败);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加销退单体
        /// </summary>
        public void addSalemon()
        {
            string sellId = Session["sellId"].ToString();
            string isbn   = Request["ISBN"];//ISBN

            if (isbn == "" || isbn == null)
            {
                Response.Write("请先输入ISBN号");
                Response.End();
            }
            else
            {
                string bookNo = Request["bookNum"];
                if (bookNo == null || bookNo == "")
                {
                    bookNo = bookds.Tables[0].Rows[0]["bookNum"].ToString();//书号
                }
                int bookCount = smBll.getBookCount(bookNo);
                if (bookCount > 0)
                {
                    BookBasicData book = new BookBasicData();
                    book = bookBll.SelectById(bookNo);
                    double unitPrice = book.Price; //定价
                                                   //double discount = double.Parse(Request["discount"]);//实际折扣

                    //获取默认折扣
                    DataSet stds = smBll.getSaleTask(sellId);
                    string  stId = Session["saleId"].ToString();
                    DataSet seds = smBll.getDisCount(stId, bookNo);
                    string  dc   = null;
                    if (seds.Tables[0].Rows.Count > 0)
                    {
                        dc = seds.Tables[0].Rows[0]["realDiscount"].ToString();
                    }
                    double discount = 0;//默认折扣
                    if (dc != null)
                    {
                        discount = double.Parse(dc);
                    }

                    int    count      = int.Parse(Request["count"]);  //数量
                    double totalPrice = unitPrice * count;            //码洋
                    double d          = totalPrice * (discount / 100);
                    double realPrice  = Math.Round(d, 2);             //实洋
                    string headId     = Session["sellId"].ToString(); //单头Id
                    int    moNum      = smBll.GetCount(headId);
                    int    smId;
                    smId = moNum + 1;//单体Id
                    DateTime time = DateTime.Now;

                    //获取默认折扣
                    //DataSet stds = smBll.getSaleTask(sellId);
                    //string stId = stds.Tables[0].Rows[0]["saleTaskId"].ToString();//销售任务Id
                    DataSet        countds = smBll.selctByBookNum(bookNo, stId);
                    int            num     = 0;
                    SellOffMonomer sm      = new SellOffMonomer();
                    sm.SellOffMonomerId = smId.ToString();
                    sm.SellOffHeadId    = headId;
                    sm.BookNum          = long.Parse(bookNo);
                    sm.ISBN1            = isbn;
                    sm.Count            = count;
                    sm.TotalPrice       = totalPrice;
                    sm.RealPrice        = realPrice;
                    sm.Price            = unitPrice;
                    sm.Time             = time;
                    sm.Discount         = discount;
                    //DataSet smcountds = smBll.selecctSm(bookNo, sellId);
                    int allcount = smBll.selecctSm(bookNo, sellId);
                    //string state = null;
                    if (countds != null)//获取销售中的相应的数量
                    {
                        for (int i = 0; i < countds.Tables[0].Rows.Count; i++)
                        {
                            num = num + int.Parse(countds.Tables[0].Rows[i]["number"].ToString());
                        }
                    }
                    //if (smcountds != null)//获取销退单体中已有的数量
                    //{
                    //    for (int i = 0; i < smcountds.Tables[0].Rows.Count; i++)
                    //    {
                    //        allcount = allcount + int.Parse(smcountds.Tables[0].Rows[i]["count"].ToString());
                    //    }
                    //}
                    if ((count + allcount) > num)//判断销退数量是否大于销售数量
                    {
                        Response.Write("销退数量大于销售数量");
                        Response.End();
                    }
                    else
                    {
                        Result row = smBll.Insert(sm);
                        if (row == Result.添加成功)//先添加销退体
                        {
                            string update = updateSellHead();
                            if (update == "更新成功")//后更新销退单头信息
                            {
                                string stock = insertStock();
                                if (stock == "更新成功")//最后写入库存
                                {
                                    Response.Write("添加成功");
                                    Response.End();
                                }
                                else
                                {
                                    Response.Write(stock);
                                    Response.End();
                                }
                            }
                            else
                            {
                                Response.Write("更新单头信息失败");
                                Response.End();
                            }
                        }
                        else
                        {
                            Response.Write("添加失败");
                            Response.End();
                        }
                    }
                }
                else
                {
                    Response.Write("销售单中暂无此数据");
                    Response.End();
                }
            }
        }