Пример #1
0
        //public JsonResult UpdateWord(int id, string fieldName)
        //{
        //    OperationResult res = new OperationResult(OperationResultType.Error);
        //    switch (fieldName)
        //    {

        //        case "IsDelivered":  //确认发货
        //            {
        //                //更改采购单信息
        //                var pur = _purchaseContract.Purchases.Where(c => c.Id == id).FirstOrDefault();
        //                pur.IsDelivered = true;
        //                pur.DeliverName = _administratorContract.Administrators.Where(c => c.Id == AuthorityHelper.OperatorId).FirstOrDefault().AdminName;
        //                pur.UpdatedTime = DateTime.Now;
        //                PurchaseDto purdt = Mapper.Map<PurchaseDto>(pur);
        //                res = _purchaseContract.Update(purdt);
        //                //将原库存的数量减少
        //                var purchLis = pur.PurchaseItems;
        //                List<InventoryDto> li = new List<InventoryDto>();
        //                foreach (var e in purchLis)
        //                {
        //                    var t = _inventoryContract.Inventorys.Where(c => c.ProductId == e.ProductId).FirstOrDefault();
        //                    t.Quantity = t.Quantity - e.Quantity;
        //                    InventoryDto dto = Mapper.Map<InventoryDto>(t);
        //                    li.Add(dto);
        //                }
        //                res = _inventoryContract.Update(li.ToArray());

        //                break;
        //            }
        //        case "IsReceived":
        //            {
        //                var pur = _purchaseContract.Purchases.Where(c => c.Id == id && c.IsDelivered == true).FirstOrDefault();
        //                if (pur == null)
        //                {
        //                    res = new OperationResult(OperationResultType.Error, "确认收货前需要由出库方确认出库");
        //                    break;
        //                }
        //                pur.IsReceived = true;
        //                pur.UpdatedTime = DateTime.Now;
        //                pur.ReceiverName = _administratorContract.Administrators.Where(c => c.Id == AuthorityHelper.OperatorId).FirstOrDefault().AdminName;
        //                PurchaseDto purdt = Mapper.Map<PurchaseDto>(pur);
        //                res = _purchaseContract.Update(purdt);
        //                break;

        //            }
        //        case "IsStoraged":
        //            {
        //                //修改采购单信息
        //                var pur = _purchaseContract.Purchases.Where(c => c.Id == id && c.IsReceived == true).FirstOrDefault();
        //                if (pur == null)
        //                {
        //                    res = new OperationResult(OperationResultType.Error, "确认入库前必须要先确认收货");
        //                    break;
        //                }
        //                pur.IsStoraged = true;
        //                pur.StoragerName = _administratorContract.Administrators.Where(c => c.Id == AuthorityHelper.OperatorId).FirstOrDefault().AdminName;
        //                pur.UpdatedTime = DateTime.Now;
        //                PurchaseDto purdt = Mapper.Map<PurchaseDto>(pur);
        //                res = _purchaseContract.Update(purdt);
        //                //修改入库的仓库信息
        //                var purch = _purchaseContract.Purchases.Where(c => c.Id == id).FirstOrDefault();
        //                var purchItemList = pur.PurchaseItems;
        //                List<InventoryDto> li = new List<InventoryDto>();
        //                foreach (var e in purchItemList)
        //                {
        //                    li.Add(new InventoryDto()
        //                    {
        //                        StoreId = (int)purch.ReceiverId,//收货店铺
        //                        StorageId = purch.ReceiverStorageId, //收货仓库
        //                        ProductId = e.ProductId,
        //                        Quantity = e.Quantity,
        //                        TagPrice = e.TagPrice,
        //                        RetailPrice = e.RetailPrice,
        //                        WholesalePrice = e.WholesalePrice,
        //                        PurchasePrice = e.PurchasePrice,
        //                        //LocationCode 库位编码
        //                        Description = purch.Notes

        //                    });
        //                }
        //                res = _inventoryContract.Insert(li.ToArray());
        //                break;
        //            }


        //    }
        //    return Json(res);
        //}

        //yxk 2015-9
        #endregion

        /// <summary>
        /// 返回一个不重复单号
        /// </summary>
        /// <returns></returns>
        private string GetOnlyNumb()
        {
            long i = 1;

            foreach (byte b in Guid.NewGuid().ToByteArray())
            {
                i *= ((int)b + 1);
            }
            //return string.Format("{0:x}", i - DateTime.Now.Ticks);
            string _num = string.Format("{0:x}", i - DateTime.Now.Ticks);

            var maxid = CacheAccess.GetOrderblankMaxId(_orderblankContract);

            XKMath36.Math36 math   = new Math36();
            var             newNum = math.To36(maxid);
            var             num    = _num.Substring(0, 6) + newNum.PadLeft(4, '0');

            return(num.ToUpper());
        }