コード例 #1
0
        protected override void BtnSave_Click(object sender, EventArgs e)
        {
            List <DepartmentVo> staffOldInfoList = SelectDao.SelectData <DepartmentVo>();
            List <DepartmentVo> changeList       = GenericUtil.GetChanges(departmentVoList, staffOldInfoList);
            int result = 0;

            if (!CheckParam(changeList))
            {
                return;
            }
            foreach (DepartmentVo vo in changeList)
            {
                if (SelectDao.IsRepeatedDepartmentId(vo.Id))
                {
                    //更新
                    result = UpdateDao.UpdateByID(vo);
                    if (result <= 0)
                    {
                        XtraMessageBox.Show(vo.Id + "更新失败!");
                        break;
                    }
                }
                else
                {
                    vo.CompanyId = SystemConst.companyId;
                    result       = InsertDao.InsertData(vo);
                    if (result <= 0)
                    {
                        XtraMessageBox.Show(vo.Id + "保存失败!");
                        break;
                    }
                }
            }
            EventBus.PublishEvent("UpdateDepartment");
            XtraMessageBox.Show("保存成功!");
        }