Пример #1
0
        private void UserRoleAddNew_Button_Click(object sender, EventArgs e)
        {
            List <object> users = UserID_CheckedComboBoxEdit.EditValue.CastTo <List <object> >();

            //string userID = UserID_TextBox.Text;
            CM_Company company  = CompanyID_LookUpEdit.GetSelectedDataRow().CastTo <CM_Company>();
            MasterInfo userRole = UserRole_ComboBox.GetSelectedDataRow().CastTo <MasterInfo>();

            //if (string.IsNullOrEmpty(userID))
            if (users == null || users.Count <= 0)
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000003);
                return;
            }

            if (string.IsNullOrEmpty(company?.CompanyID))
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000005);
                return;
            }

            if (string.IsNullOrEmpty(userRole?.Id))
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000006);
                return;
            }

            //if (DetailData.ToList().Find(o => o.UserID == userID && o.CompanyID == company.CompanyID) != null)
            //{
            //    MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000004);
            //    return;
            //}

            foreach (string userID in users)
            {
                UserCompany find = DetailData.ToList().Find(o => o.UserID == userID && o.CompanyID == company.CompanyID);
                if (find != null)
                {
                    find.UserRoleID   = userRole.Id;
                    find.UserRoleName = userRole.Value;
                    find.Status       = ModifyMode.Update;
                }
                else
                {
                    DetailData.Add(new UserCompany
                    {
                        UserID       = userID,
                        CompanyID    = company.CompanyID,
                        CompanyName  = company.CompanyName,
                        UserRoleID   = userRole.Id,
                        UserRoleName = userRole.Value,
                        Status       = ModifyMode.Insert
                    });
                }
            }
        }
Пример #2
0
        private void InitComboBox()
        {
            // Công ty
            List <CM_Company> companys = GetCompanyList();

            CompanyID_LookUpEdit.SetupLookUpEdit("CompanyID", "CompanySName", companys,
                                                 new List <ColumnInfo>
            {
                new ColumnInfo("CompanySName", "Viết tắt", 100),
                new ColumnInfo("CompanyName", "Tên công ty", 200),
            },
                                                 isBestFitColumn: true,
                                                 popupFormHeight: 250);

            // role
            UserRoles = MasterInfoManager.GetUserRoles();
            UserRole_ComboBox.SetupLookUpEdit("Id", "Value", UserRoles);

            // User
            UserID_CheckedComboBoxEdit.SetupLayout("UserID", "UserDisplay", GetUsers(), editValueType: EditValueTypeCollection.List);

            //// Company
            //CompanyID_CheckedComboBoxEdit.SetupLayout("CompanyID", "CompanySName", companys);
        }