// 物料收发明细 private SortedDictionary <int, ArrayList> getStorageManagerMaterielCountData() { SortedDictionary <int, ArrayList> sortedDictionaryList = new SortedDictionary <int, ArrayList>(); SortedDictionary <int, StorageStockDetailTable> list = new SortedDictionary <int, StorageStockDetailTable>(); list = StorageStockDetail.getInctance().getAllStorageStockDetailInfo(m_countStartDate, m_countEndDate); m_dataGridRecordCount = list.Count; for (int index = 0; index < list.Count; index++) { StorageStockDetailTable record = new StorageStockDetailTable(); record = (StorageStockDetailTable)list[index]; ArrayList temp = new ArrayList(); temp.Add(index + 1); temp.Add(record.materielID); temp.Add(record.materielName); temp.Add(record.model); temp.Add(record.tradingDate); temp.Add(record.thingsType); temp.Add(record.value); temp.Add(record.price); temp.Add(record.storageValue); temp.Add(record.storagePrice); sortedDictionaryList.Add(index, temp); } return(sortedDictionaryList); }
private void dateTimePickerHistoryDate_CloseUp(object sender, EventArgs e) { string lastDate = this.dateTimePickerHistoryDate.Value.ToString("yyyy-MM-dd"); m_materielListHistoryInfo.Clear(); m_materielListHistoryInfo = StorageStockDetail.getInctance().getMaterielStorageStockDetailHistoryInfo(lastDate); updateDataGridView(Materiel.getInctance().getAllMaterielInfo()); }
private void toolStripButtonRefreshHS_Click(object sender, EventArgs e) { if (m_orderType == CountType.PurchaseMateriel) { PurchaseInOrderDetails.getInctance().refreshRecord(); } else if (m_orderType == CountType.PurchasePeople) { PurchaseInOrder.getInctance().refreshRecord(); } else if (m_orderType == CountType.PurchaseSupplier) { PurchaseInOrder.getInctance().refreshRecord(); } else if (m_orderType == CountType.PurchaseHistoryPrice) { PurchaseInOrderDetails.getInctance().refreshRecord(); } else if (m_orderType == CountType.SaleMateriel) { SaleOutOrderDetails.getInctance().refreshRecord(); } else if (m_orderType == CountType.SalePeople) { SaleOutOrder.getInctance().refreshRecord(); } else if (m_orderType == CountType.SaleCustomer) { SaleOutOrder.getInctance().refreshRecord(); } else if (m_orderType == CountType.SaleHistoryPrice) { SaleOutOrderDetails.getInctance().refreshRecord(); } else if (m_orderType == CountType.StorageMaterielOut) { MaterielOutOrderDetails.getInctance().refreshRecord(); } else if (m_orderType == CountType.StorageManagerMaterielCount) { StorageStockDetail.getInctance().refreshRecord(); } else if (m_orderType == CountType.MaterielInOutCount) { StorageStockDetail.getInctance().refreshRecord(); } else if (m_orderType == CountType.StorageManagerProduceIn) { MaterielInOrderDetails.getInctance().refreshRecord(); } updateDataGridView(); }
// 物料出入库核算 private SortedDictionary <int, ArrayList> getMaterieInOutlCountData() { double inCount = 0, outCount = 0; SortedDictionary <int, ArrayList> sortedDictionaryList = new SortedDictionary <int, ArrayList>(); SortedDictionary <int, StorageStockDetailTable> list = new SortedDictionary <int, StorageStockDetailTable>(); list = StorageStockDetail.getInctance().getAllStorageStockDetailInfo(m_countStartDate, m_countEndDate); m_dataGridRecordCount = list.Count; for (int index = 0; index < list.Count; index++) { StorageStockDetailTable record = new StorageStockDetailTable(); record = (StorageStockDetailTable)list[index]; ArrayList temp = new ArrayList(); temp.Add(index + 1); temp.Add(record.materielID); temp.Add(record.materielName); temp.Add(record.model); temp.Add(record.tradingDate); temp.Add(record.thingsType); temp.Add(record.price); temp.Add(record.value); temp.Add(record.value * record.price); if (record.thingsType.IndexOf("入库") > 0) { inCount += record.sumMoney; } else { outCount += record.sumMoney; } sortedDictionaryList.Add(index, temp); } string countInfoToStatusLable = "当前会计期间:累计入库金额 "; inCount = (double)(Math.Round(inCount * 10000)) / 10000; countInfoToStatusLable += Convert.ToString(inCount); countInfoToStatusLable += ", 累计出库金额 "; outCount = (double)(Math.Round(outCount * 10000)) / 10000; countInfoToStatusLable += Convert.ToString(outCount); this.labelMaterieInOutlCountInfo.Text = countInfoToStatusLable; return(sortedDictionaryList); }
private void FormMaterielStorageAmountHistoryInfo_Load(object sender, EventArgs e) { // 树控件初始化 refreshTreeView(); // DataGridView控件初始化 m_dataGridViewExtend.addDataGridViewColumn("ID", 30); m_dataGridViewExtend.addDataGridViewColumn("物料名称", 200); m_dataGridViewExtend.addDataGridViewColumn("物料编码", 100); m_dataGridViewExtend.addDataGridViewColumn("简称", 80); m_dataGridViewExtend.addDataGridViewColumn("规格型号", 80); m_dataGridViewExtend.addDataGridViewColumn("品牌", 80); m_dataGridViewExtend.addDataGridViewColumn("存货数量", 80); if (m_isDisplayJG) { m_dataGridViewExtend.addDataGridViewColumn("加权单价", 80); m_dataGridViewExtend.addDataGridViewColumn("合计", 80); } m_dataGridViewExtend.addDataGridViewColumn("单位", 80); m_dataGridViewExtend.addDataGridViewColumn("参数", 60); m_dataGridViewExtend.addDataGridViewColumn("材质", 70); m_dataGridViewExtend.addDataGridViewColumn("存货上限", 80); m_dataGridViewExtend.addDataGridViewColumn("存货下限", 80); m_dataGridViewExtend.addDataGridViewColumn("保质期", 80); m_dataGridViewExtend.addDataGridViewColumn("收料仓库", 80); // 日期控件默认值为上个月最后一天,且最大值为昨天 DateTime nowDate = DateTime.Now; DateTime currentMonthFirstDay = new DateTime(nowDate.Year, nowDate.Month, 1); DateTime currentLastMonthDay = currentMonthFirstDay.AddMonths(0).AddDays(-1); this.dateTimePickerHistoryDate.Value = currentLastMonthDay; this.dateTimePickerHistoryDate.MaxDate = DateTime.Now.AddDays(-1); m_materielListHistoryInfo = StorageStockDetail.getInctance().getMaterielStorageStockDetailHistoryInfo(this.dateTimePickerHistoryDate.Value.ToString("yyyy-MM-dd")); m_dataGridViewExtend.initDataGridViewColumn(this.dataGridViewMaterielList); updateDataGridView(Materiel.getInctance().getAllMaterielInfo()); this.WindowState = FormWindowState.Maximized; }
private void updateDataGridView(int materielID = -1) { if (materielID == -1) { this.upRecord.Enabled = true; this.nextRecord.Enabled = true; if (m_currentRecordIndex < 0) { MessageBoxExtend.messageOK("已是首条记录"); return; } else if (m_currentRecordIndex >= m_materielList.Count) { MessageBoxExtend.messageOK("已是尾条记录"); return; } else { materielID = ((MaterielTable)m_materielList[m_currentRecordIndex]).pkey; } } else { this.upRecord.Enabled = false; this.nextRecord.Enabled = false; } // 期初余额 ArrayList firstRow = new ArrayList(); ArrayList sumRow = new ArrayList(); ArrayList lastRow = new ArrayList(); SortedDictionary <int, ArrayList> sortedDictionaryList = new SortedDictionary <int, ArrayList>(); SortedDictionary <int, StorageStockDetailTable> list = new SortedDictionary <int, StorageStockDetailTable>(); #region 期初余额记录行 StorageStockDetailTable firstRecord = StorageStockDetail.getInctance().getMaterielStorageStockDetailInfo(materielID, m_countStartDate); firstRow.Add(formatStringToMonth(m_countStartDate, 4)); firstRow.Add(""); firstRow.Add(""); firstRow.Add("期初结存"); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); firstRow.Add(""); if (firstRecord != null) { firstRow.Add(firstRecord.storageValue); firstRow.Add(firstRecord.storagePrice); firstRow.Add((double)(Math.Round(firstRecord.storageMoney * 100)) / 100); } else { firstRow.Add("0"); firstRow.Add("0"); firstRow.Add("0"); } sortedDictionaryList.Add(sortedDictionaryList.Count, firstRow); #endregion #region 当前时间段交易记录 list = StorageStockDetail.getInctance().getMaterielStorageStockDetailInfo(materielID, m_countStartDate, m_countEndDate); m_dataGridRecordCount = list.Count + 3; double inSumValue = 0, inSumMoney = 0, outSumValue = 0, outSumMoney = 0, stockSumValue = 0, stockSumPrice = 0, stockSumMoney = 0; for (int index = 0; index < list.Count; index++) { StorageStockDetailTable record = new StorageStockDetailTable(); record = (StorageStockDetailTable)list[index]; ArrayList temp = new ArrayList(); temp.Add(formatStringToMonth(record.tradingDate, 5)); temp.Add(record.tradingDate); temp.Add(record.billNumber); temp.Add(record.thingsType); if (record.isIn == 0) { // 出库类单据 temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(record.value); temp.Add(record.price); temp.Add(record.value * record.price); // 未完成:这里的信息需要显示项目编号和生产编号,如何添加 string projectNo = "", makeNo = ""; if (record.thingsType == "生产领料") { MaterielOutOrderTable materieOutOrder = MaterielOutOrder.getInctance().getMaterielOutOrderInfoFromBillNumber(record.billNumber); projectNo = materieOutOrder.projectNo; makeNo = materieOutOrder.makeNo; } else if (record.thingsType == "其他出库") { MaterielOutOtherOrderTable materieOutOrder = MaterielOutOtherOrder.getInctance().getMaterielOutOtherOrderInfoFromBillNumber(record.billNumber); projectNo = materieOutOrder.projectNo; makeNo = materieOutOrder.makeNo; } temp.Add(projectNo); temp.Add(makeNo); temp.Add(record.storageValue); temp.Add(record.storagePrice); temp.Add((double)(Math.Round(record.storageMoney * 100)) / 100); outSumValue += record.value; outSumMoney += record.value * record.price; } else if (record.isIn == 1) { // 入库类单据 temp.Add(record.value); temp.Add(record.price); temp.Add(record.value * record.price); if (record.thingsType == "采购入库") { m_purchaseInOrder = PurchaseInOrder.getInctance().getPurchaseInfoFromBillNumber(record.billNumber); temp.Add(m_purchaseInOrder.supplierName); } else { temp.Add(""); } temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(record.storageValue); temp.Add(record.storagePrice); temp.Add((double)(Math.Round(record.storageMoney * 100)) / 100); inSumValue += record.value; inSumMoney += record.value * record.price; } else { // 其他类型单据 temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(""); temp.Add(record.storageValue); temp.Add(record.storagePrice); temp.Add((double)(Math.Round(record.storageMoney * 100)) / 100); } if (index == list.Count - 1) { stockSumValue = record.storageValue; stockSumPrice = record.storagePrice; stockSumMoney += record.storageMoney; } sortedDictionaryList.Add(sortedDictionaryList.Count, temp); } #endregion #region 合计 sumRow.Add(""); sumRow.Add(""); sumRow.Add(""); sumRow.Add("合计"); sumRow.Add(inSumValue); sumRow.Add(getPercentValue(inSumMoney, inSumValue)); sumRow.Add(inSumMoney); sumRow.Add(""); sumRow.Add(outSumValue); sumRow.Add(getPercentValue(outSumMoney, outSumValue)); sumRow.Add(outSumMoney); sumRow.Add(""); sumRow.Add(""); sumRow.Add(""); sumRow.Add(""); sumRow.Add(""); sortedDictionaryList.Add(sortedDictionaryList.Count, sumRow); #endregion #region 期末结转 lastRow.Add(formatStringToMonth(m_countEndDate, 4)); lastRow.Add(""); lastRow.Add(""); lastRow.Add("期末结存"); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(""); lastRow.Add(stockSumValue); lastRow.Add(stockSumPrice); lastRow.Add((double)(Math.Round(stockSumMoney * 100)) / 100); sortedDictionaryList.Add(sortedDictionaryList.Count, lastRow); #endregion // 设置m_dateGridViewExtend背景为白色 m_dateGridViewExtend.initDataGridViewData(sortedDictionaryList); for (int i = 0; i < sortedDictionaryList.Count; i++) { dataGridViewList.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.White; } dataGridViewList.Rows[0].DefaultCellStyle.BackColor = System.Drawing.Color.LightGoldenrodYellow; dataGridViewList.Rows[sortedDictionaryList.Count - 2].DefaultCellStyle.BackColor = System.Drawing.Color.LightGoldenrodYellow; dataGridViewList.Rows[sortedDictionaryList.Count - 1].DefaultCellStyle.BackColor = System.Drawing.Color.LightGoldenrodYellow; // 更新状态栏信息 updateStatusLable(materielID); }
private void updateDataGridView(SortedDictionary <int, MaterielTable> materielList) { m_materielRecordCount = materielList.Count; this.labelMaterielGroupName.Text = "[" + m_materielGroupName + "]物料共计[" + Convert.ToString(m_materielRecordCount) + "]条记录"; SortedDictionary <int, ArrayList> materiels = new SortedDictionary <int, ArrayList>(); for (int i = 0; i < materielList.Count; i++) { MaterielTable materiel = new MaterielTable(); materiel = (MaterielTable)materielList[i]; if (!m_isStorageAgeCount) { ArrayList temp = new ArrayList(); temp.Add(materiel.pkey); temp.Add(materiel.name); temp.Add(materiel.model); temp.Add(materiel.brand); temp.Add(AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_UNIT_LIST", materiel.unit)); temp.Add(materiel.max); temp.Add(materiel.min); double materielCurrentStorageValue = InitMateriel.getInctance().getMarerielCountInfoFromMaterielID(materiel.pkey); temp.Add(materielCurrentStorageValue); if (m_isNeedFilterData) { if (materiel.min - materielCurrentStorageValue > m_filterValue) { temp.Add("当前库存与预设的物料下限差值大于" + Convert.ToString(m_filterValue)); materiels.Add(materiels.Count, temp); } if (materielCurrentStorageValue - materiel.max > m_filterValue) { temp.Add("当前库存与预设的物料上限差值大于" + Convert.ToString(m_filterValue)); materiels.Add(materiels.Count, temp); } } else { materiels.Add(materiels.Count, temp); } m_dataGridViewExtend.initDataGridViewData(materiels, 3); } else { // 库存账龄分析 ArrayList temp = new ArrayList(); temp.Add(materiel.pkey); temp.Add(materiel.name); temp.Add(materiel.model); temp.Add(materiel.brand); temp.Add(AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_UNIT_LIST", materiel.unit)); // 计算当前物料的账龄 double materielCurrentStorageValue = InitMateriel.getInctance().getMarerielCountInfoFromMaterielID(materiel.pkey); ArrayList materielAgeValueList = StorageStockDetail.getInctance().getMaterielAgeValue(materiel.pkey, materielCurrentStorageValue); temp.Add(materielCurrentStorageValue); temp.Add(materielAgeValueList[0]); temp.Add(materielAgeValueList[1]); temp.Add(materielAgeValueList[2]); temp.Add(materielAgeValueList[3]); materiels.Add(materiels.Count, temp); m_dataGridViewExtend.initDataGridViewData(materiels, 4); } } }
private void buttonEnter_Click(object sender, EventArgs e) { if (textBoxPrice.Text.Length == 0) { MessageBoxExtend.messageWarning("单价不能为空"); return; } if (textBoxPrice.Text.Length > 20) { MessageBoxExtend.messageWarning("单价最大长度不能超过10"); textBoxPrice.Text = ""; return; } if (textBoxValue.Text.Length == 0) { MessageBoxExtend.messageWarning("数量不能为空"); return; } if (MessageBoxExtend.messageQuestion("请确认是否要对[" + m_materielName + "]的成本进行调整,这将会影响到此物料实时库存的加权单价?")) { if (InitMateriel.getInctance().checkMaterielIsExist(m_materielPkey)) { // 第一步 插入插入到存货明细表(STORAGE_STOCK_DETAIL),已解决实际库存和历史库存信息可能不对应的问题 StorageStockDetailTable storageStockDetailRecord = new StorageStockDetailTable(); storageStockDetailRecord.materielID = m_materielPkey; storageStockDetailRecord.tradingDate = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); storageStockDetailRecord.billNumber = BillNumber.getInctance().getNewBillNumber(20, DateTime.Now.ToString("yyyy-MM-dd")); storageStockDetailRecord.thingsType = "期初成本调整"; storageStockDetailRecord.isIn = 3; storageStockDetailRecord.value = 0; storageStockDetailRecord.price = 0; // 交易完毕后数量和单价 InitMaterielTable materielStorageData = InitMateriel.getInctance().getMaterielInfoFromMaterielID(m_materielPkey); storageStockDetailRecord.storageValue = materielStorageData.value; storageStockDetailRecord.storagePrice = Convert.ToDouble(this.textBoxPrice.Text.ToString()); StorageStockDetail.getInctance().insert(storageStockDetailRecord); // 第二步 更新实时库存表(INIT_STORAGE_STOCK) InitMaterielTable record = new InitMaterielTable(); record.materielID = m_materielPkey; record.price = Convert.ToDouble(this.textBoxPrice.Text.ToString()); record.value = materielStorageData.value; InitMateriel.getInctance().update(materielStorageData.pkey, record); } else { // 第一步 插入插入到存货明细表(STORAGE_STOCK_DETAIL),已解决实际库存和历史库存信息可能不对应的问题 StorageStockDetailTable storageStockDetailRecord = new StorageStockDetailTable(); storageStockDetailRecord.materielID = m_materielPkey; storageStockDetailRecord.tradingDate = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); storageStockDetailRecord.billNumber = BillNumber.getInctance().getNewBillNumber(20, DateTime.Now.ToString("yyyy-MM-dd")); storageStockDetailRecord.thingsType = "期初成本调整"; storageStockDetailRecord.isIn = 3; storageStockDetailRecord.value = 0; storageStockDetailRecord.price = 0; storageStockDetailRecord.storageValue = 0.0; storageStockDetailRecord.storagePrice = Convert.ToDouble(this.textBoxPrice.Text.ToString()); StorageStockDetail.getInctance().insert(storageStockDetailRecord); // 第二步 更新实时库存表(INIT_STORAGE_STOCK) InitMaterielTable record = new InitMaterielTable(); record.materielID = m_materielPkey; record.price = Convert.ToDouble(this.textBoxPrice.Text.ToString()); record.value = 0.0; InitMateriel.getInctance().insert(record, true); } m_isAddToInitMaterielList = true; this.Close(); } }