Ejemplo n.º 1
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        public override void DoSave(IButtonInfo sender)
        {
            if (!gvMenus.IsValidRowHandle(gvMenus.FocusedRowHandle))
            {
                return;
            }
            DataTable summary = gcMenus.DataSource as DataTable;

            DataRow currentRow = gvMenus.GetDataRow(gvMenus.FocusedRowHandle);
            int     temp       = ConvertEx.ToInt(currentRow[TMenu.Auths]);       //取当前菜单的权限
            string  menuName   = ConvertEx.ToString(currentRow[TMenu.MenuName]); //当前菜单名

            //取窗体的权限
            int         auths = 0; int val = 0;
            ucCheckEdit ce;
            DataRow     row;
            string      filter;

            foreach (Control ctr in pcActions.Controls)
            {
                if (!(ctr is ucCheckEdit))
                {
                    continue;
                }

                ce  = ctr as ucCheckEdit;
                row = ce.Tag as DataRow; //功能点的数据行
                val = ConvertEx.ToInt(row["AuthorityValue"]);
                if (ce.IsChecked)
                {
                    auths += val;               //累加权限数值
                }
                filter = "MenuName='" + menuName + "' and TagValue=" + val.ToString();
                DataRow[] rows = _BLL.FormTagCustomName.Select(filter);
                if (rows.Length > 0) //有自定义功能点名称
                {
                    string tagName = ConvertEx.ToString(rows[0]["TagName"]);
                    if (ce.IsChecked && (tagName.ToUpper() != ce.CheckText.ToUpper()))
                    {
                        rows[0]["TagName"] = ce.CheckText; //修改新功能点名称
                    }
                    if (ce.IsChecked == false)             //删除了功能名称
                    {
                        rows[0].Delete();
                    }
                }
                else
                {
                    string authName = ConvertEx.ToString(row["AuthorityName"]);
                    if (authName.ToUpper() != ce.CheckText.ToUpper())
                    {
                        DataRow newrow = _BLL.FormTagCustomName.NewRow();
                        newrow["MenuName"] = menuName;
                        newrow["TagValue"] = val;
                        newrow["TagName"]  = ce.CheckText; //新的名称
                        _BLL.FormTagCustomName.Rows.Add(newrow);
                    }
                }
            }

            if (auths != temp)
            {
                currentRow["Auths"] = auths;//修改新权限
            }

            //保存两种数据: 1.菜单  2.各窗体的功能点名称
            if (_BLL.Update(_UpdateType))
            {
                base.DoSave(sender);
                Msg.ShowInformation("保存成功!");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        public override void DoSave(IButtonInfo sender)
        {
            if (!gvMenus.IsValidRowHandle(gvMenus.FocusedRowHandle))
            {
                return;
            }
            DataTable summary = gcMenus.DataSource as DataTable;

            DataRow currentRow = gvMenus.GetDataRow(gvMenus.FocusedRowHandle);
            int     temp       = ConvertEx.ToInt(currentRow[tb_sys_Function.FAuths]);     //取当前菜单的权限
            string  menuName   = ConvertEx.ToString(currentRow[tb_sys_Function.FNumber]); //当前菜单名
            string  MenuId     = ConvertEx.ToString(currentRow[tb_sys_Function.FID]);     //当前菜单ID
            //取窗体的权限
            int         auths = 0; int val = 0;
            ucCheckEdit ce;
            DataRow     row;

            //string filter;

            foreach (Control ctr in pcActions.Controls)
            {
                if (!(ctr is ucCheckEdit))
                {
                    continue;
                }

                ce  = ctr as ucCheckEdit;
                row = ce.Tag as DataRow; //功能点的数据行
                val = ConvertEx.ToInt(row[tb_sys_Fun_MenuBar.FAuthority]);
                if (ce.IsChecked)
                {
                    auths += val;               //累加权限数值
                }
                //filter = "FNumber='" + menuName + "' and FAuthority=" + val.ToString();
                //DataRow[] rows = _BLL.FormTagCustomName.Select(filter);
                //if (rows.Length > 0) //有自定义功能点名称
                //{
                //    string tagName = ConvertEx.ToString(rows[0][tb_sys_Fun_MenuBar.FName]);
                //    if (ce.IsChecked && (tagName.ToUpper() != ce.CheckText.ToUpper()))
                //        rows[0][tb_sys_Fun_MenuBar.FName] = ce.CheckText;//修改新功能点名称

                //    if (ce.IsChecked == false) //删除了功能名称
                //        rows[0].Delete();
                //}
                //else
                //{
                //string authName = ConvertEx.ToString(row[tb_sys_Fun_MenuBar.FAuthority]);
                //if (authName.ToUpper() != ce.CheckText.ToUpper())
                //{
                //    DataRow newrow = _BLL.FormTagCustomName.NewRow();
                //    newrow[tb_sys_Fun_MenuBar.FMenuID] = MenuId;
                //    newrow[tb_sys_Fun_MenuBar.FAuthority] = val;
                //    newrow[tb_sys_Fun_MenuBar.FName] = ce.CheckText; //新的名称
                //    _BLL.FormTagCustomName.Rows.Add(newrow);
                //}
                //}
            }

            if (auths != temp)
            {
                currentRow[tb_sys_Function.FAuths] = auths;//修改新权限
            }

            //保存两种数据: 1.菜单  2.各窗体的功能点名称
            if (_BLL.Update(_UpdateType))
            {
                string sFdes = (_UpdateType == UpdateType.Add ? "新增" : "修改") + "功能" + menuName + "的权限";
                bllComDataBaseTool.WriteLogOp(_FunctionID, "0", sFdes);
                base.DoSave(sender);
                Msg.ShowInformation("保存成功!");
            }
        }