Ejemplo n.º 1
0
        //出库
        static public bool OutWarehouse(int indetailId, int outNum, string userNum, out string msg)
        {
            List <string> list     = new List <string>();
            Indetail      indetail = IndetailDAL.QueryById(indetailId, out msg);

            if (indetail == null)
            {
                msg = "单品记录查询失败";
                return(false);
            }
            if (indetail.quantity < outNum)
            {
                msg = "数量不足";
                return(false);
            }
            indetail.quantity -= outNum;
            int   stockId = indetail.stockID;
            Stock stock   = StockDAL.QueryById(stockId, out msg);

            if (stock == null)
            {
                msg = "库存查询失败";
                return(false);
            }
            stock.quantity -= outNum;
            stock.money     = stock.money - outNum * indetail.price;
            if (stock.money < 0)
            {
                msg = "金额出错";
                return(false);
            }
            string  date    = DateTime.Now.ToString("yyyy-MM-dd");
            Outflow outflow = new Outflow(stock.cagNum, stock.storeID, date, userNum, outNum, indetail.price, indetail.batchNum, indetail.batchNum2, indetail.suppliers, "正常出库");

            if (indetail.quantity == 0)
            {
                list.Add(string.Format(" delete from Indetail where id ={0}", indetailId));
                list.Add(string.Format("update Stock set cagNum = '{0}', storeID = {1}, quantity = {2}, money = {3} where id = {4} ", stock.cagNum, stock.storeID, stock.quantity, stock.money, stock.id));
                list.Add(string.Format("insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values('{0}',{1},'{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}')", outflow.cagNum, outflow.storeID, outflow.date, outflow.userNum, outflow.quantity, outflow.price, outflow.batchNum, outflow.batchNum2, outflow.suppliers, outflow.state));
            }
            else
            {
                list.Add(string.Format("update Indetail set stockID = {0},batchNum = '{1}',date = '{2}',quantity = {3},price = {4},batchNum2 = '{5}',suppliers = '{6}',note = '{7}'  where id = {8}", indetail.stockID, indetail.batchNum, indetail.date, indetail.quantity, indetail.price, indetail.batchNum2, indetail.suppliers, indetail.note, indetail.id));
                list.Add(string.Format("update Stock set cagNum = '{0}', storeID = {1}, quantity = {2}, money = {3} where id = {4} ", stock.cagNum, stock.storeID, stock.quantity, stock.money, stock.id));
                list.Add(string.Format("insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values('{0}',{1},'{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}')", outflow.cagNum, outflow.storeID, outflow.date, outflow.userNum, outflow.quantity, outflow.price, outflow.batchNum, outflow.batchNum2, outflow.suppliers, outflow.state));
            }
            bool bol = SQL.ExecuteTransaction(list, out msg);

            if (bol)
            {
                msg = "出库成功";
            }
            else
            {
                return(false);
            }
            return(true);
        }
        static public List <Dictionary <string, string> > Query(int storeID, ref int totalPage, ref int currentPage, out string msg)
        {
            List <Stock> stockList = StockDAL.QueryByStoreId(storeID, out msg);

            if (stockList == null || stockList.Count == 0)
            {
                totalPage   = 0;
                currentPage = -1;
                msg         = "暂无库存记录";
                return(null);
            }
            List <Dictionary <string, string> > indetails = new List <Dictionary <string, string> >();

            for (int i = 0; i < stockList.Count; i++)
            {
                List <Dictionary <string, string> > temp = IndetailDAL.QueryByStockID(stockList[i].id, out msg);
                if (temp != null && temp.Count != 0)
                {
                    indetails.AddRange(temp);
                }
            }
            string nowTime = DateTime.Now.ToString("yyyy-MM-dd");

            for (int i = 0; i < indetails.Count; i++)
            {
                if (Convert.ToDateTime(indetails[i]["batchNum"]) >= Convert.ToDateTime(nowTime))
                {
                    indetails.Remove(indetails[i]);
                    i--;
                }
            }
            if (indetails == null || indetails.Count == 0)
            {
                totalPage   = 0;
                currentPage = -1;
                msg         = "库房暂无过期药品";
                return(null);
            }
            List <Dictionary <string, string> > list = SortDate(indetails);

            totalPage = (int)System.Math.Floor((decimal)(list.Count / 10));
            if (list.Count != 0 && list.Count % 10 == 0)
            {
                --totalPage;
            }
            if (currentPage < totalPage)
            {
                ++currentPage;
            }
            try
            {
                return(list.GetRange(currentPage * 10, 10));
            }
            catch
            {
                return(list.GetRange(currentPage * 10, list.Count - currentPage * 10));
            }
        }
Ejemplo n.º 3
0
        //单品明细数据进行批号排序,返回list  4/7
        static public string QueryIndetail(int stockID, out string msg, ref int totalPage, ref int currentPage)
        {
            List <Dictionary <string, string> > list = IndetailDAL.QueryByStockID(stockID, out msg);
            List <Alert> alerts = AlertDAL.QueryAll(out msg);

            if (list == null)
            {
                msg         = "不能出库过期产品";
                totalPage   = 0;
                currentPage = -1;
                return(null);
            }
            //排序+过滤过期药品
            List <Dictionary <string, string> > sortList = SortDate(list);

            if (sortList == null)
            {
                msg         = "暂无未过期的单品明细";
                totalPage   = 0;
                currentPage = -1;
                return(null);
            }
            if (alerts != null && alerts.Count != 0)
            {
                alerts = alerts.OrderBy(o => o.days).ToList();//升序
                for (int i = 0; i < sortList.Count; i++)
                {
                    int nowColor = AlertManage.GetInterval(sortList[i]["batchNum"], alerts);
                    if (nowColor != -1)
                    {
                        sortList[i].Add("color", alerts[nowColor].color.ToString());
                    }
                    else
                    {
                        sortList[i].Add("color", "");
                    }
                }
            }

            totalPage = (int)System.Math.Floor((decimal)(sortList.Count / 10));
            if (list.Count != 0 && list.Count % 10 == 0)
            {
                --totalPage;
            }
            if (currentPage < totalPage)
            {
                ++currentPage;
            }
            try
            {
                return(JsonConvert.SerializeObject(sortList.GetRange(currentPage * 10, 10)));
            }
            catch
            {
                return(JsonConvert.SerializeObject(sortList.GetRange(currentPage * 10, sortList.Count - currentPage * 10)));
            }
        }