/// <summary>
        /// 删除我的查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteSearch_Click(object sender, EventArgs e)
        {
            if (cmbSearchName.Text == "")
            {
                MessageDialog.ShowPromptMessage("不允许删除空查询");
                return;
            }
            else
            {
                if (MessageDialog.ShowEnquiryMessage("您真的要删除我的查询“" + cmbSearchName.Text + "”?") == DialogResult.Yes)
                {
                    string error = null;

                    if (!m_searchParamsServer.DeleteParam(m_parentTitle, Business, cmbSearchName.Text, out error))
                    {
                        MessageDialog.ShowErrorMessage(error);
                    }
                    else
                    {
                        MessageDialog.ShowPromptMessage("操作成功");

                        cmbSearchName.Items.Remove(cmbSearchName.Text);

                        if (cmbSearchName.Items.Count <= 1)
                        {
                            panelSelectSearch.Visible = false;
                        }
                    }
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                CustomDataGridView dgv     = GetDataGridView(tabControl1.SelectedTab);
                string             tempStr = dgv.CurrentRow.Cells["业务编号"].Value.ToString();

                if (MessageDialog.ShowEnquiryMessage("您确定要删除【" + tempStr + "】号业务单据吗?") == DialogResult.Yes)
                {
                    _BusinessService.DeleteInfo(tempStr);
                    MessageDialog.ShowPromptMessage("删除成功");
                    m_billMessageServer.DestroyMessage(tempStr);
                }

                RefreshData(tabControl1.SelectedTab);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
        /// <summary>
        /// 数据定位
        /// </summary>
        public void LocalizeData()
        {
            if (m_dataComponent.Rows.Count == 0)
            {
                return;
            }

            string findData = txtContext.Text.ToUpper();

            if (!OnlyLocalize)
            {
                // 非仅定位模式(即过滤模式)
                m_dataComponent.ClearSelection();

                CurrencyManager cm = null;

                if (m_dataComponent.DataSource != null)
                {
                    cm = (CurrencyManager)BindingContext[m_dataComponent.DataSource];

                    cm.SuspendBinding(); // 挂起数据绑定
                }

                for (int i = 0; i < m_dataComponent.Rows.Count; i++)
                {
                    if (txtContext.Text.Length == 0)
                    {
                        m_dataComponent.Rows[i].Visible = true;
                    }
                    else
                    {
                        if (m_dataComponent.Rows[i].Cells[cmbFindItem.Text].Value == null ||
                            !m_dataComponent.Rows[i].Cells[cmbFindItem.Text].Value.ToString().ToUpper().Contains(findData))
                        {
                            m_dataComponent.Rows[i].Visible = false;
                        }
                        else
                        {
                            m_dataComponent.Rows[i].Visible = true;
                        }
                    }
                }

                if (m_dataComponent.DataSource != null)
                {
                    cm.ResumeBinding(); // 恢复数据绑定
                }
            }
            else
            {
                // 仅定位模式
                bool find = false;

                if (m_startIndex >= m_dataComponent.Rows.Count)
                {
                    m_startIndex = 0;
                }

                if (m_dataComponent.Rows[m_startIndex].Selected)
                {
                    m_startIndex++;

                    if (m_startIndex >= m_dataComponent.Rows.Count)
                    {
                        m_startIndex = 0;
                    }
                }

                for (int i = m_startIndex; i < m_dataComponent.Rows.Count; i++)
                {
                    if (m_dataComponent.Rows[i].Cells[cmbFindItem.Text].Value != null &&
                        m_dataComponent.Rows[i].Cells[cmbFindItem.Text].Value.ToString().ToUpper().Contains(findData))
                    {
                        m_dataComponent.ClearSelection();

                        if (m_dataComponent.Rows[i].Visible)
                        {
                            m_dataComponent.FirstDisplayedScrollingRowIndex = i;
                            m_dataComponent.Rows[i].Selected = true;
                            m_dataComponent.CurrentCell      = m_dataComponent.Rows[i].Cells[cmbFindItem.Text];

                            m_startIndex = i + 1;
                            find         = true;
                        }

                        break;
                    }
                }

                // 从头开始查找
                if (!find)
                {
                    m_startIndex = 0;

                    if (DialogResult.Yes == MessageDialog.ShowEnquiryMessage("已经检索到记录尾部,没有找到符合条件的信息,是否从头开始?"))
                    {
                        m_dataComponent.ClearSelection();
                        LocalizeData();
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// 打印
        /// </summary>
        private void Print()
        {
            if (m_streams == null || m_streams.Count == 0)
            {
                return;
            }

            PrintDocument printDoc = new PrintDocument();

            if (m_showPrintDialog)
            {
                PrintDialog printDialog = new PrintDialog();

                printDialog.Document               = printDoc;
                printDialog.AllowPrintToFile       = false;
                printDialog.AllowCurrentPage       = false;
                printDialog.AllowSelection         = false;
                printDialog.AllowSomePages         = false;
                printDialog.PrinterSettings.Copies = 1;

                if (printDialog.ShowDialog() != DialogResult.OK)
                {
                    if (MessageDialog.ShowEnquiryMessage("您是否确定取消当前打印?") == DialogResult.Yes)
                    {
                        return;
                    }
                }

                printDialog.PrinterSettings.Copies = 1;
            }


            #region 页面设置
            PageSetupDialog pageDialog = new PageSetupDialog();

            pageDialog.Document = printDoc;
            pageDialog.PageSettings.PaperSize = new PaperSize("Custom", (int)(100 * m_pageWidth / 2.54 + 0.5),
                                                              (int)(100 * m_pageHeight / 2.54 + 0.5));

            #region 设置为横向打印

            //if (m_pageWidth < m_pageHeight)
            //{
            //    pageDialog.PageSettings.Landscape = true;
            //}

            #endregion

            printDoc.DefaultPageSettings = pageDialog.PageSettings;

            #endregion
            // 指定打印机
            //printDoc.PrinterSettings.PrinterName = printDocument1.PrinterSettings.PrinterName;

            if (!printDoc.PrinterSettings.IsValid)
            {
                string msg = String.Format("Can't find printer \"{0}\".", "默认打印机!");
                MessageBox.Show(msg, "找不到默认打印机");
                return;
            }

            #region 判断打印机是否虚拟打印机,不允许打印到P虚拟设备(如打印到PDF文件),否则可能出现多次打印等单据不可控现象

            //string error = null;

            //if (VirtualPrint.IsVirtualPrint(printDoc.PrinterSettings.PrinterName, out error))
            //{
            //    MessageDialog.ShowPromptMessage(error);
            //    return;
            //}

            #endregion

            printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
            printDoc.Print();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_blIsCheckBox)
            {
                foreach (DataRow dr in ((DataView)dataGridView1.DataSource).Table.Rows)
                {
                    if (Convert.ToBoolean(dr["选"]))
                    {
                        DataRow drTemp = m_dtResult.NewRow();

                        foreach (DataGridViewColumn dgvc in dataGridView1.Columns)
                        {
                            if (m_dtResult.Columns.Contains(dgvc.Name))
                            {
                                drTemp[dgvc.Name] = dr[dgvc.Name];
                            }
                        }

                        m_dtResult.Rows.Add(drTemp);
                    }
                }

                if (m_dtResult == null || m_dtResult.Rows.Count == 0)
                {
                    if (MessageDialog.ShowEnquiryMessage("您未勾选任何项/记录,是否继续?") == DialogResult.No)
                    {
                        return;
                    }
                }

                if (OnFormDataTableCheck != null)
                {
                    if (OnFormDataTableCheck(m_dtResult) == DialogResult.OK)
                    {
                        this.Close();
                    }
                    else
                    {
                        return;
                    }
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                if (dataGridView1.CurrentRow == null)
                {
                    return;
                }

                DataRow dr = m_dtResult.NewRow();

                foreach (DataGridViewColumn dgvc in dataGridView1.Columns)
                {
                    if (m_dtResult.Columns.Contains(dgvc.Name))
                    {
                        dr[dgvc.Name] = dataGridView1.CurrentRow.Cells[dgvc.Name].Value;
                    }
                }

                m_dtResult.Rows.Add(dr);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }