public ArrayList GetData(string sql) { entity = new ArrayList(); PartsDTO partDto; SqlCommand cmd = new SqlCommand(sql, sqlConn); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { partDto = new PartsDTO(Convert.ToInt16(read[0]), Convert.ToInt16(read[1]), Convert.ToInt16(read[2]), read[3].ToString(), read[4].ToString(), read[5].ToString(), read[6].ToString(), read[7].ToString(), read[8].ToString(), read[9].ToString(), Convert.ToDouble(read[10]), Convert.ToInt32(read[11]), Convert.ToDouble(read[12]), read[13].ToString()); entity.Add(partDto); } read.Close(); return(entity); }
private void btnModify_Click(object sender, EventArgs e) { if (dataGridPOs.CurrentRow == null) { return; } POAdd frmPurchaseOrderModify = new POAdd(((MainForm)MdiParent).dbCtrl.sqlConn); frmPurchaseOrderModify.Text = btnModify.Text; if (flag) { frmPurchaseOrderModify.btn_Save.Text = "수 정"; } else { frmPurchaseOrderModify.btn_Save.Text = "추가 발주"; } int curRow = dataGridPOs.CurrentRow.Index; frmPurchaseOrderModify.poid = dataGridPOs[0, curRow].Value.ToString(); if (dataGridPOs["구분", curRow].Value.ToString().Equals("구매부서 발주품")) { frmPurchaseOrderModify.cbBox_PoGubun.SelectedIndex = 0; } else { frmPurchaseOrderModify.cbBox_PoGubun.SelectedIndex = 1; } frmPurchaseOrderModify.txtBox_ExpenseNum.Text = dataGridPOs["승인번호", curRow].Value.ToString(); frmPurchaseOrderModify.txtBox_PoNum.Text = dataGridPOs["PO번호", curRow].Value.ToString(); if (flag) { frmPurchaseOrderModify.PORevision.Value = Convert.ToInt16(dataGridPOs["PO Rev.", curRow].Value) + 1; } else { frmPurchaseOrderModify.PORevision.Value = 1; } if (dataGridPOs["화폐단위", curRow].Value.Equals("원")) { frmPurchaseOrderModify.comboBox_moneyTypeEX.SelectedIndex = 0; frmPurchaseOrderModify.comboBox_moneyTypeTotal.SelectedIndex = 0; } else { frmPurchaseOrderModify.comboBox_moneyTypeEX.SelectedIndex = 1; frmPurchaseOrderModify.comboBox_moneyTypeTotal.SelectedIndex = 1; } frmPurchaseOrderModify.dateTimeEstimate.Value = Convert.ToDateTime(dataGridPOs["예상납기일", curRow].Value); if (dataGridPOs["요청납기일", curRow].ToString() == "DataGridViewTextBoxCell { ColumnIndex=12, RowIndex=0 }") { frmPurchaseOrderModify.dateTimeRequest.Text = ""; } else { frmPurchaseOrderModify.dateTimeRequest.Text = dataGridPOs["요청납기일", curRow].ToString(); } if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("세금계산서 발행후 30일")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 0; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("세금계산서 발행후 45일")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 1; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("세금계산서 발행후 60일")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 2; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("30%/70% 45일")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 3; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("30%/70% 현금")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 4; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("30%/70% 선결재")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 5; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("현금결재")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 6; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("익월말 결재")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 7; } else if (dataGridPOs["결제조건", curRow].Value.ToString().Equals("선결재")) { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 8; } else { frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex = 9; } frmPurchaseOrderModify.cbBox_DeliveryCondition.SelectedIndex = 0; string getVenderIDquery = "SELECT " + "[VendorID] " + "FROM [Vendors] " + "WHERE [VendorIsUse] = 1 AND [VendorName] =" + "'" + dataGridPOs[5, curRow].Value.ToString() + "'"; frmPurchaseOrderModify.VendorID = ((MainForm)MdiParent).dbCtrl.GetVendorID(getVenderIDquery); string query = "SELECT " + "[PartID] " + ",[POPartsID] " + ",[POPartsPartID] " + ",[PartNumber] [자재 NO.] " + ",[PartName] [자재명] " + ",[VendorName] [공급업체] " + ",[PartManufacture] [제조업체] " + ",[PartDrawingNumber] [도면번호] " + ",[PartMakerPN] [Maker P/N]" + ",[PartUnit] [단위] " + ",convert(VARCHAR, convert(MONEY,PartUnitPrice),1) [단가] " + ",[POPartQuantity] [수량] " + ",convert(VARCHAR, convert(MONEY,POPartTotalAmount),1) [금액] " + ",CASE [PartUnitPriceType] " + "WHEN 0 THEN '원' " + "WHEN 1 THEN '달러' " + "END [화폐단위] " + "FROM ([POParts] LEFT JOIN [Parts] ON [POPartsPartID] = [PartID]) LEFT JOIN [Vendors] ON [PartVendorID] = [VendorID] " + "WHERE [POPartsPOID] = " + modify_poid; if (!ckBoxAll.Checked) { query = query + " AND [POPartIsUse] = 1 "; } query = query + " ORDER BY [POPartsID] "; ArrayList entity = ((MainForm)MdiParent).dbCtrl.GetData(query); IEnumerator enu = entity.GetEnumerator(); while (enu.MoveNext()) { PartsDTO date = (PartsDTO)enu.Current; frmPurchaseOrderModify.UpdateAddParts(date.getPartID(), date.getPartNo(), date.getPartName(), date.getVendorName(), date.getPartManufacture(), date.getPartDrawingNumber(), date.getPartMakerPN(), date.getPartUnit(), date.getPartUnitPrice(), date.getPOPartQuantity(), date.getPOPartTotalAmount(), date.getPriceType()); frmPurchaseOrderModify.total += date.getPOPartTotalAmount(); } frmPurchaseOrderModify.dataGridPOParts.Columns[0].Visible = false; if (frmPurchaseOrderModify.ShowDialog() == DialogResult.OK) { ((MainForm)MdiParent).dbCtrl.SendQuery("UPDATE [POs] SET " + "[POIsComplete] = 1," + "[POIsUse] = 0 " + "WHERE [POID] = " + dataGridPOs[0, curRow].Value.ToString()); if (Convert.ToInt16(frmPurchaseOrderModify.PORevision.Value) > 1) { ((MainForm)MdiParent).dbCtrl.SendQuery("UPDATE [POParts] SET " + "[POPartIsComplete] = 1" + "WHERE [POPartsPOID] = " + modify_poid); } ((MainForm)MdiParent).dbCtrl.SendQuery("INSERT INTO [POs] (" + "[POVendorID] " + ",[POCategory] " + ",[POConsultNumber] " + ",[PONumber] " + ",[PONumRevion] " + ",[POEstimatedDeliveryDate] " + ",[PORequestDeliveryDate] " + ",[POPaymentTerms] " + ",[PODeliveryCondition] " + ",[POTotalAmountType] " + ",[POTotalAmount]) VALUES ( " + frmPurchaseOrderModify.VendorID + "," + frmPurchaseOrderModify.cbBox_PoGubun.SelectedIndex + "," + "'" + frmPurchaseOrderModify.txtBox_ExpenseNum.Text + "'," + "'" + frmPurchaseOrderModify.txtBox_PoNum.Text + "'," + frmPurchaseOrderModify.PORevision.Value + "," + "'" + frmPurchaseOrderModify.dateTimeEstimate.Value.ToShortDateString() + "'," + "'" + frmPurchaseOrderModify.dateTimeRequest.Text + "'," + frmPurchaseOrderModify.cbBox_PaymentCondition.SelectedIndex + "," + frmPurchaseOrderModify.cbBox_DeliveryCondition.SelectedIndex + "," + frmPurchaseOrderModify.comboBox_moneyTypeEX.SelectedIndex + "," + frmPurchaseOrderModify.total + " )"); POsTable(); if (dataGridPOs.CurrentRow == null) { return; } for (int i = 0; i < frmPurchaseOrderModify.dataGridPOParts.RowCount; i++) { ((MainForm)MdiParent).dbCtrl.SendQuery("INSERT INTO [POParts] (" + "[POPartsPOID] " + ",[POPartsPartID] " + ",[POPartQuantity] " + ",[POPartTotalAmount] " + ",[POPartInputQuantity] " + //입고량 ",[POPartInputTotalAmount] " + //입고 총액 ",[POPartInputMinusQuantity] " + //미입고 수량 ",[POPartInputMinusTotalAmount] " + //미입고 금액 " ) VALUES ( " + dataGridPOs[0, 0].Value.ToString() + "," + frmPurchaseOrderModify.dataGridPOParts[0, i].Value.ToString() + "," + frmPurchaseOrderModify.dataGridPOParts["수량", i].Value.ToString() + "," + //frmPurchaseOrderModify.dataGridPOParts["금액", i].Value.ToString() + "," + ReStringMoney(frmPurchaseOrderModify.dataGridPOParts["금액", i].Value.ToString()) + "," + "0, 0," + frmPurchaseOrderModify.dataGridPOParts["수량", i].Value.ToString() + "," + //frmPurchaseOrderModify.dataGridPOParts["금액", i].Value.ToString()+")"); ReStringMoney(frmPurchaseOrderModify.dataGridPOParts["금액", i].Value.ToString()) + ")"); } string searchPoid_query = "SELECT Max([POID]) FROM [POs]"; int opId = ((MainForm)MdiParent).dbCtrl.GetPOid(searchPoid_query); POPartsTable(opId); } }