Exemplo n.º 1
0
        protected void RCB_Company_OnItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            var combo = (RadComboBox)sender;

            combo.Items.Clear();
            if (!string.IsNullOrEmpty(e.Text))
            {
                string key = e.Text;
                IList <CompanyCussentInfo> companyList = CompanyCussentList.Where(p => p.CompanyName.Contains(key.Trim())).ToList();
                if (e.NumberOfItems >= companyList.Count)
                {
                    e.EndOfItems = true;
                }
                else
                {
                    foreach (CompanyCussentInfo i in companyList)
                    {
                        var item = new RadComboBoxItem {
                            Text = i.CompanyName, Value = i.CompanyId.ToString()
                        };
                        combo.Items.Add(item);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>获取供应商名称
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns></returns>
        protected string GetCompanyName(Guid companyId)
        {
            string             companyName = "-";
            CompanyCussentInfo info        = CompanyCussentList.FirstOrDefault(w => w.CompanyId == companyId);

            if (info != null)
            {
                companyName = info.CompanyName;
            }
            return(companyName);
        }
Exemplo n.º 3
0
        // 采购中
        protected void IbnPurchasing_Click(object sender, EventArgs eventArgs)
        {
            bool isHave      = false;
            var  codeManager = new CodeManager();

            foreach (GridDataItem dataItem in RG_DebitNote.Items)
            {
                var purchasingId      = new Guid(dataItem.GetDataKeyValue("PurchasingId").ToString());
                var personResponsible = new Guid(dataItem.GetDataKeyValue("PersonResponsible").ToString());
                var cbCheck           = (CheckBox)dataItem.FindControl("CB_Check");
                if (cbCheck.Checked)
                {
                    using (var ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        isHave = true;
                        _debitNoteDao.UpdateDebitNoteStateByPurchasingId(purchasingId, (int)DebitNoteState.Purchasing);
                        //生成采购单
                        DebitNoteInfo debitNoteInfo = _debitNoteDao.GetDebitNoteInfo(purchasingId) ?? new DebitNoteInfo();
                        IList <DebitNoteDetailInfo> debitNoteDetailList = _debitNoteDao.GetDebitNoteDetailList(purchasingId);
                        CompanyCussentInfo          companyCussentInfo  = CompanyCussentList.FirstOrDefault(w => w.CompanyId == debitNoteInfo.CompanyId);
                        //var warehouseInfo = WarehouseManager.Get(debitNoteInfo.WarehouseId);
                        PersonnelInfo  personnelInfo     = PersonnelList.FirstOrDefault(w => w.PersonnelId == debitNoteInfo.PersonResponsible) ?? new PersonnelInfo(null);
                        PurchasingInfo oldPurchasingInfo = _purchasing.GetPurchasingById(purchasingId);
                        var            realName          = CurrentSession.Personnel.Get().RealName;
                        var            filialeId         = string.IsNullOrWhiteSpace(debitNoteInfo.PurchasingNo) || debitNoteInfo.PurchasingNo == "-"?FilialeManager.GetHeadList().First(ent => ent.Name.Contains("可得")).ID
                            : _purchasing.GetPurchasingList(debitNoteInfo.PurchasingNo).FilialeID;
                        var pInfo = new PurchasingInfo
                        {
                            PurchasingID    = Guid.NewGuid(),
                            PurchasingNo    = codeManager.GetCode(CodeType.PH),
                            CompanyID       = debitNoteInfo.CompanyId,
                            CompanyName     = companyCussentInfo == null ? "" : companyCussentInfo.CompanyName,
                            FilialeID       = filialeId,
                            WarehouseID     = debitNoteInfo.WarehouseId,
                            PurchasingState = (int)PurchasingState.Purchasing,
                            PurchasingType  = (int)PurchasingType.Custom,
                            StartTime       = DateTime.Now,
                            EndTime         = DateTime.MaxValue,
                            //Description = "[采购类别:{0}赠品借记单][对应采购单号" + debitNoteInfo.PurchasingNo + "]" + CurrentSession.Personnel.Get().RealName,
                            Description         = string.Format("[采购类别:{0},赠品借记单对应采购单号{1};采购人:{2}]", EnumAttribute.GetKeyName(PurchasingType.Custom), debitNoteInfo.PurchasingNo, realName),
                            PmId                = personnelInfo.PersonnelId,
                            PmName              = personnelInfo.RealName,
                            ArrivalTime         = oldPurchasingInfo.ArrivalTime,
                            PersonResponsible   = personResponsible,
                            PurchasingFilialeId = filialeId
                        };
                        IList <PurchasingDetailInfo> purchasingDetailList = new List <PurchasingDetailInfo>();
                        if (debitNoteDetailList.Count > 0)
                        {
                            List <Guid> goodsIdOrRealGoodsIdList  = debitNoteDetailList.Select(w => w.GoodsId).Distinct().ToList();
                            Dictionary <Guid, GoodsInfo> dicGoods = _goodsCenterSao.GetGoodsBaseListByGoodsIdOrRealGoodsIdList(goodsIdOrRealGoodsIdList);
                            if (dicGoods != null && dicGoods.Count > 0)
                            {
                                foreach (var debitNoteDetailInfo in debitNoteDetailList)
                                {
                                    bool hasKey = dicGoods.ContainsKey(debitNoteDetailInfo.GoodsId);
                                    if (hasKey)
                                    {
                                        GoodsInfo goodsBaseInfo = dicGoods.FirstOrDefault(w => w.Key == debitNoteDetailInfo.GoodsId).Value;
                                        // 获取商品的60、30、11天销量
                                        var purchasingDetailInfo = _purchasingDetail.GetChildGoodsSale(debitNoteDetailInfo.GoodsId, debitNoteInfo.WarehouseId, DateTime.Now, pInfo.PurchasingFilialeId) ?? new PurchasingDetailInfo();
                                        var durchasingDetailInfo = new PurchasingDetailInfo
                                        {
                                            PurchasingID        = pInfo.PurchasingID,
                                            PurchasingGoodsID   = Guid.NewGuid(),
                                            GoodsID             = debitNoteDetailInfo.GoodsId,
                                            GoodsName           = debitNoteDetailInfo.GoodsName,
                                            GoodsCode           = goodsBaseInfo.GoodsCode,
                                            Specification       = debitNoteDetailInfo.Specification,
                                            CompanyID           = pInfo.CompanyID,
                                            Price               = debitNoteDetailInfo.Price,
                                            PlanQuantity        = debitNoteDetailInfo.GivingCount,
                                            RealityQuantity     = 0,
                                            State               = 0,
                                            Description         = "",
                                            Units               = goodsBaseInfo.Units,
                                            PurchasingGoodsType = (int)PurchasingGoodsType.Gift,
                                            SixtyDaySales       = purchasingDetailInfo.SixtyDaySales,
                                            ThirtyDaySales      = purchasingDetailInfo.ThirtyDaySales,
                                            ElevenDaySales      = purchasingDetailInfo.ElevenDaySales == 0 ? 0 : purchasingDetailInfo.ElevenDaySales, // 11 //日均销量(11天)
                                            CPrice              = debitNoteDetailInfo.Price
                                        };
                                        purchasingDetailList.Add(durchasingDetailInfo);
                                    }
                                }
                            }
                        }
                        if (purchasingDetailList.Count > 0)
                        {
                            _debitNoteDao.UpdateDebitNoteNewPurchasingIdByPurchasingId(purchasingId, pInfo.PurchasingID);
                            _purchasing.PurchasingInsert(pInfo);
                            _purchasing.PurchasingUpdateIsOut(pInfo.PurchasingID);
                            //报备管理生成采购单操作记录添加
                            WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, pInfo.PurchasingID, pInfo.PurchasingNo,
                                                       OperationPoint.ReportManage.DebitToAddPurchasingList.GetBusinessInfo(), string.Empty);
                            var purchasingDetailManager = new PurchasingDetailManager(_purchasingDetail, _purchasing);
                            purchasingDetailManager.Save(purchasingDetailList);
                        }
                        ts.Complete();
                    }
                }
            }
            if (isHave == false)
            {
                RAM.Alert("未勾选借记单!");
            }
            else
            {
                RAM.ResponseScripts.Add("setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");");
            }
        }