Exemple #1
0
        private List <SYS_USER_RULE> MapSYS_USER_RULE(DataTable dt)
        {
            List <SYS_USER_RULE> rs = new List <SYS_USER_RULE>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SYS_USER_RULE obj = new SYS_USER_RULE();
                if (dt.Columns.Contains("Goup_ID"))
                {
                    obj.Goup_ID = (dt.Rows[i]["Goup_ID"].ToString());
                }
                if (dt.Columns.Contains("Object_ID"))
                {
                    obj.Object_ID = (dt.Rows[i]["Object_ID"].ToString());
                }
                if (dt.Columns.Contains("Rule_ID"))
                {
                    obj.Rule_ID = (dt.Rows[i]["Rule_ID"].ToString());
                }
                if (dt.Columns.Contains("AllowAdd"))
                {
                    obj.AllowAdd = bool.Parse(dt.Rows[i]["AllowAdd"].ToString());
                }
                if (dt.Columns.Contains("AllowDelete"))
                {
                    obj.AllowDelete = bool.Parse(dt.Rows[i]["AllowDelete"].ToString());
                }
                if (dt.Columns.Contains("AllowEdit"))
                {
                    obj.AllowEdit = bool.Parse(dt.Rows[i]["AllowEdit"].ToString());
                }
                if (dt.Columns.Contains("AllowAccess"))
                {
                    obj.AllowAccess = bool.Parse(dt.Rows[i]["AllowAccess"].ToString());
                }
                if (dt.Columns.Contains("AllowPrint"))
                {
                    obj.AllowPrint = bool.Parse(dt.Rows[i]["AllowPrint"].ToString());
                }
                if (dt.Columns.Contains("AllowExport"))
                {
                    obj.AllowExport = bool.Parse(dt.Rows[i]["AllowExport"].ToString());
                }
                if (dt.Columns.Contains("AllowImport"))
                {
                    obj.AllowImport = bool.Parse(dt.Rows[i]["AllowImport"].ToString());
                }
                if (dt.Columns.Contains("Active"))
                {
                    obj.Active = bool.Parse(dt.Rows[i]["Active"].ToString());
                }

                rs.Add(obj);
            }
            return(rs);
        }
        public void InsertUserRule(SYS_USER_RULE obj)
        {
            SqlConnection con = new SqlConnection(DataProvider.ConnectionString);

            con.Open();
            SqlCommand sqlcmd = con.CreateCommand();

            sqlcmd.CommandText = "Insert Into SYS_USER_RULE ( Goup_ID, Object_ID, Rule_ID, AllowAdd, AllowDelete, AllowEdit, AllowAccess, AllowPrint, AllowExport, AllowImport, Active ) values ( @Goup_ID, @Object_ID, @Rule_ID, @AllowAdd, @AllowDelete, @AllowEdit, @AllowAccess, @AllowPrint, @AllowExport, @AllowImport, @Active) ";
            sqlcmd.Parameters.Add("@Goup_ID", SqlDbType.VarChar, 20).Value   = obj.Goup_ID;
            sqlcmd.Parameters.Add("@Object_ID", SqlDbType.VarChar, 50).Value = obj.Object_ID;
            sqlcmd.Parameters.Add("@Rule_ID", SqlDbType.VarChar, 20).Value   = obj.Rule_ID;
            sqlcmd.Parameters.Add("@AllowAdd", SqlDbType.Bit).Value          = obj.AllowAdd;
            sqlcmd.Parameters.Add("@AllowDelete", SqlDbType.Bit).Value       = obj.AllowDelete;
            sqlcmd.Parameters.Add("@AllowEdit", SqlDbType.Bit).Value         = obj.AllowEdit;
            sqlcmd.Parameters.Add("@AllowAccess", SqlDbType.Bit).Value       = obj.AllowAccess;
            sqlcmd.Parameters.Add("@AllowPrint", SqlDbType.Bit).Value        = obj.AllowPrint;
            sqlcmd.Parameters.Add("@AllowExport", SqlDbType.Bit).Value       = obj.AllowExport;
            sqlcmd.Parameters.Add("@AllowImport", SqlDbType.Bit).Value       = obj.AllowImport;
            sqlcmd.Parameters.Add("@Active", SqlDbType.Bit).Value            = obj.Active;
            sqlcmd.ExecuteNonQuery();
            con.Close();
        }
Exemple #3
0
 public int SYS_USER_RULE_Insert(SYS_USER_RULE obj)
 {
     try
     {
         return(DataProvider.ExecuteNonquery(DataProvider.ConnectionString, "SYS_USER_RULE_Insert",
                                             obj.Goup_ID,
                                             obj.Object_ID,
                                             obj.Rule_ID,
                                             obj.AllowAdd,
                                             obj.AllowDelete,
                                             obj.AllowEdit,
                                             obj.AllowAccess,
                                             obj.AllowPrint,
                                             obj.AllowExport,
                                             obj.AllowImport,
                                             obj.Active
                                             ));
     }
     catch
     {
         //throw ex;
         return(-1);
     }
 }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            SYS_USER_RULE objSYS_USER_RULE = new SYS_USER_RULE();
            int           rs    = -1;
            int           rsobj = -1;

            objSYS_GROUP.Group_ID     = txtGroup_ID.Text;
            objSYS_GROUP.Group_Name   = txtGroup_Name.Text;
            objSYS_GROUP.Group_NameEn = txtGroup_Name.Text;
            objSYS_GROUP.Description  = txtGroup_Description.Text;
            objSYS_GROUP.Active       = chk_Active.Checked;
            rsobj = new SYS_GROUPController().SYS_GROUP_Insert(objSYS_GROUP);
            for (int i = 0; i < treeList1.Nodes.Count; i++)
            {
                objSYS_USER_RULE.Goup_ID     = txtGroup_ID.Text;
                objSYS_USER_RULE.Object_ID   = treeList1.Nodes[i][8].ToString();
                objSYS_USER_RULE.Rule_ID     = "view";
                objSYS_USER_RULE.AllowAdd    = bool.Parse(treeList1.Nodes[i][1].ToString());
                objSYS_USER_RULE.AllowEdit   = bool.Parse(treeList1.Nodes[i][2].ToString());
                objSYS_USER_RULE.AllowDelete = bool.Parse(treeList1.Nodes[i][3].ToString());
                objSYS_USER_RULE.AllowPrint  = bool.Parse(treeList1.Nodes[i][4].ToString());
                objSYS_USER_RULE.AllowImport = bool.Parse(treeList1.Nodes[i][5].ToString());
                objSYS_USER_RULE.AllowExport = bool.Parse(treeList1.Nodes[i][6].ToString());
                objSYS_USER_RULE.AllowAccess = bool.Parse(treeList1.Nodes[i][7].ToString());
                objSYS_USER_RULE.Active      = true;
                rs = new SYS_USER_RULEController().SYS_USER_RULE_Update(objSYS_USER_RULE);
                if (rs < 0)
                {
                    XtraMessageBox.Show("Lưu Thất Bại 1!", "Thông Báo");
                    break;
                }
                for (int j = 0; j < treeList1.Nodes[i].Nodes.Count; j++)
                {
                    rs = -1;
                    objSYS_USER_RULE.Goup_ID     = txtGroup_ID.Text;
                    objSYS_USER_RULE.Object_ID   = treeList1.Nodes[i].Nodes[j][8].ToString();
                    objSYS_USER_RULE.Rule_ID     = "view";
                    objSYS_USER_RULE.AllowAdd    = bool.Parse(treeList1.Nodes[i].Nodes[j][1].ToString());
                    objSYS_USER_RULE.AllowEdit   = bool.Parse(treeList1.Nodes[i].Nodes[j][2].ToString());
                    objSYS_USER_RULE.AllowDelete = bool.Parse(treeList1.Nodes[i].Nodes[j][3].ToString());
                    objSYS_USER_RULE.AllowPrint  = bool.Parse(treeList1.Nodes[i].Nodes[j][4].ToString());
                    objSYS_USER_RULE.AllowImport = bool.Parse(treeList1.Nodes[i].Nodes[j][5].ToString());
                    objSYS_USER_RULE.AllowExport = bool.Parse(treeList1.Nodes[i].Nodes[j][6].ToString());
                    objSYS_USER_RULE.AllowAccess = bool.Parse(treeList1.Nodes[i].Nodes[j][7].ToString());
                    objSYS_USER_RULE.Active      = true;

                    rs = new SYS_USER_RULEController().SYS_USER_RULE_Update(objSYS_USER_RULE);
                    if (rs < 0)
                    {
                        XtraMessageBox.Show("Lưu Thất Bại 2!", "Thông Báo");
                        break;
                    }
                    for (int k = 0; k < treeList1.Nodes[i].Nodes[j].Nodes.Count; k++)
                    {
                        rs = -1;
                        objSYS_USER_RULE.Goup_ID     = txtGroup_ID.Text;
                        objSYS_USER_RULE.Object_ID   = treeList1.Nodes[i].Nodes[j].Nodes[k][8].ToString();
                        objSYS_USER_RULE.Rule_ID     = "view";
                        objSYS_USER_RULE.AllowAdd    = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][1].ToString());
                        objSYS_USER_RULE.AllowEdit   = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][2].ToString());
                        objSYS_USER_RULE.AllowDelete = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][3].ToString());
                        objSYS_USER_RULE.AllowPrint  = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][4].ToString());
                        objSYS_USER_RULE.AllowImport = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][5].ToString());
                        objSYS_USER_RULE.AllowExport = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][6].ToString());
                        objSYS_USER_RULE.AllowAccess = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k][7].ToString());
                        objSYS_USER_RULE.Active      = true;

                        rs = new SYS_USER_RULEController().SYS_USER_RULE_Update(objSYS_USER_RULE);
                        if (rs < 0)
                        {
                            XtraMessageBox.Show("Lưu Thất Bại 3!", "Thông Báo");
                            break;
                        }
                        for (int l = 0; l < treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes.Count; l++)
                        {
                            rs = -1;
                            objSYS_USER_RULE.Goup_ID     = txtGroup_ID.Text;
                            objSYS_USER_RULE.Object_ID   = treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][8].ToString();
                            objSYS_USER_RULE.Rule_ID     = "view";
                            objSYS_USER_RULE.AllowAdd    = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][1].ToString());
                            objSYS_USER_RULE.AllowEdit   = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][2].ToString());
                            objSYS_USER_RULE.AllowDelete = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][3].ToString());
                            objSYS_USER_RULE.AllowPrint  = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][4].ToString());
                            objSYS_USER_RULE.AllowImport = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][5].ToString());
                            objSYS_USER_RULE.AllowExport = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][6].ToString());
                            objSYS_USER_RULE.AllowAccess = bool.Parse(treeList1.Nodes[i].Nodes[j].Nodes[k].Nodes[l][7].ToString());
                            objSYS_USER_RULE.Active      = true;

                            rs = new SYS_USER_RULEController().SYS_USER_RULE_Update(objSYS_USER_RULE);
                            if (rs < 0)
                            {
                                XtraMessageBox.Show("Lưu Thất Bại 4!", "Thông Báo");
                                break;
                            }
                        }
                    }
                }
            }
            XtraMessageBox.Show("Lưu thành công!");
        }