public UserControlAvailableSalespersons(UserControlAPIs userControlAPIs, string userName, string securityIdentifier)
        {
            InitializeComponent();

            try
            {
                this.userName           = userName;
                this.securityIdentifier = securityIdentifier;
                this.userControlAPIs    = userControlAPIs;

                this.fastUserControlAvailableSalespersons.ShowGroups           = true;
                this.fastUserControlAvailableSalespersons.AboutToCreateGroups += fastUserControlAvailableSalespersons_AboutToCreateGroups;

                this.fastUserControlAvailableSalespersons.SetObjects(this.userControlAPIs.GetUserControlAvailableSalespersons(this.securityIdentifier));
                this.fastUserControlAvailableSalespersons.Sort(this.olvEmployeeType, SortOrder.Ascending);
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
Esempio n. 2
0
        protected override void InitializeCommonControlBinding()
        {
            base.InitializeCommonControlBinding();

            this.treeWarehouseID.RootKeyValue               = 0;
            this.treeCommodityID.RootKeyValue               = 0;
            this.treeCommodityTypeID.RootKeyValue           = 0;
            this.treeCustomerID.RootKeyValue                = 0;
            this.treeEmployeeID.RootKeyValue                = 0;
            this.treeWarehouseIssueID.RootKeyValue          = 0;
            this.treeWarehouseReceiptID.RootKeyValue        = 0;
            this.treeWarehouseAdjustmentTypeID.RootKeyValue = 0;

            WarehouseAPIs warehouseAPIs = new WarehouseAPIs(CommonNinject.Kernel.Get <IWarehouseAPIRepository>());

            this.warehouseTrees             = warehouseAPIs.GetWarehouseTrees(ContextAttributes.User.LocationID);
            this.treeWarehouseID.DataSource = new BindingSource(this.warehouseTrees, "");

            this.warehouseIssueTrees             = warehouseAPIs.GetWarehouseTrees(null);
            this.treeWarehouseIssueID.DataSource = new BindingSource(this.warehouseIssueTrees, "");

            this.warehouseReceiptTrees             = warehouseAPIs.GetWarehouseTrees(null);
            this.treeWarehouseReceiptID.DataSource = new BindingSource(this.warehouseReceiptTrees, "");

            WarehouseAdjustmentTypeAPIs warehouseAdjustmentTypeAPIs = new WarehouseAdjustmentTypeAPIs(CommonNinject.Kernel.Get <IWarehouseAdjustmentTypeAPIRepository>());

            this.warehouseAdjustmentTypeTrees             = warehouseAdjustmentTypeAPIs.GetWarehouseAdjustmentTypeTrees();
            this.treeWarehouseAdjustmentTypeID.DataSource = new BindingSource(this.warehouseAdjustmentTypeTrees, "");

            CommodityAPIs commodityAPIs = new CommodityAPIs(CommonNinject.Kernel.Get <ICommodityAPIRepository>());

            this.commodityTrees             = commodityAPIs.GetCommodityTrees();
            this.treeCommodityID.DataSource = new BindingSource(this.commodityTrees, "");

            CommodityTypeAPIs commodityTypeAPIs = new CommodityTypeAPIs(CommonNinject.Kernel.Get <ICommodityTypeAPIRepository>());

            this.commodityTypeTrees             = commodityTypeAPIs.GetCommodityTypeTrees();
            this.treeCommodityTypeID.DataSource = new BindingSource(this.commodityTypeTrees, "");

            CustomerAPIs customerAPIs = new CustomerAPIs(CommonNinject.Kernel.Get <ICustomerAPIRepository>());

            this.customerTrees             = customerAPIs.GetCustomerTrees();
            this.treeCustomerID.DataSource = new BindingSource(this.customerTrees, "");

            EmployeeAPIs employeeAPIs = new EmployeeAPIs(CommonNinject.Kernel.Get <IEmployeeAPIRepository>());

            this.employeeTrees             = employeeAPIs.GetEmployeeTrees();
            this.treeEmployeeID.DataSource = new BindingSource(this.employeeTrees, "");

            this.comboSummaryVersusDetail.ComboBox.Items.AddRange(new string[] { "Summary only", "Show detail" });
            this.comboSummaryVersusDetail.ComboBox.SelectedIndex = 0;

            this.comboQuantityVersusVolume.ComboBox.Items.AddRange(new string[] { "By quantity", "By volume" });
            this.comboQuantityVersusVolume.ComboBox.SelectedIndex = 1;

            this.comboDateVersusMonth.ComboBox.Items.AddRange(new string[] { "Daily summary", "Monthly summary" });
            this.comboDateVersusMonth.ComboBox.SelectedIndex = 1;

            this.comboSalesVersusPromotion.ComboBox.Items.AddRange(new string[] { "Sales & promotions", "Sales only", "Promotions only" });
            this.comboSalesVersusPromotion.ComboBox.SelectedIndex = 0;

            this.comboForecastFilters.ComboBox.Items.AddRange(new string[] { "[All Items in Stock]", "[Current Stock + In Transit] > 0", "[Current Stock + In Transit] = 0", "[Current Stock + In Transit] < 0", "[Current Stock + In Transit] Between Low-High Level", "[Current Stock + In Transit] Out of Range Low-High Level", "[Current Stock + In Transit] Under Low-Level", "[Current Stock + In Transit] Over High-Level" });
            this.comboForecastFilters.ComboBox.SelectedIndex = 0;

            this.comboSlowMoving.Items.AddRange(new string[] { "Regardless forecast", "And without forecast" });
            this.comboSlowMoving.SelectedIndex = 0;

            UserControlAPIs userControlAPIs = new UserControlAPIs(CommonNinject.Kernel.Get <IUserControlAPIRepository>());

            this.comboUserName.ComboBox.Items.Add("[All users]");
            this.comboUserName.ComboBox.Items.AddRange(Array.ConvertAll(userControlAPIs.GetUserControlIndexes(GlobalEnums.ActiveOption.Both).ToArray(), u => u.UserName));
            this.comboUserName.ComboBox.SelectedIndex = 0;

            this.dateTimexFromDate.DataBindings.Add("Value", GlobalEnums.GlobalOptionSetting, CommonExpressions.PropertyName <OptionSetting>(p => p.FromDate), true, DataSourceUpdateMode.OnPropertyChanged);
            this.dateTimexToDate.DataBindings.Add("Value", GlobalEnums.GlobalOptionSetting, CommonExpressions.PropertyName <OptionSetting>(p => p.ToDate), true, DataSourceUpdateMode.OnPropertyChanged);

            this.fastReportIndex.AboutToCreateGroups += fastReportIndex_AboutToCreateGroups;
            this.fastReportIndex.ShowGroups           = true;
            //this.olvApproved.Renderer = new MappedImageRenderer(new Object[] { 1, Resources.Placeholder16, 2, Resources.Void_16 });
        }
        public UserControlRegister(UserControlAPIs userControlAPIs)
        {
            InitializeComponent();

            try
            {
                this.userControlAPIs = userControlAPIs;

                List <UserControlIndex> userControlIndexes = this.userControlAPIs.GetUserControlIndexes(GlobalEnums.ActiveOption.Both);

                List <DomainUser> allUsers = new List <DomainUser>();

                //userAPIs.UpdateUserName("S-1-5-21-3775195119-1044016383-3360809325-1001", "NMVN\vendor");

                if (true)
                {
                    PrincipalContext  ctx     = new PrincipalContext(ContextType.Domain, "chevronvn.com"); //, "OU=SomeOU,dc=YourCompany,dc=com"// create your domain context and define the OU container to search in
                    UserPrincipal     qbeUser = new UserPrincipal(ctx);                                    // define a "query-by-example" principal - here, we search for a UserPrincipal (user)
                    PrincipalSearcher srch    = new PrincipalSearcher(qbeUser);                            // create your principal searcher passing in the QBE principal

                    foreach (var found in srch.FindAll())                                                  // find all matches
                    {                                                                                      // do whatever here - "found" is of type "Principal" - it could be user, group, computer.....
                        if (found.Sid.Value != null && found.Sid.Value != "" && found.SamAccountName != null && found.SamAccountName != "")
                        {
                            userControlAPIs.UpdateUserName(found.Sid.Value, found.SamAccountName);

                            if (!this.UserExisted(userControlIndexes, found.Sid.Value))
                            {
                                allUsers.Add(new DomainUser()
                                {
                                    FirstName = "", LastName = "", DistinguishedName = this.GetWindowsIdentityName(found.DistinguishedName), UserName = found.SamAccountName, SecurityIdentifier = found.Sid.Value
                                });                                                                                                                                                                                                                //found.UserPrincipalName: the same as SamAccountName, but with @chevron.com
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 1; i <= 5; i++)
                    {
                        if (!this.UserExisted(userControlIndexes, "S-1-5-21-290773801108-TEST-" + i.ToString()))
                        {
                            allUsers.Add(new DomainUser()
                            {
                                FirstName = "FIST NAME" + i.ToString(), LastName = "LAST NAME " + i.ToString(), DistinguishedName = "Distinguished Name " + i.ToString(), UserName = "******" + i.ToString(), SecurityIdentifier = "S-1-5-21-290773801108-TEST-" + i.ToString()
                            });
                        }
                    }
                }

                this.combexUserID.DataSource          = allUsers;
                this.combexUserID.DisplayMember       = CommonExpressions.PropertyName <DomainUser>(p => p.UserName);
                this.combexUserID.ValueMember         = CommonExpressions.PropertyName <DomainUser>(p => p.UserName);
                this.bindingUserName                  = this.combexUserID.DataBindings.Add("SelectedValue", this, CommonExpressions.PropertyName <DomainUser>(p => p.UserName), true, DataSourceUpdateMode.OnPropertyChanged);
                this.bindingUserName.BindingComplete += binding_BindingComplete;
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }