/// <summary>
        /// 点击查看附件事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Attachment_ButtonCustom2Click(object sender, EventArgs e)
        {
            DataGridViewMaskedTextBoxAdvCell cell = dgv.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                if (dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value != null)
                {
                    if (dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value.ToString() != string.Empty)
                    {
                        string remoteFilePath  = dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value.ToString();
                        string localFilePath   = Application.StartupPath + @"\temp" + remoteFilePath.Replace("/", @"\");
                        string localFileFolder = Path.GetDirectoryName(localFilePath);//获取待下载文件的下载后目录,如不存在目录则先创建
                        if (!Directory.Exists(localFileFolder))
                        {
                            Directory.CreateDirectory(localFileFolder);
                        }
                        FtpProcessForm fpf           = new FtpProcessForm(localFilePath, remoteFilePath, false);
                        var            downloadState = fpf.ShowDialog();
                        if (downloadState == DialogResult.OK)
                        {
                            System.Diagnostics.Process.Start("explorer.exe", localFilePath);//打开下载的文件
                        }
                        else
                        {
                            MessageBoxEx.Show("下载附件失败");
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Handles X2 "Part" ButtonCustomClick events
        /// </summary>
        /// <param name="sender">DataGridViewMaskedTextBoxAdvCell</param>
        /// <param name="e">EventArgs</param>
        void X2Part_ButtonCustomClick(object sender, EventArgs e)
        {
            DataGridViewMaskedTextBoxAdvCell cell =
                dataGridViewX2.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                DataGridViewMaskedTextBoxAdvEditingControl ec =
                    cell.DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;

                if (ec != null)
                {
                    string s = ec.Text;

                    if (s.Length > 0)
                    {
                        // Changed the ending text char and display some
                        // nonsense to the user for feedback

                        ec.Text = s.Substring(0, s.Length - 1) + "X";

                        MessageBox.Show("Inventory part " + s + " added to bug tracking database.",
                                        "Bug Track", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Handles X2 "Order" ButtonCustom clicks
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void X2Order_ButtonCustomClick(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Assign new Order Number?", "New Order Number",
                                              MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                              MessageBoxDefaultButton.Button1);

            if (dr == DialogResult.Yes)
            {
                DataGridViewMaskedTextBoxAdvCell cell =
                    dataGridViewX2.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

                if (cell != null)
                {
                    DataGridViewMaskedTextBoxAdvEditingControl ec =
                        cell.DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;

                    if (ec != null)
                    {
                        Random rand = new Random();

                        ec.Text = rand.Next(1, 9999).ToString();
                    }
                }
            }
        }
        //清除附件按钮
        private void Attachment_ButtonClearClick(object sender, CancelEventArgs e)
        {
            DataGridViewMaskedTextBoxAdvCell cell = dgv.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = string.Empty;
            }
        }
        /// <summary>
        /// 上传附件按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Attachment_ButtonCustomClick(object sender, EventArgs e)
        {
            DataGridViewMaskedTextBoxAdvCell cell = dgv.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                var         indicatorId = (int)dgv.Rows[cell.RowIndex].Cells["indicatorId"].Value;
                var         brandId     = (int)dgv.Rows[cell.RowIndex].Cells["brandId"].Value;
                var         modelId     = (int)dgv.Rows[cell.RowIndex].Cells["modelId"].Value;
                var         attachment  = dgv.Rows[cell.RowIndex].Cells["attachment"].Value.ToString();
                FtpListForm flf         = new AviationSafetyExperiment.FtpListForm(taskId, indicatorId, brandId, modelId, attachment);
                var         flfState    = flf.ShowDialog(this);
                if (flfState == DialogResult.OK)
                {
                    string remoteFiles = flf.remoteFiles;
                    DataGridViewMaskedTextBoxAdvEditingControl ec = cell.DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;
                    if (ec != null)
                    {
                        dgv.Rows[cell.RowIndex].Cells["attachment"].Value = remoteFiles;
                        if (ec.Text.Contains("补"))
                        {
                            ec.Text = (remoteFiles == string.Empty ? "" : remoteFiles.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Count() + "个") + "(补)";
                        }
                        else
                        {
                            ec.Text = remoteFiles == string.Empty ? "" : remoteFiles.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Count() + "个";
                        }
                    }
                }
                ////原逻辑,单文件上传
                //if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //{
                //    string localFilePath = ofd.FileName;
                //    string extension = Path.GetExtension(localFilePath);
                //    string remoteFilePath = RemoteFileNameMaker.makeName(taskId, indicatorId, brandId, modelId, extension);
                //    DataGridViewMaskedTextBoxAdvEditingControl ec = cell.DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;
                //    FtpProcessForm fpf = new FtpProcessForm(localFilePath, remoteFilePath, true);
                //    var uploadState = fpf.ShowDialog();
                //    if (uploadState == DialogResult.OK)
                //    {
                //        MessageBoxEx.Show("上传完成");
                //        if (ec != null)
                //        {
                //            dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = remoteFilePath;
                //            ec.Text = remoteFilePath;
                //        }
                //    }
                //    if (uploadState == DialogResult.No)
                //    {
                //        MessageBoxEx.Show("上传失败");
                //    }
                //}
            }
        }
예제 #6
0
        /// <summary>
        /// Handles X2 "Part" ButtonDropDown click events
        /// </summary>
        /// <param name="sender">DataGridViewMaskedTextBoxAdvCell</param>
        /// <param name="e">CancelEventArgs</param>
        void X2Part_ButtonDropDownClick(object sender, CancelEventArgs e)
        {
            DataGridViewMaskedTextBoxAdvCell cell =
                dataGridViewX2.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                DataGridViewMaskedTextBoxAdvEditingControl ec =
                    cell.DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;

                if (ec != null)
                {
                    cbNewParts.Checked         = ec.Text.EndsWith("N");
                    cbRefurbishedParts.Checked = ec.Text.EndsWith("R");
                }
            }
        }
        /// <summary>
        /// 点击打开补录窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AttachmentCount_ButtonCustom2Click(object sender, EventArgs e)
        {
            DataGridViewMaskedTextBoxAdvCell cell = dgv.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                if (dgv.Rows[cell.RowIndex].Cells["supplement"].Value != null)
                {
                    string         supplementJsonString = dgv.Rows[cell.RowIndex].Cells["supplement"].Value.ToString();
                    SupplementForm sf = new SupplementForm(supplementJsonString, taskId);
                    if (sf.ShowDialog(this) == DialogResult.OK)
                    {
                        dgv.Rows[cell.RowIndex].Cells["supplement"].Value = sf.getSupplimentJsonString();
                        if (dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value.ToString().Contains("补") == false)
                        {
                            dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = dgv.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value.ToString() + "(补)";
                        }
                    }
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Updates the X2 "Part" type from the users
        /// RadioButton selection
        /// </summary>
        /// <param name="t">Text to replace</param>
        private void X2Part_UpdatePartType(string t)
        {
            DataGridViewMaskedTextBoxAdvCell cell =
                dataGridViewX2.CurrentCell as DataGridViewMaskedTextBoxAdvCell;

            if (cell != null)
            {
                DataGridViewMaskedTextBoxAdvEditingControl ec =
                    cell.DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;

                if (ec != null)
                {
                    string s = ec.Text;

                    if (s.EndsWith(t) == false)
                    {
                        ec.Text = s.Substring(0, s.Length - 1) + t;
                    }
                }
            }
        }