Exemplo n.º 1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            List <CardVo> staffOldInfoList = SelectDao.SelectData <CardVo>();
            List <CardVo> changeList       = GenericUtil.GetChanges(cardVoList, staffOldInfoList);
            int           result           = 0;

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