// 物料收发明细 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 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 StorageStockDetailTable getMaterielHistoryInfoFromMaterielID(int pkey) { StorageStockDetailTable record = new StorageStockDetailTable(); record.price = 0; record.value = 0; foreach (KeyValuePair <int, StorageStockDetailTable> index in m_materielListHistoryInfo) { StorageStockDetailTable tmp = new StorageStockDetailTable(); tmp = index.Value; if (tmp.materielID == pkey) { record.price = tmp.storagePrice; record.value = tmp.storageValue; break; } } return(record); }
private void updateDataGridView(SortedDictionary <int, MaterielTable> materielList) { double sum = 0; m_materielRecordCount = materielList.Count; SortedDictionary <int, ArrayList> materiels = new SortedDictionary <int, ArrayList>(); //分别代表数量和单价 double materielCountdataPrice = 0, materielCountdataValue = 0; for (int i = 0; i < materielList.Count; i++) { MaterielTable materiel = new MaterielTable(); materiel = (MaterielTable)materielList[i]; ArrayList temp = new ArrayList(); temp.Add(materiel.pkey); temp.Add(materiel.name); temp.Add(materiel.nameShort); temp.Add(materiel.model); StorageStockDetailTable MaterielHistoryInfo = getMaterielHistoryInfoFromMaterielID(materiel.pkey); materielCountdataPrice = MaterielHistoryInfo.price; materielCountdataValue = MaterielHistoryInfo.value; temp.Add(materielCountdataValue); if (m_isDisplayJG) { temp.Add(materielCountdataPrice); temp.Add((double)(Math.Round(materielCountdataValue * materielCountdataPrice * 100)) / 100); } temp.Add(AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_UNIT_LIST", materiel.unitStorage)); temp.Add(materiel.max); temp.Add(materiel.min); temp.Add(materiel.warramty); temp.Add(AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_STORAGE_LIST", materiel.storage)); if (m_displayDataType == (int)DisplayDataType.Materiel) { string materielAttributeName = AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_MATERIEL_ATTRIBUTE", materiel.materielAttribute); if (materielAttributeName.IndexOf("外购") != -1) { materiels.Add(materiels.Count, temp); sum += materielCountdataValue * materielCountdataPrice; } } else if (m_displayDataType == (int)DisplayDataType.Product) { string materielAttributeName = AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_MATERIEL_ATTRIBUTE", materiel.materielAttribute); if (materielAttributeName.IndexOf("外购") == -1) { materiels.Add(materiels.Count, temp); sum += materielCountdataValue * materielCountdataPrice; } } else { materiels.Add(materiels.Count, temp); sum += materielCountdataValue * materielCountdataPrice; } } // 金额信息保留2位小数儿 sum = (double)(Math.Round(sum * 100)) / 100; m_dataGridViewExtend.initDataGridViewData(materiels, 5); this.dataGridViewMaterielList.Columns[1].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; this.dataGridViewMaterielList.Columns[4].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; if (m_isDisplayJG) { this.dataGridViewMaterielList.Columns[5].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; this.dataGridViewMaterielList.Columns[6].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; } this.labelCountInfo.Text = "[" + m_materielGroupName + "]类材料总计[" + Convert.ToString(materiels.Count) + "]条"; if (m_isDisplayJG) { this.labelCountInfo.Text += " 累计金额[" + Convert.ToString(sum) + "]"; } }
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 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(); } }