Exemplo n.º 1
0
        /// <summary>
        /// 查找排序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchTimeToolStripButton1_Click(object sender, EventArgs e)
        {
            if (startTxtToolStripTextBox1.Text == "" || endTxtToolStripTextBox2.Text == "")
            {
                MessageBox.Show("查询开始时间和结束时间不能为空!");
                return;
            }

            expireDataSet.Tables[0].Rows.Clear();
            for (int i = 0; i < showDataSet.Tables[0].Rows.Count; i++)
            {
                DataRow  row = showDataSet.Tables[0].Rows[i];
                Contract con = ContractUtil.getContractFromRow(row);
                DateTime cTime;
                try
                {
                    cTime = DateTime.Parse(con.proExpireData);
                }
                catch { continue; }

                DateTime sTime = DateTime.Parse(startTxtToolStripTextBox1.Text);
                DateTime eTime = DateTime.Parse(endTxtToolStripTextBox2.Text);

                if ((cTime.CompareTo(sTime) >= 0) && (cTime.CompareTo(eTime) <= 0))
                {
                    DataRow nrow = expireDataSet.Tables[0].NewRow();
                    nrow = ContractUtil.getRowFromContract(nrow, con);
                    expireDataSet.Tables[0].Rows.Add(nrow);
                }
            }
            expireDataGridView1.Sort(expireDataGridView1.Columns[16], ListSortDirection.Descending);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 打开合同信息文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*string hz = "合同信息文件|*.db";
             * openFileDialog.Filter = hz;
             * openFileDialog.FilterIndex = 2;
             * openFileDialog.RestoreDirectory = true;
             * openFileDialog.FileName = "contracts.db";
             *
             * if (openFileDialog.ShowDialog() == DialogResult.OK)
             * {
             *  string fName = openFileDialog.FileName;
             */
            FileInfo file = new FileInfo(fName);

            if (!file.Exists)
            {
                return;
            }

            List <Contract> list = ExcelUtil.getContractsFromExcel(fName);

            showDataSet.Tables[0].Rows.Clear();
            foreach (Contract con in list)
            {
                DataRow row = showDataSet.Tables[0].NewRow();
                row = ContractUtil.getRowFromContract(row, con);
                showDataSet.Tables[0].Rows.Add(row);
            }
            statusLab.Text = "打开合同信息文件数据库:" + fName;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加一个协议,自动判断是否存在Id,若存在Id则不会添加
        /// </summary>
        /// <param name="con"></param>
        /// <returns></returns>
        public static string addContract(DataSet dataSet, Contract con)
        {
            DataRowCollection rows = dataSet.Tables[0].Rows;

            foreach (DataRow r in rows)
            {
                if (r["协议编号"].ToString() == con.proId)
                {
                    return("已包含协议编号为:" + con.proId + " 的协议。不能再添加!");
                }
            }
            DataRow row = dataSet.Tables[0].NewRow();

            row = ContractUtil.getRowFromContract(row, con);
            dataSet.Tables[0].Rows.Add(row);
            return("添加协议:" + con.proId + "  " + con.proName + "   成功!");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 弹出对话框,添加新合同
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addNewContractBtn_Click(object sender, EventArgs e)
        {
            ContractEditForm cef = new ContractEditForm("add", "添加新合同", "确定添加", null);

            cef.ShowDialog();

            if (cef.IsCanel)
            {
                cef.Dispose();
                return;
            }

            Contract con = cef.Contract;

            if (con != null)
            {
                if (con.fileName != "")
                {
                    FileInfo f = new FileInfo(con.fileName);
                    if (new FileInfo(Contract.relativePath + f.Name).Exists)
                    {
                        statusLab.Text = "已经存在文件名为:" + Contract.relativePath + f.Name + " 的文件,请更改文件名再添加";
                        MessageBox.Show(statusLab.Text);
                        return;
                    }
                    f.CopyTo(Contract.relativePath + f.Name);
                    con.fileName = f.Name;
                }

                DataRow row = showDataSet.Tables[0].NewRow();
                row = ContractUtil.getRowFromContract(row, con);

                showDataSet.Tables[0].Rows.Add(row);

                //自动保存数据
                saveToolStripMenuItem_Click(sender, e);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 搜索按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchStripBtn_Click(object sender, EventArgs e)
        {
            string clas    = searchCombo.Text;
            string content = searchTxt.Text;

            if (clas == "" || content == "")
            {
                MessageBox.Show("搜索类型和搜索内容不能为空,请输入完整后再搜索!");
                return;
            }
            clas = clas.Replace("按", "").Replace("查找", "");

            List <DataRow> resRows = ContractUtil.findContract(showDataSet, clas, content);

            searchDataSet.Tables[0].Rows.Clear();
            foreach (DataRow row in resRows)
            {
                Contract con  = ContractUtil.getContractFromRow(row);
                DataRow  nrow = searchDataSet.Tables[0].NewRow();
                nrow = ContractUtil.getRowFromContract(nrow, con);
                searchDataSet.Tables[0].Rows.Add(nrow);
            }
            statusLab.Text = ContractUtil.statusLab;
        }