private void addButton_Click(object sender, EventArgs e) { addAttchmntDiag nwDiag = new addAttchmntDiag(); nwDiag.attchmntIDTextBox.Text = "-1"; nwDiag.batchID = this.prmKeyID; nwDiag.attchCtgry = this.attchCtgry; DialogResult dgrs = nwDiag.ShowDialog(); if (dgrs == DialogResult.OK) { if (Global.mnFrm.cmCde.myComputer.FileSystem.FileExists( nwDiag.fileNmTextBox.Text) == true) { string tblNm = ""; string pkNm = ""; if (this.attchCtgry == 1) { tblNm = "accb.accb_batch_trns_attchmnts"; pkNm = "batch_id"; } else if (this.attchCtgry == 2) { tblNm = "accb.accb_asset_doc_attchmnts"; pkNm = "asset_id"; } else if (this.attchCtgry == 3) { tblNm = "accb.accb_pybl_doc_attchmnts"; pkNm = "doc_hdr_id"; } else if (this.attchCtgry == 4) { tblNm = "accb.accb_rcvbl_doc_attchmnts"; pkNm = "doc_hdr_id"; } else if (this.attchCtgry == 5) { tblNm = "accb.accb_ptycsh_doc_attchmnts"; pkNm = "doc_hdr_id"; } else { tblNm = "accb.accb_firms_doc_attchmnts"; pkNm = "firms_id"; } Global.createAttachment(this.prmKeyID, nwDiag.attchmntNmTextBox.Text, "", tblNm, pkNm); long attchID = Global.getAttchmntID(nwDiag.attchmntNmTextBox.Text, this.prmKeyID, tblNm, pkNm); string extnsn = Global.mnFrm.cmCde.myComputer.FileSystem.GetFileInfo(nwDiag.fileNmTextBox.Text).Extension; if (Global.mnFrm.cmCde.copyAFile(attchID, this.fldrNm, nwDiag.fileNmTextBox.Text) == true) { Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn, tblNm, pkNm); } } } this.gotoButton_Click(this.gotoButton, e); }
private void editButton_Click(object sender, EventArgs e) { if (this.attchmntsListView.SelectedItems.Count <= 0) { Global.mnFrm.cmCde.showMsg("Please select an Item First!", 0); return; } string oldFile = this.fldrNm + @"\" + this.attchmntsListView.SelectedItems[0].SubItems[2].Text; string oldExtn = this.attchmntsListView.SelectedItems[0].SubItems[2].Text; addAttchmntDiag nwDiag = new addAttchmntDiag(); nwDiag.attchmntIDTextBox.Text = this.attchmntsListView.SelectedItems[0].SubItems[3].Text; nwDiag.batchID = this.prmKeyID; nwDiag.attchmntNmTextBox.Text = this.attchmntsListView.SelectedItems[0].SubItems[1].Text; nwDiag.fileNmTextBox.Text = oldFile; nwDiag.attchCtgry = this.attchCtgry; DialogResult dgrs = nwDiag.ShowDialog(); if (dgrs == DialogResult.OK) { if (Global.mnFrm.cmCde.myComputer.FileSystem.FileExists( nwDiag.fileNmTextBox.Text) == true) { string tblNm = ""; string pkNm = ""; if (this.attchCtgry == 1) { tblNm = "accb.accb_batch_trns_attchmnts"; pkNm = "batch_id"; } else if (this.attchCtgry == 2) { tblNm = "accb.accb_asset_doc_attchmnts"; pkNm = "asset_id"; } else if (this.attchCtgry == 3) { tblNm = "accb.accb_pybl_doc_attchmnts"; pkNm = "doc_hdr_id"; } else if (this.attchCtgry == 4) { tblNm = "accb.accb_rcvbl_doc_attchmnts"; pkNm = "doc_hdr_id"; } else if (this.attchCtgry == 5) { tblNm = "accb.accb_ptycsh_doc_attchmnts"; pkNm = "doc_hdr_id"; } else { tblNm = "accb.accb_firms_doc_attchmnts"; pkNm = "firms_id"; } //Global.createAttachment(this.batchid, nwDiag.attchmntNmTextBox.Text, ""); long attchID = long.Parse(nwDiag.attchmntIDTextBox.Text); if (nwDiag.fileNmTextBox.Text != oldFile) { string extnsn = Global.mnFrm.cmCde.myComputer.FileSystem.GetFileInfo(nwDiag.fileNmTextBox.Text).Extension; if (Global.mnFrm.cmCde.copyAFile(attchID, this.fldrNm, nwDiag.fileNmTextBox.Text) == true) { Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn, tblNm, pkNm); } } else { Global.mnFrm.cmCde.upldImgsFTP(this.fldrTyp, this.fldrNm, oldExtn); Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, oldExtn, tblNm, pkNm); } } } this.gotoButton_Click(this.gotoButton, e); }