/// <summary>
 /// 保存
 /// </summary>
 /// <param name="frmbase"></param>
 protected override void SetSaveDataProc(frmBaseToolEntryXC frmbase)
 {
     try
     {
         base.SetSaveDataProc(frmbase);
     }
     catch (Exception ex)
     {
         log.Error(ex);
         XtraMsgBox.Show("新增数据失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, ex, this.GetType());
     }
 }
 protected override void SetSaveDataProc(frmBaseToolEntryXC frmbase)
 {
     gridView1.CloseEditor();
     gridView1.UpdateCurrentRow();
     
     base.SetSaveDataProc(frmbase);
 }
        /// <summary>
        /// 数据查询功能处理
        /// </summary>
        protected virtual void SetSearchProc(frmBaseToolEntryXC frmBaseToolXC)
        {

            try
            {
                //获取表格一览信息

                GetDspDataList();
            }
            catch (Exception ex)
            {
                throw ex;    
            }
        }
        /// <summary>
        /// 保存数据功能处理
        /// </summary>
        protected virtual void SetSaveDataProc(frmBaseToolEntryXC frmbase)
        {
            bool isSucces = false;
            int RtnValue = -1;

            //画面数据验证处理
            if (!this.validData.Validate())
            {
                return;
            }

            //获取需要编辑数据信息

            this.GetGrpDataItem();

            //数据检查功能处理

            this.GetInputCheck(ref isSucces);

            if (!isSucces)
            {
                return;
            }

            switch (frmbase.ScanMode)
            {

                case Common.DataModifyMode.add:

                    //if (XtraMsgBox.Show("确定要新增吗(Y/N)?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;

                    SetInsertProc(ref RtnValue);
                    break;
                case Common.DataModifyMode.copyadd:

                    SetCopyInsertProc(ref RtnValue);
                    break;

                case Common.DataModifyMode.upd:

                    //if (XtraMsgBox.Show("确定要修改吗(Y/N)?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;

                    SetModifyProc(ref RtnValue);
                    break;

                case Common.DataModifyMode.del:

                    if (XtraMsgBox.Show("确定要删除吗(Y/N)?", this.Text , MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;

                    SetDeleteProc(ref RtnValue);
              
                    break;

                default :
                    this.ScanMode = Common.DataModifyMode.dsp;
                    break;

            }

            //数据刷新功能处理
            if (RtnValue > 0)
            {
                this.ScanMode = Common.DataModifyMode.dsp;

                SetRefreshProc(this);
                SetCancelInit(true);
            }

       }
        /// <summary>
        /// 设定工具栏的有效性

        /// </summary>
        /// <param name="mode">编辑的状态</param>
        public static void SetCmdControl(frmBaseToolEntryXC frmbase)
        {

            switch (frmbase.ScanMode)
            {

                case Common.DataModifyMode.dsp:

                    //初始化状态

                    frmbase.NewButtonEnabled = true;
                    frmbase.SaveButtonEnabled = false;
                    frmbase.CancelButtonEnabled = false;
                    frmbase.SearchButtonEnabled = true;
                    frmbase.RefreshButtonEnabled = true;

                    frmbase.PrintButtonEnabled = true;
                    frmbase.ExcelButtonEnabled = true;
                    frmbase.DeleteButtonEnabled = true;
                    frmbase.EditButtonEnabled = true;

                    //if (RecordCount > 0)
                    //{
                    //    frmbase.PrintButtonEnabled = true;
                    //    frmbase.ExcelButtonEnabled = true;
                    //    frmbase.DeleteButtonEnabled = true;
                    //    frmbase.EditButtonEnabled = true;
                    //}
                    //else
                    //{
                    //    frmbase.PrintButtonEnabled = false;
                    //    frmbase.ExcelButtonEnabled = false;
                    //    frmbase.DeleteButtonEnabled = false;
                    //    frmbase.EditButtonEnabled = false;
                    //}
                    break;

                case Common.DataModifyMode.add:

                    //添加状态

                    frmbase.NewButtonEnabled = false;
                    frmbase.PrintButtonEnabled = false;
                    frmbase.ImportButtonEnabled = false;
                    frmbase.SaveButtonEnabled = true;
                    frmbase.CancelButtonEnabled = true;
                    frmbase.ExcelButtonEnabled = false;
                    frmbase.SearchButtonEnabled = false;
                    frmbase.EditButtonEnabled = false;
                    frmbase.DeleteButtonEnabled = false;
                    frmbase.RefreshButtonEnabled = false;
                    break;

                case Common.DataModifyMode.upd:

                    //修改状态

                    frmbase.NewButtonEnabled = false;
                    frmbase.PrintButtonEnabled = false;
                    frmbase.ImportButtonEnabled = false;
                    frmbase.SaveButtonEnabled = true;
                    frmbase.CancelButtonEnabled = true;
                    frmbase.ExcelButtonEnabled = false;
                    frmbase.SearchButtonEnabled = false;
                    frmbase.EditButtonEnabled = false;
                    frmbase.DeleteButtonEnabled = false;
                    frmbase.RefreshButtonEnabled = false;

                    break;

                case Common.DataModifyMode.del:

                    //删除状态

                    frmbase.NewButtonEnabled = false;
                    frmbase.PrintButtonEnabled = false;
                    frmbase.ImportButtonEnabled = false;
                    frmbase.SaveButtonEnabled = true;
                    frmbase.CancelButtonEnabled = true;
                    frmbase.ExcelButtonEnabled = false;
                    frmbase.SearchButtonEnabled = false;
                    frmbase.EditButtonEnabled = false;
                    frmbase.DeleteButtonEnabled = false;
                    frmbase.RefreshButtonEnabled = false;

                    break;

        
            }


            if (Common._isHistory)
            {

                frmbase.cmdNew.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                frmbase.cmdEdit.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                frmbase.cmdDelete.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                frmbase.cmdCancel.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                frmbase.cmdSave.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }
        }
Exemple #6
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="frmbase"></param>
        protected override void SetSaveDataProc(frmBaseToolEntryXC frmbase)
        {
            DataRow _dr;
            try
            {
               
                gridView1.CloseEditor();
                gridView1.UpdateCurrentRow();
                gridView2.CloseEditor();
                gridView2.UpdateCurrentRow();
                bool isScuess = false;
                GetInputCheck(ref isScuess);
                if (!isScuess) return;

                int result = 0;
                DataTable dt_temp = ((DataView)gridView1.DataSource).ToTable();
                DataTable dt_temp2 = ((DataView)gridView2.DataSource).ToTable();
                string str_sql = string.Empty;

                Common.AdoConnect.Connect.CreateSqlTransaction();
                m_dicPrimarName.Clear();
                m_dicItemData.Clear();


                for (int i = 0; i < dt_temp.Rows.Count; i++)
                {
                    //如果Oper_Info表中没有数据 新增数据
                    str_sql = string.Format(@"select * from Oper_Info where OperID='{0}'", dt_temp.Rows[i]["UserID"].ToString());
                    DataTable dt = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql);
                    if (dt.Rows.Count > 0)
                    {
                        //回写账号状态和密码到Oper_Info表中
                        str_sql = string.Format(@"update Oper_Info set StatusID='{0}', Pwd='{1}' where OperID='{2}'",
                                            dt_temp.Rows[i]["statusID"].ToString(), dt_temp.Rows[i]["passWord"].ToString(), dt_temp.Rows[i]["UserID"].ToString());
                        result = SysParam.m_daoCommon.SetModifyDataItemBySql(str_sql, m_dicItemData, m_dicPrimarName, m_dicUserColum);

                        //日志
                        SysParam.m_daoCommon.WriteLog("人员信息表", "修改", dt_temp.Rows[i]["UserID"].ToString());
                    }
                    else 
                    {
                        //新增用户到Oper_Info表中
                        m_dicItemData.Clear();
                        m_dicItemData["OperID"] = dt_temp.Rows[i]["UserID"].ToString();
                        m_dicItemData["TypeID"] = dt_temp.Rows[i]["OperType"].ToString();
                        m_dicItemData["StatusID"] = dt_temp.Rows[i]["StatusID"].ToString();
                        m_dicItemData["Pwd"] = dt_temp.Rows[i]["passWord"].ToString();
                        m_dicItemData["WebRole"] = "";
                        m_dicItemData["Memo"] = "";

                        result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Oper_Info, m_dicItemData);

                        //日志
                        SysParam.m_daoCommon.WriteLog("人员信息", "新增", dt_temp.Rows[i]["UserID"].ToString());
                    }

                    //SetSaveRoleOper(dt_temp2, dt_temp);

                    //保存到人员和角色绑定表
                    str_sql = string.Format(@"select * from Oper_User_Role where UserID='{0}'", dt_temp.Rows[i]["UserID"].ToString());
                    dt = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql);
                    if (dt.Rows.Count > 0)//表中已存在该用户则是修改
                    {
                        m_dicPrimarName.Clear();
                        m_dicPrimarName["UserID"] = dt_temp.Rows[i]["UserID"].ToString();

                        //先删除已存在的用户权限
                        m_dicItemData["UserID"] = dt_temp.Rows[i]["UserID"].ToString();
                        result = SysParam.m_daoCommon.SetDeleteDataItem("Oper_User_Role", m_dicItemData, m_dicPrimarName);

                        //保存当前用户的角色信息
                        m_dicItemData.Clear();
                        for (int k = 0; k < dt_temp2.Rows.Count; k++)
                        {
                            _dr = dt_temp2.Rows[k];
                            if (!_dr["SlctValue"].ToString().ToLower().Equals("true"))
                            {
                                continue;
                            }
                            m_dicItemData["UserID"] = dt_temp.Rows[i]["UserID"].ToString();
                            m_dicItemData["OperID"] = Common._personid;
                            m_dicItemData["RoleID"] = dt_temp2.Rows[k]["RoleID"].ToString();
                            m_dicItemData["ReMark"] = dt_temp2.Rows[k]["RoleName"].ToString();
                            m_dicItemData["operDate"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            result = SysParam.m_daoCommon.SetInsertDataItem("Oper_User_Role", m_dicItemData);

                            //日志
                            SysParam.m_daoCommon.WriteLog("人员资料登记", "修改权限", dt_temp.Rows[i]["UserID"].ToString());
                        }
                    }
                    else //表中不存在该用户则是新增
                    {
                        m_dicPrimarName.Clear();
                        m_dicPrimarName["UserID"] = dt_temp.Rows[i]["UserID"].ToString();
                        m_dicPrimarName["RoleID"] = dt_temp2.Rows[i]["RoleID"].ToString();

                        //保存当前用户的角色信息
                        m_dicItemData.Clear();
                        for (int k = 0; k < dt_temp2.Rows.Count; k++)
                        {
                            _dr = dt_temp2.Rows[k];
                            if (!_dr["SlctValue"].ToString().ToLower().Equals("true"))
                            {
                                continue;
                            }
                            m_dicItemData["UserID"] = dt_temp.Rows[i]["UserID"].ToString();
                            m_dicItemData["OperID"] = Common._personid;
                            m_dicItemData["RoleID"] = dt_temp2.Rows[k]["RoleID"].ToString();
                            m_dicItemData["ReMark"] = dt_temp2.Rows[k]["RoleName"].ToString();
                            m_dicItemData["operDate"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            result = SysParam.m_daoCommon.SetInsertDataItem("Oper_User_Role", m_dicItemData, m_dicPrimarName);

                            //日志
                            SysParam.m_daoCommon.WriteLog("人员信息登记", "新增权限", dt_temp.Rows[i]["UserID"].ToString());
                        }
                    }
                }
                Common.AdoConnect.Connect.TransactionCommit();
                XtraMsgBox.Show("保存数据成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Common.AdoConnect.Connect.TransactionRollback();
                XtraMsgBox.Show("保存数据失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, ex, this.GetType());
            }
        }