/// <summary>获取责任人名称 /// </summary> /// <param name="personId"></param> /// <returns></returns> protected string GetPersonName(Guid personId) { string personName = "-"; PersonnelInfo info = PersonnelList.FirstOrDefault(w => w.PersonnelId == personId); if (info != null) { personName = info.RealName; } return(personName); }
// Copy the configuration files for remote linked users to the local Calendar_Configuration folder. public void RETRIEVE_REMOTE_USERS() { string[] lines = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/configuration"); DATABASE_NAME = null; DATABASE_EXTERNAL = null; DATABASE_NAME = lines[17]; DATABASE_EXTERNAL = lines[18]; EXTERNAL_DATABASE = DATABASE_EXTERNAL + DATABASE_NAME + ".db"; FileInfo FileFromDirectory = new FileInfo(EXTERNAL_DATABASE); using (var db = new LiteDatabase(EXTERNAL_DATABASE)) { var EmployeeCollection = db.GetCollectionNames(); while (db.Engine.Locker.ThreadState != LockState.Unlocked) { Console.WriteLine("Wainting for file to be unlocked"); } for (int x = 3; x < EmployeeCollection.Count(); x++) { MonolithConsole("Count Add List"); PersonnelList.Add(EmployeeCollection.ElementAtOrDefault(x)); string FULL_NAME = EmployeeCollection.ElementAtOrDefault(x); LiteFileInfo file = db.FileStorage.FindById("configurations/" + FULL_NAME + "/" + FULL_NAME + ".cfg"); if (file != null) { if (lines[8] + "_" + lines[9] != FULL_NAME) { file.SaveAs(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/" + FULL_NAME + ".cfg", true); } } } } }
public Dialog_DataEntry() { InitializeComponent(); this.Paint += Dialog_DataEntry_Paint; this.Opacity = 1f; checkedListBox_DataEntry.SelectedValueChanged += CheckedListBox_DataEntry_SelectedValueChanged; checkedListBox_DataEntry.CheckOnClick = true; comboBox_HourFrom.MouseClick += ComboBox_HourFrom_MouseClick; comboBox_MinuteFrom.MouseClick += ComboBox_MinuteFrom_MouseClick; comboBox_DayFrom.MouseClick += ComboBox_DayFrom_MouseClick; comboBox_HourTo.MouseClick += ComboBox_HourTo_MouseClick; comboBox_MinuteTo.MouseClick += ComboBox_MinuteTo_MouseClick; comboBox_DayTo.MouseClick += ComboBox_DayTo_MouseClick; comboBox_HourFrom.SelectionChangeCommitted += ComboBox_HourFrom_SelectionChangeCommitted; comboBox_MinuteFrom.SelectionChangeCommitted += ComboBox_MinuteFrom_SelectionChangeCommitted; comboBox_DayFrom.SelectionChangeCommitted += ComboBox_DayFrom_SelectionChangeCommitted; comboBox_HourTo.SelectionChangeCommitted += ComboBox_HourTo_SelectionChangeCommitted; comboBox_MinuteTo.SelectionChangeCommitted += ComboBox_MinuteTo_SelectionChangeCommitted; comboBox_DayTo.SelectionChangeCommitted += ComboBox_DayTo_SelectionChangeCommitted; Title_DataEntry.MouseClick += Title_DataEntry_MouseClick; string[] TimeRange = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }; string[] MinuteRange = { "00", "30" }; comboBox_HourTo.Items.AddRange(TimeRange); comboBox_MinuteTo.Items.AddRange(MinuteRange); comboBox_HourFrom.Items.AddRange(TimeRange); comboBox_MinuteFrom.Items.AddRange(MinuteRange); comboBox_DayFrom.Text = "AM"; comboBox_DayTo.Text = "AM"; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/configuration")) { string INTERNAL_CONFIG = AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/configuration"; string[] lines = File.ReadAllLines(INTERNAL_CONFIG); string FirstName = lines[8]; string LastName = lines[9]; EXTERNAL_DATABASE = lines[18] + lines[17] + ".db"; using (var db = new LiteDatabase(EXTERNAL_DATABASE)) { var EmployeeCollection = db.GetCollectionNames(); PersonnelList.Clear(); for (int x = 3; x < EmployeeCollection.Count(); x++) { PersonnelList.Add(EmployeeCollection.ElementAtOrDefault(x)); } checkedListBox_DataEntry.Refresh(); for (int x = 0; x < PersonnelList.Count; x++) { checkedListBox_DataEntry.Items.Add(PersonnelList[x].Replace("_", " ")); } } } comboBox_HourFrom.SelectedItem = "9"; comboBox_MinuteFrom.SelectedItem = "00"; comboBox_DayFrom.SelectedItem = "AM"; comboBox_HourTo.SelectedItem = "5"; comboBox_MinuteTo.SelectedItem = "00"; comboBox_DayTo.SelectedItem = "PM"; }
// 采购中 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 + ");"); } }
public void MainLoad() { string[] lines = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/configuration"); /* * if (Loading remoteUsers Fails) * { * Pull information from local database * } */ // Check to see if the local database is the most recent copy of the remote database. If not, copy it to the local database. FileInfo localDB = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "database_internal.db"); FileInfo remoteDB = new FileInfo(lines[18] + lines[17] + ".db"); if (File.Equals(localDB.LastWriteTime, remoteDB.LastWriteTime) == false) { if (File.Exists(lines[18] + lines[17] + ".db") == true) { File.Copy(lines[18] + lines[17] + ".db", AppDomain.CurrentDomain.BaseDirectory + "database_internal.db", true); } else { //Dialog_DatabaseNotConnected notConnected = new Dialog_DatabaseNotConnected(); //notConnected.Show(); MessageBox.Show("The remote database " + (lines[18] + lines[17] + ".db") + " is offline. An empty database will be recreated. Please check database connection."); } } // Set default user. SetTheme(); LoadImage(); display_Panel1.pib_1.panel_PersonnelImage.BackgroundImage = PersonnelImage; display_Panel1.pib_1.label_PImageName.Text = lines[8] + " " + lines[9]; display_Panel1.Panel_DayControlHolder.Controls.Add(display_Panel1.day_Control_1); // Load Settings Menu dialog_internalsettings.label_SelectDBDatabase.Text = "CURRENT DATABASE: " + lines[18] + lines[17] + ".db"; dialog_internalsettings.textBoxSettings_FirstName.Text = lines[8]; dialog_internalsettings.textBoxSettings_LastName.Text = lines[9]; dialog_internalsettings.maskedTextBox_Email.Text = lines[10]; dialog_internalsettings.maskedTextBox_Phone.Text = lines[11]; dialog_internalsettings.textBoxSettings_JobTitle.Text = lines[12]; dialog_internalsettings.textBoxSettings_Host.Text = lines[20]; dialog_internalsettings.textBoxSettings_UserName.Text = lines[21]; dialog_internalsettings.textBoxSettings_Password.Text = lines[22]; dialog_internalsettings.textBoxSettings_Port.Text = lines[23]; dialog_internalsettings.textBoxSettings_Folder.Text = lines[25]; if (lines[24] == "False") { dialog_internalsettings.checkBox_Passive.CheckState = CheckState.Unchecked; } else if (lines[24] == "True") { dialog_internalsettings.checkBox_Passive.CheckState = CheckState.Checked; } string EXTERNAL_DATABASE = lines[18] + lines[17] + ".db"; string DATABASE_EXTERNAL = EXTERNAL_DATABASE; using (var db = new LiteDatabase(EXTERNAL_DATABASE)) { var EmployeeCollection = db.GetCollectionNames(); var NumberCollect = db.CollectionExists("Copeland Lanier"); Console.WriteLine("" + NumberCollect); for (int x = 3; x < EmployeeCollection.Count(); x++) { PersonnelList.Add(EmployeeCollection.ElementAtOrDefault(x)); Console.WriteLine("USING: " + EmployeeCollection.Count()); } } for (int x = 0; x < PersonnelList.Count(); x++) { dialog_internalsettings.listBox_SettingUsers.Items.Add(PersonnelList[x]); MonolithConsole(PersonnelList[x]); } dialog_internalsettings.label_InternalSettings_Registered.Text = lines[8] + " " + lines[9]; dialog_internalsettings.panelSettings_ImageBox.BackgroundImage = resizeImage(PersonnelImage, new Size(dialog_internalsettings.panelSettings_ImageBox.Width, dialog_internalsettings.panelSettings_ImageBox.Height)); if (lines[18] != null) { DATABASE_EXTERNAL = lines[18]; // File watcher ON REMOTE DATABASE. fileSystemWatcher_RemoteDB.Path = DATABASE_EXTERNAL; MonolithConsole("Remote Database Path: " + DATABASE_EXTERNAL); } // Add in remote users. ADDRemoteUsers(); // Set Internal Settings Menu dialog_internalsettings.ApplyThemeColor(lines[13]); // Add file watchers fileSystemWatcher_WebUpload.Path = AppDomain.CurrentDomain.BaseDirectory + "Web_Upload"; fileSystemWatcher_Config.Path = AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration"; fileSystemWatcher_Config.EnableRaisingEvents = true; fileSystemWatcher_RemoteDB.EnableRaisingEvents = true; fileSystemWatcher_WebUpload.EnableRaisingEvents = true; backgroundWorker_Listener.WorkerReportsProgress = true; backgroundWorker_Listener.WorkerSupportsCancellation = true; }
/// <summary>绑定数据源 /// </summary> protected void GridGoodsStock_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { IList <StockTurnOverInfo> stockTurnOverList = new List <StockTurnOverInfo>(); if (!WarehouseId.Equals(Guid.Empty)) { //选择了责任人,则获取当前责任人负责的商品ID集合 var goodsIds = new List <Guid>(); if (PersonnelId != Guid.Empty || CompanyId != Guid.Empty) { goodsIds = _purchaseSet.GetGoodsIdByPersonnelId(PersonnelId, CompanyId).ToList(); } //根据条件获取商品信息 List <GoodsPerformance> goodsList = _goodsCenterSao.GetGoodsPerformanceList(GoodsClassId, goodsIds, GoodsNameOrCode, CB_IsPerformance.Checked); var tempGoodsIds = new List <Guid>(); //var isNeedStock = true; switch (State) { case 0: //全部 tempGoodsIds = goodsList.Select(ent => ent.GoodsId).ToList(); break; case 1: //下架缺货有库存 //备注: PurchaseState 0下架, 1上架 tempGoodsIds.AddRange(from item in goodsList where item.IsScarcity || item.PurchaseState == 0 select item.GoodsId); //isNeedStock = true; break; case 2: //无销售商品 tempGoodsIds.AddRange(from item in goodsList where !_salesDic.ContainsKey(item.GoodsId) select item.GoodsId); var newGoodsList = tempGoodsIds.Select(goodsId => goodsList.FirstOrDefault(ent => ent.GoodsId == goodsId)).ToList(); goodsList.Clear(); goodsList.AddRange(newGoodsList); break; } //获取商品库存信息 var goodsStockList = WMSSao.StockSearchByGoodsIds(tempGoodsIds, WarehouseId, FilialeId) ?? new Dictionary <Guid, int>(); //获取所有的商品采购设置 var allGoodsPurchaseSet = _purchaseSet.GetAllPurchaseSet(WarehouseId); var companyIdList = allGoodsPurchaseSet.Select(p => p.CompanyId).Distinct().ToList(); //获取商品的最后一次进货价信息 var goodsPurchaseLastPriceInfoList = _storageRecordDao.GetGoodsPurchaseLastPriceInfoByWarehouseId(WarehouseId); goodsPurchaseLastPriceInfoList = goodsPurchaseLastPriceInfoList.Where(p => tempGoodsIds.Contains(p.GoodsId) && companyIdList.Contains(p.ThirdCompanyId)).ToList(); foreach (var goodsInfo in goodsList) { // ReSharper disable once UseObjectOrCollectionInitializer var info = new StockTurnOverInfo(); info.GoodsID = goodsInfo.GoodsId; info.GoodsName = goodsInfo.GoodsName; info.GoodsCode = goodsInfo.GoodsCode; info.IsStatisticalPerformance = goodsInfo.IsStatisticalPerformance; info.IsStatisticalPerformanceStr = goodsInfo.IsStatisticalPerformance ? "√" : string.Empty; info.IsScarcity = goodsInfo.IsScarcity; info.IsScarcityStr = goodsInfo.IsScarcity ? "√" : string.Empty; info.State = goodsInfo.PurchaseState == 0; info.IsStateStr = goodsInfo.PurchaseState == 0 ? "√" : string.Empty; //库存信息获取 var stockQuantity = goodsStockList.ContainsKey(goodsInfo.GoodsId) ? goodsStockList[goodsInfo.GoodsId] : 0; if (stockQuantity <= 0) { continue; } info.StockNums = stockQuantity; if (!_salesDic.ContainsKey(goodsInfo.GoodsId)) { info.StockNumSort = stockQuantity; } //责任人供应商信息获取 var tempGoodsPurchaseSetInfo = allGoodsPurchaseSet.FirstOrDefault(ent => ent.GoodsId == goodsInfo.GoodsId); //根据商品id获取供应商 var companyId = tempGoodsPurchaseSetInfo != null ? tempGoodsPurchaseSetInfo.CompanyId : Guid.Empty; decimal unitPrice = 0; GoodsPurchaseLastPriceInfo goodsPurchaseLastPriceInfo = null; if (goodsPurchaseLastPriceInfoList.Count > 0) { goodsPurchaseLastPriceInfo = goodsPurchaseLastPriceInfoList.FirstOrDefault(p => p.GoodsId.Equals(goodsInfo.GoodsId) && p.ThirdCompanyId.Equals(companyId)); unitPrice = goodsPurchaseLastPriceInfo != null ? goodsPurchaseLastPriceInfo.UnitPrice : 0; } info.RecentInPrice = unitPrice; info.RecentCDate = (goodsPurchaseLastPriceInfo != null ? goodsPurchaseLastPriceInfo.LastPriceDate : DateTime.MinValue).ToString("yyyy-MM-dd"); if (tempGoodsPurchaseSetInfo != null) { info.PersonResponsible = tempGoodsPurchaseSetInfo.PersonResponsible; var firstOrDefault = PersonnelList.FirstOrDefault(ent => ent.PersonnelId == tempGoodsPurchaseSetInfo.PersonResponsible); if (firstOrDefault != null) { info.PersonResponsibleName = firstOrDefault.RealName; } info.CompanyId = tempGoodsPurchaseSetInfo.CompanyId; info.CompanyName = tempGoodsPurchaseSetInfo.CompanyName; } //销售数量 if (_salesDic.ContainsKey(goodsInfo.GoodsId)) { info.SaleNums = _salesDic[goodsInfo.GoodsId]; info.SaleNumSort = 1; info.StockNumSort = 0; } #region [计算商品库存周转情况(天数)] if (info.State && info.StockNums == 0) { info.TurnOverDays = 0; info.TurnOverStr = "下架"; } else if (info.State && info.StockNums != 0) { info.TurnOverDays = 0; info.TurnOverStr = "下架有库存"; } else if (info.IsScarcity && info.StockNums == 0) { info.TurnOverDays = 0; info.TurnOverStr = "缺货"; } else if (info.IsScarcity && info.StockNums != 0) { info.TurnOverDays = 0; info.TurnOverStr = "缺货有库存"; } else if (info.StockNums == 0) { info.TurnOverDays = 0; info.TurnOverStr = "0天"; } else if (info.SaleNums > 0) { var tempTurnOverDays = info.StockNums * 30 / info.SaleNums; info.TurnOverDays = tempTurnOverDays; info.TurnOverStr = tempTurnOverDays + "天"; } else { info.TurnOverDays = 0; info.TurnOverStr = "无销售"; } #endregion #region [计算商品报备周转天数] if (_weightedAverageSaleDic.ContainsKey(info.GoodsID)) { var weightedAverageSale = _weightedAverageSaleDic[info.GoodsID]; if (_weightedAverageSaleDic[info.GoodsID] != 0) { info.TurnOverByFiling = info.StockNums * 30 / weightedAverageSale + "天"; } } #endregion stockTurnOverList.Add(info); } } var pageIndex = GridGoodsStock.CurrentPageIndex; var pageSize = GridGoodsStock.PageSize; stockTurnOverList = stockTurnOverList.OrderBy(ent => ent.SaleNumSort).ThenByDescending(ent => ent.StockNumSort).ThenByDescending(ent => ent.TurnOverDays).ToList(); GridGoodsStock.DataSource = stockTurnOverList.Skip(pageIndex * pageSize).Take(pageSize).ToList(); GridGoodsStock.VirtualItemCount = stockTurnOverList.Count; }