Esempio n. 1
0
        private void Main_Load(object sender, EventArgs e)
        {
            Login login = new Login();

            if (login.ShowDialog() == DialogResult.Cancel)
            {
                this.Close();
            }
            if (Sharevariables.IsTenantAdministrator)
            {
                buttonTenantManager.Visible      = true;
                buttonDressManagement.Visible    = false;
                buttonCustomerManagement.Visible = false;
                buttonStatistic.Visible          = false;
                buttonOrderManagement.Visible    = false;
                buttonUserManager.Visible        = false;
            }
            else if (Sharevariables.StoreId == 0)
            {
                buttonTenantManager.Visible      = false;
                buttonDressManagement.Visible    = false;
                buttonCustomerManagement.Visible = false;
                buttonStatistic.Visible          = false;
                buttonOrderManagement.Visible    = false;
                buttonUserManager.Visible        = true;
            }
            else
            {
                if (Sharevariables.UserName.Length == 0)
                {
                    this.Close();
                }
                int ul = Sharevariables.UserLevel;
                switch (ul)
                {
                case 2:
                    this.buttonDressManagement.Visible    = true;
                    this.buttonOrderManagement.Visible    = true;
                    this.buttonTenantManager.Visible      = false;
                    this.buttonUserManager.Visible        = false;
                    this.buttonCustomerManagement.Visible = true;
                    break;

                case 16:
                    this.buttonDressManagement.Visible    = false;
                    this.buttonOrderManagement.Visible    = false;
                    this.buttonTenantManager.Visible      = false;
                    this.buttonUserManager.Visible        = false;
                    this.buttonCustomerManagement.Visible = true;
                    break;

                default:
                    buttonCustomerManagement.Visible   = false;
                    buttonDressManagement.Visible      = true;
                    this.buttonTenantManager.Visible   = false;
                    this.buttonUserManager.Visible     = false;
                    this.buttonOrderManagement.Visible = true;
                    break;
                }
                //if (Sharevariables.StoreId == 0)
                //{
                // all admin
                //Form storeSelection = new StoreSelection();
                //storeSelection.ShowDialog();

                //}
                Data customerChannels = ShardDb.getChannels();
                if (!customerChannels.Success)
                {
                    this.Close();
                    return;
                }
                foreach (DataRow row in customerChannels.DataTable.Rows)
                {
                    Sharevariables.CustomerChannels.Add(Convert.ToInt16(row["id"]), row["name"].ToString());
                }

                Data customerStatuses = ShardDb.getStatuses();
                if (!customerStatuses.Success)
                {
                    this.Close();
                    return;
                }
                foreach (DataRow row in customerStatuses.DataTable.Rows)
                {
                    Sharevariables.CustomerStatuses.Add(Convert.ToInt16(row["id"]), row["name"].ToString());
                }

                Data customerCities = ShardDb.getCities();
                if (!customerCities.Success)
                {
                    this.Close();
                    return;
                }
                foreach (DataRow row in customerCities.DataTable.Rows)
                {
                    Sharevariables.CustomerCities.Add(Convert.ToInt16(row["id"]), row["name"].ToString());
                }

                getOrderStatistic();
                getOrderStatuses();
            }

            Logger.getLogger().info("Program started.");
            this.Visible = true;
        }