Example #1
0
        protected override void BtnSave_Click(object sender, EventArgs e)
        {
            List <StaffLevelVo> staffOldInfoList = SelectDao.SelectData <StaffLevelVo>();
            List <StaffLevelVo> changeList       = GenericUtil.GetChanges(staffLevelList, staffOldInfoList);
            int result = 0;

            if (!CheckParam(changeList))
            {
                return;
            }
            foreach (StaffLevelVo vo in changeList)
            {
                if (SelectDao.IsRepeatedLevelId(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("UpdateLevel");
            EventBus.PublishEvent("UpdateLevelCard");
            XtraMessageBox.Show("保存成功!");
        }