Beispiel #1
0
        /// <summary>
        /// Get file details from file name
        /// </summary>
        private void FileSelected(string fileName, string fullPathFileName)
        {
            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Extract File Path
            string pathOnly = fullPathFileName.Replace(fileName, "");

            txtFileName.Text = fileName;
            txtLocation.Text = pathOnly;

            string pathPartToCheck = "";

            if (pathOnly.Length >= templateFolder.Length)
            {
                pathPartToCheck = pathOnly.Substring(0, templateFolder.Length);
            }
            else
            {
                pathPartToCheck = pathOnly;
            }

            if (pathPartToCheck != templateFolder)
            {
                txtFileName.Text = "";
                txtLocation.Text = "";

                MessageBox.Show("Please select file from allowed folder. " + templateFolder);
                return;
            }

            // Get reference path
            //
            string refPath =
                Utils.getReferenceFilePathName(txtLocation.Text);

            txtLocation.Text = refPath;

            // This is the name of the document and not the file name
            // If it is already set for the client, there is no need
            // to replace it. The idea here is to suggest a name only
            // when the document is being created.
            //
            if (string.IsNullOrEmpty(txtName.Text))
            {
                txtName.Text = fileName.Substring(0, fileName.Length - 4);
            }

            txtFileName.Text = fileName;
        }
Beispiel #2
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            // Separate the file name from the path
            // Store both in separate fields
            //

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Show file dialog
            openFileDialog1.InitialDirectory = templateFolder;
            openFileDialog1.Filter           = "*.doc|*.xls|*.xlsx|*.docx";
            openFileDialog1.FileName         = "*";

            var file = openFileDialog1.ShowDialog();

            if (file == DialogResult.OK)
            {
                // Only File Name
                string fileName = openFileDialog1.SafeFileName;
                // Full Path including file name
                string fullPathFileName = openFileDialog1.FileName;

                // Extract File Path
                string pathOnly = fullPathFileName.Replace(fileName, "");

                txtFileName.Text = fileName;
                txtLocation.Text = pathOnly;

                string pathPartToCheck = "";

                if (pathOnly.Length >= templateFolder.Length)
                {
                    pathPartToCheck = pathOnly.Substring(0, templateFolder.Length);
                }
                else
                {
                    pathPartToCheck = pathOnly;
                }

                if (pathPartToCheck != templateFolder)
                {
                    txtFileName.Text = "";
                    txtLocation.Text = "";

                    MessageBox.Show("Please select file from allowed folder. " + templateFolder);
                    return;
                }

                // Get reference path
                //
                string refPath =
                    Utils.getReferenceFilePathName(txtLocation.Text);
                txtLocation.Text = refPath;

                // This is the name of the document and not the file name
                // If it is already set for the client, there is no need
                // to replace it. The idea here is to suggest a name only
                // when the document is being created.
                //
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    txtName.Text = openFileDialog1.SafeFileName.Substring(0,
                                                                          openFileDialog1.SafeFileName.Length - 4);
                }

                txtFileName.Text = openFileDialog1.SafeFileName;

                // 03.04.2013
                // CLA-00-00
                txtDisplayName.Text  = txtFileName.Text;
                txtCUID.Text         = txtFileName.Text.Substring(0, 6);
                cbxDocumentType.Text = "WORD";
                cbxRecordType.Text   = FCMConstant.RecordType.DOCUMENT;

                if (txtFileName.Text.Length >= 10)
                {
                    txtSimpleFileName.Text = txtFileName.Text.Substring(10, txtFileName.Text.Length - 10);
                }

                enableSave(sender, e);
            }
        }