コード例 #1
0
        /// <summary>
        /// 按钮启用自动校验(EnableAutoValidate属性为True)后事件处理程序,根据校验结果看是否更新数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_AfterAutoValidate(object sender, AutoValidateResultEventArgs e)
        {
            //如果校验通过
            if (e.Result)
            {
                //绑定界面数据&设置标题
                switch (this.formState)
                {
                case FormState.Edit:
                    try
                    {
                        //收集数据
                        this.CollectData();

                        //更新
                        this.customerService.Update(this.basicRow);
                        MsgBoxUtility.ShowTips("修改成功!");
                        //执行更新成功事件
                        if (this.UpdateSucceed != null)
                        {
                            this.UpdateSucceed(this, new TEventArgs <CustomerDataSet.BasicInfoRow>(this.basicRow));
                        }
                    }
                    catch (Exception ex)
                    {
                        MsgBoxUtility.ShowError("修改失败:" + ex.Message);
                    }
                    break;

                case FormState.Add:
                    try
                    {
                        //收集数据
                        this.CollectData();
                        //新增
                        this.customerService.Add(this.basicRow);
                        MsgBoxUtility.ShowTips("新增成功!");
                        //执行添加成功事件
                        if (this.AddSucceed != null)
                        {
                            this.AddSucceed(this, new TEventArgs <CustomerDataSet.BasicInfoRow>(this.basicRow));
                        }
                    }
                    catch (Exception ex)
                    {
                        MsgBoxUtility.ShowError("新增失败:" + ex.Message);
                    }
                    break;

                default:
                    break;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 删除按钮单击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolBtnDelete_Click(object sender, EventArgs e)
        {
            CustomerDataSet.BasicInfoRow basicRow = GetSelectedRow();
            if (basicRow == null)
            {
                MsgBoxUtility.ShowError("请选择一条记录!");
                return;
            }
            try
            {
                this.CustomerService.Delete(basicRow.CustomerID);

                // 记住分页信息的查询客户信息操作然后绑定客户信息
                this.RemeberPagerQueryAndBind();
            }
            catch (Exception ex)
            {
                MsgBoxUtility.ShowTips(ex.Message);
            }
        }