コード例 #1
0
        private void btn添加_Click(object sender, EventArgs e)
        {
            OtherMoneyData item = new OtherMoneyData();

            item.年 = Convert.ToInt32(year.Value);
            item.月 = Convert.ToInt32(month.Text);

            currRows.Add(item);
            gridControl1.RefreshDataSource();
            gridView1.FocusedRowHandle = gridView1.RowCount - 1;
        }
コード例 #2
0
        private void btn删除_Click(object sender, EventArgs e)
        {
            ColumnView colView = (ColumnView)gridControl1.MainView;

            if (colView != null)
            {
                if (MessageBox.Show("确实删除当前记录吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)
                {
                    OtherMoneyData currentItem = (OtherMoneyData)colView.GetFocusedRow();
                    currRows.Remove(currentItem);
                    OtherMoney.GetOtherMoney(currentItem.员工编号, currentItem.年, currentItem.月, currentItem.类型, currentItem.项目名称);
                    currentItem = null;
                    gridControl1.RefreshDataSource();
                    MessageBox.Show("删除成功。", "删除提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #3
0
        private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            OtherMoneyData row = gridView1.GetRow(e.RowHandle) as OtherMoneyData;

            if (row != null)
            {
                if (e.Column.FieldName == "员工编号")
                {
                    PersonalInfo pInfo = PersonalInfo.Get(row.员工编号);
                    if (pInfo == null)
                    {
                        MessageBox.Show("找不到指定编号的员工");
                    }
                    else
                    {
                        row.姓名 = pInfo.姓名;
                        gridControl1.RefreshDataSource();
                    }
                }
            }
        }
コード例 #4
0
        private void btn导入_Click(object sender, EventArgs e)
        {
            if (prevMonth.Year != Convert.ToInt32(year.Value) || prevMonth.Month != Convert.ToInt32(month.Text))
            {
                if (MessageBox.Show("您导入的不是上月的数据,您要继续吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) != DialogResult.Yes)
                {
                    return;
                }
            }

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                CreateWaitDialog("正在导入数据...", "请稍等");

                Workbook  workbook = new Workbook(openFileDialog1.FileName);
                Worksheet sheet    = workbook.Worksheets[0];
                Cells     cells    = sheet.Cells;

                currRows.Clear();

                int        totalCount = 0;
                List <Row> errorRows  = new List <Row>();
                foreach (Row row in sheet.Cells.Rows)
                {
                    try
                    {
                        OtherMoneyData item = new OtherMoneyData();

                        item.年 = Convert.ToInt32(year.Value);
                        item.月 = Convert.ToInt32(month.Text);

                        item.员工编号 = (string)cells[row.Index, 0].StringValue;
                        item.姓名   = (string)cells[row.Index, 1].StringValue;
                        item.类型   = (string)cells[row.Index, 2].StringValue;
                        item.项目名称 = (string)cells[row.Index, 3].StringValue;
                        item.金额   = Convert.ToDecimal(cells[row.Index, 4].Value);

                        currRows.Add(item);
                        totalCount++;
                    }
                    catch
                    {
                        errorRows.Add(row);
                    }
                }
                CloseWaitDialog();
                gridControl1.RefreshDataSource();

                string errMsg = "";
                foreach (Row row in errorRows)
                {
                    if (errMsg != "")
                    {
                        errMsg += "、";
                    }
                    errMsg += (row.Index + 1).ToString();
                }
                string msg = "导入完毕," + totalCount + " 成功, " + errorRows.Count + " 失败。\n\n失败行:" + errMsg;
                MessageBox.Show(msg);
            }
        }