private void addButton_Click(object sender, EventArgs e) { addAttchmntDiag nwDiag = new addAttchmntDiag(); nwDiag.attchmntIDTextBox.Text = "-1"; nwDiag.batchID = this.prmKeyID; nwDiag.isPrchSng = this.isPrchSng; nwDiag.attchCtgry = this.attchCtgry; DialogResult dgrs = nwDiag.ShowDialog(); if (dgrs == DialogResult.OK) { string tblNm = ""; string pkNm = ""; if (Global.mnFrm.cmCde.myComputer.FileSystem.FileExists( nwDiag.fileNmTextBox.Text) == true) { string extnsn = Global.mnFrm.cmCde.myComputer.FileSystem.GetFileInfo(nwDiag.fileNmTextBox.Text).Extension; if (this.attchCtgry == 3) { tblNm = "accb.accb_pybl_doc_attchmnts"; pkNm = "doc_hdr_id"; Global.createAttachment(this.prmKeyID, nwDiag.attchmntNmTextBox.Text, "", tblNm, pkNm); long attchID = Global.getAttchmntID(nwDiag.attchmntNmTextBox.Text, this.prmKeyID, tblNm, pkNm); 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 if (this.isPrchSng == false) { Global.createAttachment(this.prmKeyID, nwDiag.attchmntNmTextBox.Text, ""); long attchID = Global.getAttchmntID(nwDiag.attchmntNmTextBox.Text, this.prmKeyID); if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getSalesImgsDrctry(), nwDiag.fileNmTextBox.Text) == true) { Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn); } } else { Global.createP_Attachment(this.prmKeyID, nwDiag.attchmntNmTextBox.Text, ""); long attchID = Global.getP_AttchmntID(nwDiag.attchmntNmTextBox.Text, this.prmKeyID); if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getPrchsImgsDrctry(), nwDiag.fileNmTextBox.Text) == true) { Global.updateP_Attachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn); } } } } 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 = ""; if (this.attchCtgry == 3) { oldFile = this.fldrNm + @"\" + this.attchmntsListView.SelectedItems[0].SubItems[2].Text; } else if (this.isPrchSng == false) { oldFile = Global.mnFrm.cmCde.getSalesImgsDrctry() + @"\" + this.attchmntsListView.SelectedItems[0].SubItems[2].Text; } else { oldFile = Global.mnFrm.cmCde.getPrchsImgsDrctry() + @"\" + this.attchmntsListView.SelectedItems[0].SubItems[2].Text; } string oldExtn = this.attchmntsListView.SelectedItems[0].SubItems[2].Text; addAttchmntDiag nwDiag = new addAttchmntDiag(); nwDiag.attchCtgry = this.attchCtgry; nwDiag.attchmntIDTextBox.Text = this.attchmntsListView.SelectedItems[0].SubItems[3].Text; nwDiag.batchID = this.prmKeyID; nwDiag.isPrchSng = this.isPrchSng; nwDiag.attchmntNmTextBox.Text = this.attchmntsListView.SelectedItems[0].SubItems[1].Text; nwDiag.fileNmTextBox.Text = oldFile; DialogResult dgrs = nwDiag.ShowDialog(); if (dgrs == DialogResult.OK) { if (Global.mnFrm.cmCde.myComputer.FileSystem.FileExists( nwDiag.fileNmTextBox.Text) == true) { //Global.createAttachment(this.batchid, nwDiag.attchmntNmTextBox.Text, ""); string tblNm = ""; string pkNm = ""; long attchID = long.Parse(nwDiag.attchmntIDTextBox.Text); string extnsn = Global.mnFrm.cmCde.myComputer.FileSystem.GetFileInfo(nwDiag.fileNmTextBox.Text).Extension; if (nwDiag.fileNmTextBox.Text != oldFile) { if (this.attchCtgry == 3) { tblNm = "accb.accb_pybl_doc_attchmnts"; pkNm = "doc_hdr_id"; 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 if (this.isPrchSng == false) { if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getSalesImgsDrctry(), nwDiag.fileNmTextBox.Text) == true) { Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn); } } else { if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getPrchsImgsDrctry(), nwDiag.fileNmTextBox.Text) == true) { Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn); } } } else { if (this.attchCtgry == 3) { tblNm = "accb.accb_pybl_doc_attchmnts"; pkNm = "doc_hdr_id"; Global.mnFrm.cmCde.upldImgsFTP(this.fldrTyp, this.fldrNm, oldExtn); Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, oldExtn, tblNm, pkNm); } else { Global.updateAttachment(attchID, this.prmKeyID, nwDiag.attchmntNmTextBox.Text, oldExtn); } } } } this.gotoButton_Click(this.gotoButton, e); }