Exemple #1
0
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <returns></returns>
        public string AddPromission()
        {
            string     roleID = Query <string>("RoleID");
            bool       result = false;
            MDataTable dt     = GetTable(roleID);// MDataTable.CreateFrom(strArr, mdc);

            if (dt != null && dt.Rows.Count > 0)
            {
                //删除该角色下面所有权限
                using (MAction action = new MAction(TableNames.Sys_RoleAction))
                {
                    action.BeginTransation();
                    action.Delete("RoleID='" + roleID + "'");
                    dt.DynamicData = action;
                    dt.SetState(1);
                    result = dt.AcceptChanges(AcceptOp.Insert);
                    if (!result)
                    {
                        action.RollBack();
                    }
                    action.EndTransation();
                }
            }

            return(JsonHelper.OutResult(result, result ? "添加成功!" : "添加失败!"));
        }
Exemple #2
0
        /// <summary>
        /// 格式化Excel列头和Config_KeyValue数据。
        /// </summary>
        protected bool FormatExcel(MDataTable dt, MDataRow excelInfo)
        {
            //翻译列头。
            Dictionary <string, string> formatterDic = ExcelConfig.FormatterTitle(dt, excelInfo, ObjName);//
            //翻译字典值,处理默认值。
            bool result = KeyValueConfig.FormatNameValue(dt, formatterDic, false);

            //校验基础数据类型。
            result = ExcelConfig.ValidateData(dt, excelInfo) && result;

            if (result)//验证是否存在有错误信息
            {
                int index = dt.Columns.GetIndex("错误信息");
                if (index > -1)
                {
                    foreach (var row in dt.Rows)
                    {
                        if (!row[index].IsNullOrEmpty)
                        {
                            result = false;
                            break;
                        }
                    }
                }
            }
            dt.SetState(2, BreakOp.NullOrEmpty);
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 批量更新瓦片数据
        /// </summary>
        /// <param name="listdata"></param>
        /// <returns></returns>
        public static bool updateDatas(List <DiTu_DB> listdata)
        {
            using (MDataTable dt2 = MDataTable.CreateFrom(listdata))
            {
                dt2.SetState(2);

                dt2.TableName = TableNames.dt.ToString();

                dt2.Conn = ConnectStr;

                return(dt2.AcceptChanges(AcceptOp.Update));
            }
        }
Exemple #4
0
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <returns></returns>
        public string AddPromission()
        {
            string roleID = Query <string>("RoleID");
            bool   result = false;
            //MDataColumn mdc = new MDataColumn();
            //mdc.Add("RoleID", SqlDbType.NVarChar);
            //mdc.Add("MenuID", SqlDbType.NVarChar);
            //mdc.Add("ActionID", SqlDbType.NVarChar);
            MDataTable dt = GetTable(roleID);// MDataTable.CreateFrom(strArr, mdc);

            if (dt != null && dt.Rows.Count > 0)
            {
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    MDataRow row = dt.Rows[i];
                //    if (row["MenuID"].IsNullOrEmpty || row["ActionID"].IsNullOrEmpty)
                //    {
                //        dt.Rows.RemoveAt(i);
                //        i--;
                //        continue;
                //    }
                //    row.Set("RoleID", roleID);
                //}
                //dt.TableName = TableNames.Sys_RoleAction.ToString();
                //删除该角色下面所有权限
                using (MAction action = new MAction(TableNames.Sys_RoleAction))
                {
                    action.BeginTransation();
                    action.Delete("RoleID='" + roleID + "'");
                    dt.DynamicData = action;
                    dt.SetState(1);
                    result = dt.AcceptChanges(AcceptOp.Insert);
                    if (!result)
                    {
                        action.RollBack();
                    }
                    action.EndTransation();
                }
            }

            return(JsonHelper.OutResult(result, result ? "添加成功!" : "添加失败!"));
        }