Пример #1
0
        private void Delete()
        {
            FrmProcessing          frmP       = new FrmProcessing();
            string                 msg        = string.Empty;
            List <DataGridViewRow> deleteRows = new List <DataGridViewRow>();
            Action action = delegate()
            {
                try
                {
                    int success           = 0;
                    int fail              = 0;
                    WaitingCommandBLL bll = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect);
                    foreach (DataGridViewRow item in this.GridView.SelectedRows)
                    {
                        if (item.Tag is WaitingCommandInfo)
                        {
                            WaitingCommandInfo info = item.Tag as WaitingCommandInfo;
                            BusinessModel.Enum.WaitingCommandStatus oldStatus = info.Status;
                            info.Status = BusinessModel.Enum.WaitingCommandStatus.Waiting;
                            if (bll.Delete(info).Result == ResultCode.Successful)
                            {
                                success++;
                                deleteRows.Add(item);
                            }
                            else
                            {
                                fail++;
                            }
                        }
                        msg = string.Format(Resource1.Form_Total + ":{0}/{1} " + Resource1.Form_Success + ":{2} " + Resource1.Form_Fail + ":{3}", success + fail, this.GridView.SelectedRows.Count, success, fail);
                        frmP.ShowProgress(msg, (success + fail) / this.GridView.SelectedRows.Count);
                    }
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception ex)
                {
                    frmP.ShowProgress(ex.Message, 1);
                }
            };
            Thread t = new Thread(new ThreadStart(action));

            t.CurrentCulture   = Thread.CurrentThread.CurrentCulture;
            t.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
            t.Start();
            if (frmP.ShowDialog() != DialogResult.OK)
            {
                t.Abort();
            }
            if (!string.IsNullOrEmpty(msg))
            {
                foreach (DataGridViewRow item in deleteRows)
                {
                    this.GridView.Rows.Remove(item);
                }
                MessageBox.Show(msg);
            }
        }
Пример #2
0
        public static void ShowProcessing(string msg, Form owner, ParameterizedThreadStart work, object workArg = null)
        {
            FrmProcessing processingForm = new FrmProcessing(msg);
            dynamic       expObj         = new ExpandoObject();

            expObj.Form    = processingForm;
            expObj.WorkArg = workArg;
            processingForm.SetWorkAction(work, expObj);
            processingForm.ShowDialog(owner);
            if (processingForm.WorkException != null)
            {
                throw processingForm.WorkException;
            }
        }
Пример #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            this.UltraGrid1.DataSource = null;

            Globals.SearchType = this.rbBinarySearch.Checked ? "Byte" : "Filename";

            if (string.IsNullOrEmpty(this.inPath.Text.Trim()))
            {
                MessageBox.Show("Please select a start location.", "Invalid start location", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (System.IO.Directory.Exists(this.inPath.Text.Trim()) == false)
            {
                MessageBox.Show("It appears that the start location does not exist. Please select another location and try again.", "Bad Start Location", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (this.BackgroundWorker1.IsBusy == false)
            {
                GetAllCheckedBoxes();

                if (this.chkItems.Count > 0)
                {
                    Globals.dtFiles.Clear();
                    FrmProcessing frm = new FrmProcessing(this.inPath.Text.Trim(), this.chkSubDirectories.Checked, this.chkItems);
                    frm.LoadData += LoadData;
                    frm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please select file types to search for.", "Missing File Types", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
        }