예제 #1
0
        public frmDashBoard()
        {
            DevExpress.Utils.AppearanceObject.DefaultFont = new Font("Arial", 10, FontStyle.Bold);
            DashBoard = this;
            InitializeComponent();
            ribbonMain.Minimized = true;

            //--
            DAL.Settings.CompanyDAL CompanyDAL = new DAL.Settings.CompanyDAL();
            SettingsDAL = new SettingsDAL();

            // Loading Settings at level 0
            Model.CommonProperties.LoginInfo.SoftwareSettings = SettingsDAL.GetSetting();

            // Loading theme from settings
            SkinHelper.InitSkinGallery(rgbiSkins);
            UserLookAndFeel.Default.StyleChanged += Default_StyleChanged;
            UserLookAndFeel.Default.SkinName      = Model.CommonProperties.LoginInfo.SoftwareSettings.GUIThemeSkinName;
            //Properties.Settings.Default["ApplicationSkinName"].ToString();

            this.Text = Model.CommonProperties.DevelopmentCompanyInfo.CompanyShortName + " " + Model.CommonProperties.DevelopmentCompanyInfo.ProductName;
            lblCompanyName.Caption = "";
            lblFinPeriod.Caption   = "";
            lblLoginTime.Caption   = "";
            lblUserName.Caption    = "";
        }
예제 #2
0
        bool Login()
        {
            Users.frmUserLogin frmLogin = new Users.frmUserLogin();

            frmLogin.ShowDialog(this);
            if (Model.CommonProperties.LoginInfo.LoggedinUser == null)
            {
                //this.Close();
                return(false);
            }

            //if (CompanyDAL.GetFirstCompany() == null)
            //{
            //    bool ContCompany = false;
            //    do
            //    {
            //        Settings.frmCompany frmComp = new Settings.frmCompany();
            //        frmComp.StartPosition = FormStartPosition.CenterScreen;
            //        frmComp.ShowDialog();

            //        if (CompanyDAL.GetFirstCompany() == null)
            //        {
            //            if (Alit.WinformControls.MessageBox.Show(this, "You don't have a company to start. Do you want to create a new company ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            //            {
            //                ContCompany = true;
            //            }
            //            else
            //            {
            //                Application.Exit();
            //                return;
            //            }
            //        }
            //        else
            //        {
            //            ContCompany = false;
            //        }
            //    } while (ContCompany);
            //}

            if (DAL.Settings.CompanyDAL.CompanyCount(Model.CommonProperties.LoginInfo.LoggedinUser.UserGroupID) == 1)
            {
                Model.CommonProperties.LoginInfo.LoggedInCompany = DAL.Settings.CompanyDAL.GetFirstCompany(Model.CommonProperties.LoginInfo.LoggedinUser.UserGroupID);
                if (DAL.Settings.FinPeriodDAL.FinPeriodsCount(Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID) == 1)
                {
                    Model.CommonProperties.LoginInfo.LoggedInFinPeriod = DAL.Settings.FinPeriodDAL.GetFirstFinPeriod(Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID);
                }
            }

            if (Model.CommonProperties.LoginInfo.LoggedInCompany == null ||
                Model.CommonProperties.LoginInfo.LoggedInFinPeriod == null)
            {
                Users.frmSelectCompany frmSelectCompany = new Users.frmSelectCompany();
                frmSelectCompany.ShowDialog(this);
            }

            if (Model.CommonProperties.LoginInfo.LoggedinUser != null && Model.CommonProperties.LoginInfo.LoggedInCompany != null && Model.CommonProperties.LoginInfo.LoggedInFinPeriod != null)
            {
                lblUserName.Caption    = Model.CommonProperties.LoginInfo.LoggedinUser.UserName;
                lblCompanyName.Caption = "Company : " + Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyName;
                lblFinPeriod.Caption   = "(" + Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodFrom.ToShortDateString() + " - " + (Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodTo.HasValue ? Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodTo.Value.ToShortDateString() : "*") + ")";
                lblLoginTime.Caption   = "Login at : " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

                this.Text = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyName + " " +
                            lblFinPeriod.Caption + " - " +
                            Model.CommonProperties.DevelopmentCompanyInfo.CompanyShortName + " " +
                            Model.CommonProperties.DevelopmentCompanyInfo.ProductName;

                SettingsDAL.GetSetting(Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID, Model.CommonProperties.LoginInfo.SoftwareSettings);

                Model.CommonProperties.LoginInfo.LoggedInCompanyReportModel = DAL.Settings.CompanyDAL.GetCompanyDetailReportModel(Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID);

                Model.CommonProperties.LoginInfo.CurrentPayrollMonth = (new DAL.Settings.PayrollMonthDAL()).GetLatestPayrollMonthViewModelByCompanyID(Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID);
                if (Model.CommonProperties.LoginInfo.CurrentPayrollMonth != null)
                {
                    lblPayrollMonthName.Caption = Model.CommonProperties.LoginInfo.CurrentPayrollMonth.PayrollMonthName;
                }


                ApplySettingsOnMenus();

                if (!Model.CommonProperties.LoginInfo.LoggedinUser.SuperUser)
                {
                    /// Setting visibility of bar items according to permission
                    foreach (BarItem item in ribbonMain.Items)
                    {
                        if (item.Tag != null)
                        {
                            long MenuOptionID = Model.CommonFunctions.ParseLong(item.Tag.ToString());
                            var  perm         = Model.CommonFunctions.GetCurreUserPermission(MenuOptionID);
                            if (perm != null && perm.CanView)
                            {
                                item.Visibility = BarItemVisibility.Always;
                            }
                            else
                            {
                                item.Visibility = BarItemVisibility.Never;
                            }
                        }
                    }
                }
                else
                {
                    foreach (BarItem item in ribbonMain.Items)
                    {
                        item.Visibility = BarItemVisibility.Always;
                    }
                }
            }
            else
            {
                //this.Close();
                return(false);
            }
            ribbonMain.Minimized = false;

            return(true);
        }