private void addButton_Click(object sender, EventArgs e)
        {
            addAttchmntDiag nwDiag = new addAttchmntDiag();

            nwDiag.attchmntIDTextBox.Text = "-1";
            nwDiag.batchID   = this.batchid;
            nwDiag.isPrchSng = this.isPrchSng;
            DialogResult dgrs = nwDiag.ShowDialog();

            if (dgrs == DialogResult.OK)
            {
                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.isPrchSng == false)
                    {
                        Global.createAttachment(this.batchid, nwDiag.attchmntNmTextBox.Text, "");
                        long attchID = Global.getAttchmntID(nwDiag.attchmntNmTextBox.Text, this.batchid);
                        if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getSalesImgsDrctry(), nwDiag.fileNmTextBox.Text) == true)
                        {
                            Global.updateAttachment(attchID, this.batchid, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn);
                        }
                    }
                    else
                    {
                        Global.createP_Attachment(this.batchid, nwDiag.attchmntNmTextBox.Text, "");
                        long attchID = Global.getP_AttchmntID(nwDiag.attchmntNmTextBox.Text, this.batchid);
                        if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getPrchsImgsDrctry(), nwDiag.fileNmTextBox.Text) == true)
                        {
                            Global.updateP_Attachment(attchID, this.batchid, 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.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.attchmntIDTextBox.Text = this.attchmntsListView.SelectedItems[0].SubItems[3].Text;
            nwDiag.batchID   = this.batchid;
            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, "");
                    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 (this.isPrchSng == false)
                        {
                            if (Global.mnFrm.cmCde.copyAFile(attchID, Global.mnFrm.cmCde.getSalesImgsDrctry(), nwDiag.fileNmTextBox.Text) == true)
                            {
                                Global.updateAttachment(attchID, this.batchid, 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.batchid, nwDiag.attchmntNmTextBox.Text, attchID.ToString() + extnsn);
                            }
                        }
                    }
                    else
                    {
                        Global.updateAttachment(attchID, this.batchid, nwDiag.attchmntNmTextBox.Text, oldExtn);
                    }
                }
            }
            this.gotoButton_Click(this.gotoButton, e);
        }