Ejemplo n.º 1
0
 private void RoleForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && GridViewRole.IsFilterRow(GridViewRole.FocusedRowHandle))
     {
         executeQuery();
     }
 }
Ejemplo n.º 2
0
        protected void ToggleInRole_Click(object sender, EventArgs e)
        {
            // Grab text from button and parse, not so elegant, but gets the job done
            Button bt         = (Button)sender;
            string buttonText = bt.Text;

            char[] seps = new char[1];
            seps[0] = ' ';
            string[] buttonTextArray = buttonText.Split(seps);
            string   roleName        = buttonTextArray[5];
            string   userName        = buttonTextArray[2];
            string   whatToDo        = buttonTextArray[0];

            string[] userNameArray = new string[1];
            userNameArray[0] = userName;  // Need to do this because RemoveUserFromRole requires string array.

            if (whatToDo.StartsWith("Qu"))
            {
                // need to remove assignment of this role to this user
                Roles.RemoveUsersFromRole(userNameArray, roleName);
            }
            else
            {
                Roles.AddUserToRole(userName, roleName);
            }
            GridViewRole.DataBind();
        }
Ejemplo n.º 3
0
 private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (!GridViewRole.IsFilterRow(e.RowHandle))
     {
         modified = true;
     }
 }
Ejemplo n.º 4
0
        private void BindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (RoleBindingSource.Current == null)
            {
                return;
            }

            GridViewRole.CloseEditor();
            tYPEComboBoxEdit.Focus();
            // bindingNavigatorPositionItem.Focus();//trigger field leave eventoo
            bool temp = newRec;

            if (checkForms())
            {
                tYPEComboBoxEdit.Focus();
                setReadOnly(true);
                panelControlStatus.Visible = true;
                LabelStatus.Text           = "Record Saved";
                rowStatusSave          = new Timer();
                rowStatusSave.Interval = 3000;
                rowStatusSave.Start();
                rowStatusSave.Tick += TimedEventSave;
            }

            if (!temp && !modified)
            {
                context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (ROLE)RoleBindingSource.Current);
            }
        }
Ejemplo n.º 5
0
 protected void ButtonCreateNewRole_Click(object sender, EventArgs e)
 {
     if (TextBoxCreateNewRole.Text.Length > 0)
     {
         ObjectDataSourceRoleObject.InsertParameters["RoleName"].DefaultValue = TextBoxCreateNewRole.Text;;
         ObjectDataSourceRoleObject.Insert();
         GridViewRole.DataBind();
         TextBoxCreateNewRole.Text = "";
     }
 }
Ejemplo n.º 6
0
        protected void GridViewMembershipUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridView gv = (GridView)sender;

            // cover case where there is no current user
            if (Membership.GetUser() != null)
            {
                ObjectDataSourceRoleObject.SelectParameters["UserName"].DefaultValue = Membership.GetUser().UserName;
                ObjectDataSourceRoleObject.SelectParameters["ShowOnlyAssignedRolls"].DefaultValue = "true";
            }

            GridViewRole.DataBind();
        }
Ejemplo n.º 7
0
    public void ButtonAddRole_Click(object sender, EventArgs e)
    {
        String roleId     = LabelRoleId.Text;
        String peopleName = DPLPeople.SelectedValue;
        String peopleid   = People.getByName(peopleName).id;
        String roleName   = DPLRole.SelectedValue;
        String sqlstr     = String.Format("INSERT INTO role(id, movie_id, people_id, role) VALUES ('{0:s}', '{1:s}', '{2:s}', '{3:s}')",
                                          roleId, getMovieId(), peopleid, roleName);

        SqlData.getInstance().ExecuteSQL(sqlstr);
        int id = SqlData.getInstance().getMaxId("role") + 1;

        LabelRoleId.Text = id.ToString();
        GridViewRole.DataBind();
    }
Ejemplo n.º 8
0
    private void SearchSubmit()
    {
        try
        {
            string               User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass        user_class = dbo_UserDataClass.Select_Record(User_ID);
            List <dbo_RoleClass> item       = new List <dbo_RoleClass>();
            if (user_class.User_Group_ID == "Agent")
            {
                item = dbo_RoleDataClass.Search(string.Empty, string.Empty, "Agent");
            }
            else
            {
                item = dbo_RoleDataClass.Search(string.Empty, string.Empty, string.Empty);
            }

            //List<dbo_RoleClass> item = new List<dbo_RoleClass>();
            //if (ddlRoleType.SelectedIndex == 0)
            //{
            //    item = dbo_RoleDataClass.Search(string.Empty, string.Empty, string.Empty);

            //}
            //else
            //{
            //    item = dbo_RoleDataClass.Search(string.Empty, string.Empty, ddlRoleType.Text);
            //}

            //GridViewRole.ShowFooter = false;

            if (item.Count == 0)
            {
                item.Add(new dbo_RoleClass());
                GridViewRole.DataSource = item;
                GridViewRole.DataBind();
                GridViewRole.Rows[0].Visible = false;
            }
            else
            {
                GridViewRole.DataSource = item;
                GridViewRole.DataBind();
            }
        }
        catch (Exception)
        {
        }
    }
Ejemplo n.º 9
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            // 33	9 : สิทธิ์ใช้งานหน้าตั้งค่าสิทธิ์การใช้งาน	 บันทึกข้อมูลสิทธิ์การใช้งาน
            int AuthorizeId = 33;

            if (SQLAuthorized.CheckAuthorized(ClassProperty.permisRoleId, AuthorizeId) == false)
            {
                SQLAuthorized.AlertAuthorized("สิทธิ์ใช้งานหน้าตั้งค่าสิทธิ์การใช้งาน", "ไม่มีสิทธิ์บันทึกข้อมูลสิทธิ์การใช้งาน");
                return;
            }

            if (SaveData() == true)
            {
                GetRoles();
                GridViewRole.FocusedRowHandle = GridViewRole.LocateByValue("RoleName", TxtRoleName.Text);
                RoleId = Convert.ToInt32(GridViewRole.GetFocusedRowCellValue("RoleId"));
                GetData(RoleId);
            }
        }
Ejemplo n.º 10
0
 private bool move()
 {
     GridViewRole.CloseEditor();
     tYPEComboBoxEdit.Focus();
     // bindingNavigatorPositionItem.Focus();//trigger field leave event
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( ROLE)RoleBindingSource.Current);
         }
         setReadOnly(true);
         newRec   = false;
         modified = false;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewRole.FocusedColumn.FieldName;
            string value   = String.Empty;

            if (!string.IsNullOrWhiteSpace(GridViewRole.GetFocusedDisplayText()))
            {
                value = GridViewRole.GetFocusedDisplayText();
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                string query   = String.Format("it.CODE like '{0}%'", GridViewRole.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"));
                var    special = context.ROLE.Where(query);

                if (!string.IsNullOrWhiteSpace(GridViewRole.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "DESC")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "[DESC]", GridViewRole.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "DESC"));
                    special = special.Where(query);
                }
                if (!string.IsNullOrWhiteSpace(GridViewRole.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "TYPE")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "[TYPE]", GridViewRole.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "TYPE"));
                    special = special.Where(query);
                }
                int count = special.Count();
                if (count > 0)
                {
                    RoleBindingSource.DataSource = special;
                    GridViewRole.SetRowCellValue(GridControl.AutoFilterRowHandle, colName, value);
                    GridViewRole.FocusedRowHandle        = 0;
                    GridViewRole.FocusedColumn.FieldName = colName;
                }
                else
                {
                    MessageBox.Show("No records in database.");
                    GridViewRole.ClearColumnsFilter();
                }
            }
            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 12
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewRole.ClearColumnsFilter();
     if (RoleBindingSource.Current == null)
     {
         //fake query in order to create a link between the database table and the binding source
         RoleBindingSource.DataSource = from opt in context.ROLE where opt.CODE == "KJM9" select opt;
         RoleBindingSource.AddNew();
         if (GridViewRole.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewRole.FocusedRowHandle = GridViewRole.RowCount - 1;
         }
         tYPEComboBoxEdit.Focus();
         setReadOnly(false);
         newRec = true;
         return;
     }
     tYPEComboBoxEdit.Focus();
     //bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewRole.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( ROLE)RoleBindingSource.Current);
         }
         RoleBindingSource.AddNew();
         if (GridViewRole.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewRole.FocusedRowHandle = GridViewRole.RowCount - 1;
         }
         tYPEComboBoxEdit.Focus();
         setReadOnly(false);
         newRec = true;
     }
 }
Ejemplo n.º 13
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (RoleBindingSource.Current == null)
     {
         return;
     }
     GridViewRole.CloseEditor();
     if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         modified = false;
         newRec   = false;
         RoleBindingSource.RemoveCurrent();
         errorProvider1.Clear();
         context.SaveChanges();
         setReadOnly(true);
         panelControlStatus.Visible = true;
         LabelStatus.Text           = "Record Deleted";
         rowStatusDelete            = new Timer();
         rowStatusDelete.Interval   = 3000;
         rowStatusDelete.Start();
         rowStatusDelete.Tick += new EventHandler(TimedEventDelete);
     }
     currentVal = tYPEComboBoxEdit.Text;
 }
Ejemplo n.º 14
0
 protected void GridViewMembership_RowDeleted(object sender, GridViewDeletedEventArgs e)
 {
     FindFirstUserName();     // Current user is deleted so need to select a new user as current
     GridViewRole.DataBind(); // update roll lists to reflect new counts
 }