private void updateDataGridView(SortedDictionary <int, MaterielTable> materielList) { m_materielRecordCount = materielList.Count; SortedDictionary <int, ArrayList> materiels = new SortedDictionary <int, ArrayList>(); 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); InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(materiel.pkey); temp.Add(MaterielCountdata.value); temp.Add(MaterielCountdata.price); 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)); materiels.Add(i, temp); } m_dataGridViewExtend.initDataGridViewData(materiels, 5); this.dataGridViewMaterielList.Columns[1].DefaultCellStyle.BackColor = System.Drawing.Color.LightGray; this.dataGridViewMaterielList.Columns[4].DefaultCellStyle.BackColor = System.Drawing.Color.LightGray; this.dataGridViewMaterielList.Columns[5].DefaultCellStyle.BackColor = System.Drawing.Color.LightGray; }
private void setMatetielInfoToDataGridView(double pkey) { /* 如果是物料编码列,需要判断该物料编码是否存在 * 如果存在读取相应的值填充DataGridView中对应的其他列,如果不存在该物料编码,则清空该行 * */ MaterielTable record = Materiel.getInctance().getMaterielInfoFromPkey((int)pkey); if (pkey != record.pkey || record.pkey == 0) { MessageBoxExtend.messageWarning("[" + dataGridViewDataList.Rows[m_rowIndex].Cells[m_columnIndex].EditedFormattedValue.ToString() + "]不存在,请重新输入或选择"); m_dateGridVeiwListDataList.clearDataGridViewRow(m_rowIndex); } else { InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID((int)pkey); dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.MatetielName].Value = record.name; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Model].Value = record.model; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Unit].Value = AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_UNIT_LIST", record.unitSale); dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Price].Value = Convert.ToString(MaterielCountdata.price); dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Value].Value = "0"; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Turnover].Value = "0"; } }
private void FormInitMaterielEdit_Load(object sender, EventArgs e) { if (m_isEditMaterielData) { this.buttonEdit.Enabled = true; this.buttonSelect.Enabled = false; this.textBoxPrice.Enabled = false; this.textBoxValue.Enabled = false; this.buttonEnter.Enabled = false; MaterielTable materiel = Materiel.getInctance().getMaterielInfoFromPkey(m_materielPkey); this.textBoxName.Text = Convert.ToString(materiel.pkey) + "-" + materiel.name; m_materielName = materiel.name; if (InitMateriel.getInctance().checkMaterielIsExist(m_materielPkey)) { InitMaterielTable materielStock = InitMateriel.getInctance().getMaterielInfoFromMaterielID(m_materielPkey); this.textBoxValue.Text = Convert.ToString(materielStock.value); this.textBoxPrice.Text = Convert.ToString(materielStock.price); } else { this.textBoxValue.Text = "0"; this.textBoxPrice.Text = "0"; } } }
private void modify_Click(object sender, EventArgs e) { FormInitMaterielEdit fime = new FormInitMaterielEdit("编辑物料初始资料", true, m_currentDataGridViedRecordPkey); fime.ShowDialog(); updateDataGridView(InitMateriel.getInctance().getAllInitMaterielInfo()); }
private void FormMaterielDetailed_Load(object sender, EventArgs e) { // 物料基本信息 this.labelMaterielID.Text = Convert.ToString(m_materielID); MaterielTable record = Materiel.getInctance().getMaterielInfoFromPkey(m_materielID); this.labelMaterielName.Text = record.name; // 实际库存+预占 InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(m_materielID); this.labelCount.Text = Convert.ToString(MaterielCountdata.value); this.labelProCount.Text = Convert.ToString(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(m_materielID)); // 材料表情况 if (m_xxMaterielTablebillNubmber.Length > 0) { this.labelxxMaterielTableNum.Text = m_xxMaterielTablebillNubmber; FormProjectMaterielTable projectInfo = FormProject.getInctance().getProjectInfoFromBillNumber(m_xxMaterielTablebillNubmber); this.labelProjectNum.Text = projectInfo.projectNum; this.labelProName.Text = projectInfo.projectName; this.labelDevMode.Text = projectInfo.deviceMode; SortedDictionary <int, ProjectManagerDetailsTable> list = ProjectManagerDetails.getInctance().getPurchaseInfoFromBillNumber(m_xxMaterielTablebillNubmber); foreach (KeyValuePair <int, ProjectManagerDetailsTable> index in list) { if (index.Value.materielID == m_materielID) { this.labelSub.Text = index.Value.deviceName; this.labelNum.Text = index.Value.no; this.labelSquence.Text = index.Value.sequence; this.label1Value.Text = Convert.ToString(index.Value.value); this.labelUseDate.Text = index.Value.useDate; break; } } } else { this.labelxxMaterielTableNum.Text = " "; this.labelProjectNum.Text = " "; this.labelProName.Text = " "; this.labelDevMode.Text = " "; this.labelSub.Text = " "; this.label1Value.Text = " "; this.labelUseDate.Text = " "; this.labelNum.Text = " "; this.labelSquence.Text = " "; this.labelUseDate.Text = " "; } }
private void setMatetielInfoToDataGridView(string id) { /* 如果是物料编码列,需要判断该物料编码是否存在 * 如果存在读取相应的值填充DataGridView中对应的其他列,如果不存在该物料编码,则清空该行 * */ //使用这个输入的值,匹配物料编号 double pkey = 0; MaterielTable record = Materiel.getInctance().getMaterielInfoFromNum(Convert.ToString(id)); if (record == null || id.ToLower() != record.num.ToLower() || record.pkey == 0) { try { //使用这个输入的值,匹配物料key pkey = Convert.ToDouble(id.ToString()); record = Materiel.getInctance().getMaterielInfoFromPkey((int)pkey); if (pkey != record.pkey || record.pkey == 0) { MessageBoxExtend.messageWarning("[" + dataGridViewDataList.Rows[m_rowIndex].Cells[m_columnIndex].EditedFormattedValue.ToString() + "]不存在,请重新输入或选择"); m_dateGridVeiwListDataList.clearDataGridViewRow(m_rowIndex); return; } } catch { MessageBoxExtend.messageWarning("[" + dataGridViewDataList.Rows[m_rowIndex].Cells[m_columnIndex].EditedFormattedValue.ToString() + "]不存在,请重新输入或选择"); m_dateGridVeiwListDataList.clearDataGridViewRow(m_rowIndex); return; } } InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID((int)pkey); dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.MatetielNumber].Value = record.pkey; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.MatetielName].Value = record.name; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Model].Value = record.model; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Unit].Value = AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_UNIT_LIST", record.unitSale); dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Parameter].Value = record.materielParameter; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Brand].Value = record.brand; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.CZ].Value = record.CZ; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Price].Value = Convert.ToString(MaterielCountdata.price); dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Value].Value = "0"; dataGridViewDataList.Rows[m_rowIndex].Cells[(int)DataGridColumnName.Turnover].Value = "0"; }
private void import_Click(object sender, EventArgs e) { if (MessageBoxExtend.messageQuestion("批量导入数据会清空数据库所有已存在库存记录,是否继续?")) { // 指定OpenFileDialog控件打开的文件格式 openFileDialog1.Filter = "导入文件(*.xls)|*.xls"; openFileDialog1.FileName = ""; if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { InitMateriel.getInctance().fileImport(openFileDialog1.FileName); updateDataGridView(Materiel.getInctance().getAllMaterielInfo()); } } }
private void FormInitMateriel_Load(object sender, EventArgs e) { m_dateGridViewExtend.addDataGridViewColumn("ID", 30); m_dateGridViewExtend.addDataGridViewColumn("物料编号", 80); m_dateGridViewExtend.addDataGridViewColumn("物料名称", 150); m_dateGridViewExtend.addDataGridViewColumn("计价单位", 150); m_dateGridViewExtend.addDataGridViewColumn("收料仓库", 150); m_dateGridViewExtend.addDataGridViewColumn("单价", 100); m_dateGridViewExtend.addDataGridViewColumn("数量", 100); m_dateGridViewExtend.initDataGridViewColumn(this.dataGridViewMaterielList); updateDataGridView(InitMateriel.getInctance().getAllInitMaterielInfo()); setPageActionEnable(); }
private void add_Click(object sender, EventArgs e) { // shengguang++ 2016-11-05 当业务启动后,增加功能:不能再直接增加物料库存信息 if (InitSubSystemSign.getInctance().isBusinessSystemInit()) { MessageBoxExtend.messageWarning("业务系统已启用,不能再直接添加物料库存信息,请通过物料入库方式完成此操作"); return; } // ++shengguang FormInitMaterielEdit fime = new FormInitMaterielEdit("添加物料初始资料", false); fime.ShowDialog(); updateDataGridView(InitMateriel.getInctance().getAllInitMaterielInfo()); }
private void delete_Click(object sender, EventArgs e) { // shengguang++ 2016-11-05 当业务启动后,增加功能:不能再直接删除物料库存信息 if (InitSubSystemSign.getInctance().isBusinessSystemInit()) { MessageBoxExtend.messageWarning("业务系统已启用,不能再直接删除物料库存信息,请通过物料出库方式完成此操作"); return; } // ++shengguang if (m_currentDataGridViedRecordPkey != 0) { if (MessageBoxExtend.messageQuestion("确定删除[" + m_currentDataGridViedRecordName + "]库存信息吗?")) { InitMateriel.getInctance().delete(m_currentDataGridViedRecordPkey); updateDataGridView(Materiel.getInctance().getAllMaterielInfo()); } } }
private void FormInitMaterielEdit_Load(object sender, EventArgs e) { if (m_isEditMaterielData) { this.buttonEdit.Enabled = true; this.buttonSelect.Enabled = false; this.textBoxPrice.Enabled = false; this.textBoxValue.Enabled = false; this.buttonEnter.Enabled = false; InitMaterielTable materielStock = InitMateriel.getInctance().getMaterielInfoFromPkey(m_storageStockTablePkey); m_materielPkey = materielStock.materielID; MaterielTable materiel = Materiel.getInctance().getMaterielInfoFromPkey(m_materielPkey); this.textBoxName.Text = Convert.ToString(materiel.pkey) + "-" + materiel.name; this.textBoxValue.Text = Convert.ToString(materielStock.value); this.textBoxPrice.Text = Convert.ToString(materielStock.price); m_materielName = materiel.name; } }
private void updateDataGridView(SortedDictionary <int, MaterielTable> settlmentWayList) { m_dataGridRecordCount = settlmentWayList.Count; SortedDictionary <int, ArrayList> settlmentWayLArrary = new SortedDictionary <int, ArrayList>(); SortedDictionary <int, AuxiliaryMaterialDataTable> AuxiliaryStorelList = AuxiliaryMaterial.getInctance().getAuxiliaryListFromTableName("BASE_STORAGE_LIST"); for (int i = 0; i < settlmentWayList.Count; i++) { MaterielTable record = new MaterielTable(); record = (MaterielTable)settlmentWayList[i]; ArrayList temp = new ArrayList(); temp.Add(record.pkey); temp.Add(record.num); temp.Add(record.name); if (AuxiliaryStorelList.ContainsKey(record.storage)) { temp.Add(AuxiliaryStorelList[record.storage].name); } else { temp.Add(""); } InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(record.pkey); temp.Add(MaterielCountdata.price); temp.Add(MaterielCountdata.value); settlmentWayLArrary.Add(i, temp); } m_dateGridViewExtend.initDataGridViewData(settlmentWayLArrary); }
private void updateDataGridView(SortedDictionary <int, MaterielTable> materielList) { double sum = 0; m_materielRecordCount = materielList.Count; SortedDictionary <int, ArrayList> materiels = new SortedDictionary <int, ArrayList>(); 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.model); InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(materiel.pkey); temp.Add(MaterielCountdata.value); if (m_isDisplayJG) { temp.Add(MaterielCountdata.price); temp.Add((double)(Math.Round(MaterielCountdata.value * MaterielCountdata.price * 100)) / 100); } if (m_materielProlist.ContainsKey(materiel.pkey)) { MaterielProOccupiedInfo proOccupiedRecord = new MaterielProOccupiedInfo(); proOccupiedRecord = (MaterielProOccupiedInfo)m_materielProlist[materiel.pkey]; temp.Add(proOccupiedRecord.sum); temp.Add(proOccupiedRecord.applyStaffName); temp.Add(MaterielCountdata.value - proOccupiedRecord.sum); } else { temp.Add(0); temp.Add("-"); temp.Add(MaterielCountdata.value); } 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 += MaterielCountdata.value * MaterielCountdata.price; } } 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 += MaterielCountdata.value * MaterielCountdata.price; } } else { materiels.Add(materiels.Count, temp); sum += MaterielCountdata.value * MaterielCountdata.price; } } // 金额信息保留2位小数儿 sum = (double)(Math.Round(sum * 100)) / 100; if (m_isDisplayJG) { m_dataGridViewExtend.initDataGridViewData(materiels, 8); } else { m_dataGridViewExtend.initDataGridViewData(materiels, 6); } this.dataGridViewMaterielList.Columns[1].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; this.dataGridViewMaterielList.Columns[3].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; if (m_isDisplayJG) { this.dataGridViewMaterielList.Columns[4].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; this.dataGridViewMaterielList.Columns[5].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; this.dataGridViewMaterielList.Columns[8].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; this.labelCountInfo.Text += " 累计金额[" + Convert.ToString(sum) + "]"; } else { this.dataGridViewMaterielList.Columns[6].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen; } this.labelCountInfo.Text = "[" + m_materielGroupName + "]类材料总计[" + Convert.ToString(materiels.Count) + "]条"; }
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 toolStripButtonRefresh_Click(object sender, EventArgs e) { InitMateriel.getInctance().refreshRecord(); Materiel.getInctance().refreshRecord(); updateDataGridView(Materiel.getInctance().getAllMaterielInfo()); }
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(); } }
private void getProInfoList() { m_proInfoList.Clear(); // 得到单据变更情况 SortedDictionary <int, ProjectManagerDetailsTable> changeMaterielList = FormProjectInfoChange.getInctance().getMaterielDetailsFromSrcBillNumber(m_billNumber); // 根据单据,得到单据详细信息 SortedDictionary <int, ProjectManagerDetailsTable> listDetails = new SortedDictionary <int, ProjectManagerDetailsTable>(); listDetails = ProjectManagerDetails.getInctance().getPurchaseInfoFromBillNumber(m_billNumber); for (int index = 0; index < listDetails.Count; index++) { ArrayList record = new ArrayList(); ProjectManagerDetailsTable tmp = new ProjectManagerDetailsTable(); tmp = (ProjectManagerDetailsTable)listDetails[index]; // 单据所需物料 double requestValue = 0.0; // 已转数量 double proValue = 0.0; // 物料数量可能会存在变更,若发生变更,需要使用变更后数量代替原有数量,在一个材料表中,序号是唯一值 int sign = 0; if (tmp.no.Length > 0) { sign = Convert.ToInt32(tmp.no); } if (changeMaterielList.Count > 0 && changeMaterielList.ContainsKey(sign)) { if (tmp.materielID != changeMaterielList[sign].materielID) { // 相当于变更时,使用使用了另外一种物料替换了现有物料, tmp.materielID = changeMaterielList[sign].materielID; } requestValue = changeMaterielList[sign].value; changeMaterielList.Remove(sign); } else { requestValue = tmp.value; } if (m_dataType == 1) { proValue = MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID, tmp.billNumber); } else if (m_dataType == 2) { proValue = PurchaseApplyOrderDetails.getInctance().getPurchaseValueFromProjectNumber(tmp.billNumber, PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); } else if (m_dataType == 3) { proValue = MaterielOutOrderDetails.getInctance().getMaterielCountInfoFromProject(tmp.billNumber, PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); } if (requestValue - proValue > 0) { record.Add(tmp.billNumber); record.Add(tmp.materielID); record.Add(requestValue); record.Add(proValue); // 库存预占情况,本项目预占量 record.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID)); record.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID, tmp.billNumber)); // 得到实际库存 InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(tmp.materielID); record.Add(MaterielCountdata.value); // 使用行号+序列号+序号的和作为一行数据的唯一标识 record.Add(PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); m_proInfoList.Add(m_proInfoList.Count, record); } } foreach (KeyValuePair <int, ProjectManagerDetailsTable> index3 in changeMaterielList) { ArrayList record1 = new ArrayList(); ProjectManagerDetailsTable tmp1 = new ProjectManagerDetailsTable(); tmp1 = index3.Value; // 单据需要的数量 double requestValue1 = tmp1.value; // 已转数量 double proValue1 = 0.0; if (m_dataType == 1) { proValue1 = MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp1.materielID, FormProjectInfoChange.getInctance().getxxMaterielNumberFromBillNumber(tmp1.billNumber)); } else if (m_dataType == 2) { proValue1 = PurchaseApplyOrderDetails.getInctance().getPurchaseValueFromProjectNumber( FormProjectInfoChange.getInctance().getxxMaterielNumberFromBillNumber(tmp1.billNumber), PublicFuction.getXXMateaielOrderSign(tmp1.rowNumber, tmp1.sequence, tmp1.no)); } else if (m_dataType == 3) { proValue1 = MaterielOutOrderDetails.getInctance().getMaterielCountInfoFromProject( FormProjectInfoChange.getInctance().getxxMaterielNumberFromBillNumber(tmp1.billNumber), PublicFuction.getXXMateaielOrderSign(tmp1.rowNumber, tmp1.sequence, tmp1.no)); } if (requestValue1 - proValue1 > 0) { record1.Add(tmp1.billNumber); record1.Add(tmp1.materielID); record1.Add(tmp1.value); record1.Add(proValue1); // 库存预占情况,本项目预占量 record1.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp1.materielID)); record1.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp1.materielID, tmp1.billNumber)); // 得到实际库存 InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(tmp1.materielID); record1.Add(MaterielCountdata.value); // 使用行号+序列号+序号的和作为一行数据的唯一标识 record1.Add(PublicFuction.getXXMateaielOrderSign(tmp1.rowNumber, tmp1.sequence, tmp1.no)); m_proInfoList.Add(m_proInfoList.Count, record1); } } if (m_proInfoList.Count == 0) { this.button1.Enabled = false; } this.label1.Text += ", 共有[" + Convert.ToString(m_proInfoList.Count) + "]条数据"; }
private void getInfoListFromBillNumber(FormProjectMaterielTable record) { SortedDictionary <int, ProjectManagerDetailsTable> listDetails = new SortedDictionary <int, ProjectManagerDetailsTable>(); listDetails = ProjectManagerDetails.getInctance().getPurchaseInfoFromBillNumber(record.billNumber); SortedDictionary <int, ProjectManagerDetailsTable> changeMaterielList = FormProjectInfoChange.getInctance().getMaterielDetailsFromSrcBillNumber(record.billNumber); for (int index2 = 0; index2 < listDetails.Count; index2++) { ProjectManagerDetailsTable tmp = new ProjectManagerDetailsTable(); tmp = (ProjectManagerDetailsTable)listDetails[index2]; // 物料数量可能会存在变更,若发生变更,需要使用变更后数量代替原有数量,在一个材料表中,序号是唯一值 double actualValue = 0.0; int sign = 0; if (tmp.no.Length > 0) { sign = Convert.ToInt32(tmp.no); } if (changeMaterielList.Count > 0 && changeMaterielList.ContainsKey(sign)) { if (tmp.materielID != changeMaterielList[sign].materielID) { // 相当于变更时,使用使用了另外一种物料替换了现有物料, tmp.materielID = changeMaterielList[sign].materielID; tmp.materielName = changeMaterielList[sign].materielName; tmp.num = changeMaterielList[sign].num; tmp.materielModel = changeMaterielList[sign].materielModel; tmp.materielParameter = changeMaterielList[sign].materielParameter; tmp.cl = changeMaterielList[sign].cl; tmp.materielSize = changeMaterielList[sign].materielSize; } actualValue = changeMaterielList[sign].value; changeMaterielList.Remove(sign); } else { actualValue = tmp.value; } ArrayList temp = new ArrayList(); temp.Add(record.billNumber); temp.Add(record.projectNum); temp.Add(record.makeNum); temp.Add(record.deviceMode); temp.Add(record.subName); temp.Add(tmp.materielID); temp.Add(tmp.materielName); temp.Add(tmp.num); temp.Add(tmp.materielModel); temp.Add(tmp.materielParameter); temp.Add(tmp.cl); temp.Add(tmp.materielSize); temp.Add(actualValue); // 得到实际库存 InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(tmp.materielID); temp.Add(MaterielCountdata.value); // 库存预占情况,包含总预占量和本项目预占量 temp.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID)); temp.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID, record.billNumber)); // 转采购申请单数量 double appylyCount = PurchaseApplyOrderDetails.getInctance().getPurchaseValueFromProjectNumber(record.billNumber, PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); temp.Add(appylyCount); // 采购订单数量 SortedDictionary <int, PurchaseOrderTable> listOrderList = new SortedDictionary <int, PurchaseOrderTable>(); listOrderList = PurchaseOrder.getInctance().getAllPurchaseOrderInfoFromProjectNum(record.billNumber); double orderCount = 0; for (int indexOrderList = 0; indexOrderList < listOrderList.Count; indexOrderList++) { PurchaseOrderTable recordOrder = new PurchaseOrderTable(); recordOrder = (PurchaseOrderTable)listOrderList[indexOrderList]; orderCount += PurchaseOrderDetails.getInctance().getPurchaseValueFromBillNumber(recordOrder.billNumber, tmp.materielID); } temp.Add(orderCount); // 采购入库数量 SortedDictionary <int, PurchaseInOrderTable> purchaseInOrderList = new SortedDictionary <int, PurchaseInOrderTable>(); purchaseInOrderList = PurchaseInOrder.getInctance().getAllPurchaseOrderInfoFromProjectNum(record.billNumber); double purchaseInOrderValueCount = 0; for (int indexOrderList = 0; indexOrderList < purchaseInOrderList.Count; indexOrderList++) { PurchaseInOrderTable recordOrder = new PurchaseInOrderTable(); recordOrder = (PurchaseInOrderTable)purchaseInOrderList[indexOrderList]; purchaseInOrderValueCount += PurchaseInOrderDetails.getInctance().getPurchaseValueFromBillNumber(recordOrder.billNumber, tmp.materielID); } temp.Add(purchaseInOrderValueCount); // 生产领料数量 double materielOutOrderValueCount = MaterielOutOrderDetails.getInctance().getMaterielCountInfoFromProject(record.billNumber, PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); temp.Add(materielOutOrderValueCount); m_projectInfoList.Add(m_projectInfoList.Count, temp); } // 如果changeMaterielList.count大于0 则代表有 foreach (KeyValuePair <int, ProjectManagerDetailsTable> index3 in changeMaterielList) { ProjectManagerDetailsTable tmp = new ProjectManagerDetailsTable(); tmp = index3.Value; ArrayList temp = new ArrayList(); temp.Add(record.billNumber); temp.Add(record.projectNum); temp.Add(record.makeNum); temp.Add(record.deviceMode); temp.Add(record.subName); temp.Add(tmp.materielID); temp.Add(tmp.materielName); temp.Add(tmp.num); temp.Add(tmp.materielModel); temp.Add(tmp.materielParameter); temp.Add(tmp.cl); temp.Add(tmp.materielSize); temp.Add(tmp.value); // 得到实际库存 InitMaterielTable MaterielCountdata = InitMateriel.getInctance().getMaterielInfoFromMaterielID(tmp.materielID); temp.Add(MaterielCountdata.value); // 库存预占情况,包含总预占量和本项目预占量 temp.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID)); temp.Add(MaterielProOccupiedOrderDetails.getInctance().getMaterielProCountInfoFromProject(tmp.materielID, record.billNumber)); // 转采购申请单数量 double appylyCount = PurchaseApplyOrderDetails.getInctance().getPurchaseValueFromProjectNumber(record.billNumber, PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); temp.Add(appylyCount); // 采购订单数量 SortedDictionary <int, PurchaseOrderTable> listOrderList = new SortedDictionary <int, PurchaseOrderTable>(); listOrderList = PurchaseOrder.getInctance().getAllPurchaseOrderInfoFromProjectNum(record.billNumber); double orderCount = 0; for (int indexOrderList = 0; indexOrderList < listOrderList.Count; indexOrderList++) { PurchaseOrderTable recordOrder = new PurchaseOrderTable(); recordOrder = (PurchaseOrderTable)listOrderList[indexOrderList]; orderCount += PurchaseOrderDetails.getInctance().getPurchaseValueFromBillNumber(recordOrder.billNumber, tmp.materielID); } temp.Add(orderCount); // 采购入库数量 SortedDictionary <int, PurchaseInOrderTable> purchaseInOrderList = new SortedDictionary <int, PurchaseInOrderTable>(); purchaseInOrderList = PurchaseInOrder.getInctance().getAllPurchaseOrderInfoFromProjectNum(record.billNumber); double purchaseInOrderValueCount = 0; for (int indexOrderList = 0; indexOrderList < purchaseInOrderList.Count; indexOrderList++) { PurchaseInOrderTable recordOrder = new PurchaseInOrderTable(); recordOrder = (PurchaseInOrderTable)purchaseInOrderList[indexOrderList]; purchaseInOrderValueCount += PurchaseInOrderDetails.getInctance().getPurchaseValueFromBillNumber(recordOrder.billNumber, tmp.materielID); } temp.Add(purchaseInOrderValueCount); // 生产领料数量 double materielOutOrderValueCount = MaterielOutOrderDetails.getInctance().getMaterielCountInfoFromProject(record.billNumber, PublicFuction.getXXMateaielOrderSign(tmp.rowNumber, tmp.sequence, tmp.no)); temp.Add(materielOutOrderValueCount); m_projectInfoList.Add(m_projectInfoList.Count, temp); } }