private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            PersonBorrowInput row = gridView1.GetRow(e.RowHandle) as PersonBorrowInput;

            if (row != null)
            {
                if (e.Column.FieldName == "员工编号")
                {
                    EmployeeInfo pInfo = EmployeeInfo.GetEmployeeInfo(row.员工编号);
                    if (pInfo == null)
                    {
                        throw new Exception("找不到指定编号的员工");
                    }
                    else
                    {
                        if (AccessController.CheckPayGroup(pInfo.薪资组))
                        {
                            row.姓名 = pInfo.姓名;
                            gridControl1.RefreshDataSource();
                        }
                        else
                        {
                            throw new Exception("您没有权限录入这个员工的报销标准");
                        }
                    }
                }
                row.GetModifiyFields();
            }
        }
        private void btn保存_Click(object sender, EventArgs e)
        {
            ColumnView colView = (ColumnView)gridControl1.MainView;

            if (colView != null)
            {
                PersonBorrowInput currentItem = (PersonBorrowInput)colView.GetFocusedRow();
                if (currentItem != null)
                {
                    currentItem.录入人  = AccessController.CurrentUser.姓名;
                    currentItem.录入时间 = DateTime.Now;
                    currentItem.Save();
                }
                //遍历
                foreach (PersonBorrowInput row in currInputRows)
                {
                    row.UpdateCompareResult();
                    //如果完全相同,转为正式
                    if (row.金额 > 0 && row.内容不同的字段.Count == 0 && row.另一人已录入)
                    {
                        BecomeEffective(row);
                    }
                }
                MessageBox.Show("保存成功!");
                LoadData();
            }
            MyHelper.WriteLog(LogType.信息, "修改员工报销记录", null);
        }
        private void gridView1_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            PersonBorrowInput row = gridView1.GetRow(e.RowHandle) as PersonBorrowInput;

            if (row != null)
            {
            }
        }
 protected void LoadData()
 {
     //清除原来的数据
     currInputRows           = PersonBorrowInput.GetEditingRows(this.是验证录入);
     currInputRows           = currInputRows.FindAll(a => a.员工信息 != null && AccessController.CheckPayGroup(a.员工信息.薪资组));
     currInputRows           = currInputRows.OrderBy(a => a.编号).ToList();
     gridControl1.DataSource = currInputRows;
     gridControl1.RefreshDataSource();
 }
        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            PersonBorrowInput row = gridView1.GetRow(e.PrevFocusedRowHandle) as PersonBorrowInput;

            if (row != null)
            {
                row.GetModifiyFields();
            }
        }
        private void OnEmployeeSelectd(object sender, EmployeeInfo emp)
        {
            PersonBorrowInput item = new PersonBorrowInput();

            item.生效日期  = MyHelper.GetPrevMonth1Day();
            item.是验证录入 = this.是验证录入;
            item.员工编号  = emp.员工编号;
            item.姓名    = emp.姓名;
            item.录入人   = AccessController.CurrentUser.姓名;
            item.录入时间  = DateTime.Now;
            currInputRows.Add(item);
            gridControl1.RefreshDataSource();
            gridView1.FocusedRowHandle = gridView1.RowCount - 1;

            MyHelper.WriteLog(LogType.信息, "新增员工借款记录录入", item.ToString <PersonBorrowInput>());
        }
        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)
                {
                    PersonBorrowInput currentItem = (PersonBorrowInput)colView.GetFocusedRow();
                    currInputRows.Remove(currentItem);
                    MyHelper.WriteLog(LogType.信息, "删除员工报销标准录入记录", currentItem.ToString <PersonBorrowInput>());
                    gridControl1.RefreshDataSource();
                    currentItem.Delete();
                    MessageBox.Show("删除成功。", "删除提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void gridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
        {
            e.Appearance.ForeColor = Color.Black;
            e.Appearance.BackColor = Color.Transparent;

            PersonBorrowInput row = gridView1.GetRow(e.RowHandle) as PersonBorrowInput;

            if (row != null)
            {
                foreach (ModifyField field in row.内容不同的字段)
                {
                    if (field.称 == e.Column.FieldName)
                    {
                        e.Appearance.ForeColor = Color.Yellow;
                        e.Appearance.BackColor = Color.Red;
                    }
                }
            }
        }
        private void BecomeEffective(PersonBorrowInput input)
        {
            PersonBorrow m     = new PersonBorrow();
            PersonBorrow found = PersonBorrow.GetPersonBorrow(input.员工编号, input.项目, input.生效日期);

            if (found != null)
            {
                m = found;
            }

            input.CopyWatchMember(m);
            m.效 = true;

            PersonBorrowInput anotherInput = input.另一人录入的记录 as PersonBorrowInput;

            m.录入人  = input.录入人 + " " + anotherInput.录入人;
            m.录入时间 = input.生效时间;

            m.Save();
        }