public StorageRessourceTypeEditForm(RPN_API_Web web, int id)
        {
            InitializeComponent();

            Icon = Resources.RPN_Sharp;

            if (Program.IsFullscreen)
            {
                WindowState = FormWindowState.Maximized;
            }

            storageRessourceTypeFormSkin.FlatColor = Program.UIColor;

            this.web = web;
            this.id  = id;

            // Load Storage Ressource
            if (id != -1)
            {
                RPN_API_Json.RessourceTypeData data = web.GetRessourceTypeFromId(id);
                nameFlatTextBox.Text     = data.Name;
                massNumericUpDown.Value  = data.Mass;
                priceNumericUpDown.Value = data.Price;
                if (data.Icon != null)
                {
                    ressourcePictureBox.Image = web.Base64ToImage(data.Icon);
                }
            }
        }
        public StorageDataEditForm(RPN_API_Web web, int storage_id, int storage_data_id)
        {
            InitializeComponent();
            Icon = Resources.RPN_Sharp;

            if (Program.IsFullscreen)
            {
                WindowState = FormWindowState.Maximized;
            }

            storageDataFormSkin.FlatColor = Program.UIColor;

            ressourceTypeFlatComboBox.HoverColor = Program.UIColor;
            belongtoFlatComboBox.HoverColor      = Program.UIColor;

            this.web             = web;
            this.storage_id      = storage_id;
            this.storage_data_id = storage_data_id;


            foreach (RPN_API_Json.RessourceTypeData ressourceTypeData in web.GetRessourceType())
            {
                ressourceTypeFlatComboBox.Items.Add(ressourceTypeData.Name);
            }

            foreach (RPN_API_Json.InternalData internalData in web.GetAllUsers())
            {
                belongtoFlatComboBox.Items.Add(internalData.Username);
            }

            if (storage_data_id != -1)
            {
                RPN_API_Json.StorageData       currentStorageData   = web.GetStorageDataFromId(storage_data_id);
                RPN_API_Json.RessourceTypeData currentRessourceType = web.GetRessourceTypeFromId(currentStorageData.RessourceType);
                RPN_API_Json.InternalData      currentBelongTo      = web.GetUser(currentStorageData.BelongTo);

                foreach (RPN_API_Json.RessourceTypeData ressourceTypeData in web.GetRessourceType())
                {
                    if (currentRessourceType.Name.Equals(ressourceTypeData.Name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        ressourceTypeFlatComboBox.Text = ressourceTypeData.Name;
                    }
                }

                foreach (RPN_API_Json.InternalData internalData in web.GetAllUsers())
                {
                    if (currentBelongTo.Username.Equals(internalData.Username, StringComparison.InvariantCultureIgnoreCase))
                    {
                        belongtoFlatComboBox.Text = internalData.Username;
                    }
                }

                quantityNumericUpDown.Value = currentStorageData.Quantity;
            }
        }
Ejemplo n.º 3
0
        private void storageDetailDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (storageDetailDataGridView.SelectedCells.Count > 0)
            {
                int storage_data_id = int.Parse(storageDetailDataGridView.Rows[storageDetailDataGridView.SelectedCells[0].RowIndex].Cells[0].Value.ToString());

                RPN_API_Json.StorageData storageData = web.GetStorageDataFromId(storage_data_id);

                RPN_API_Json.RessourceTypeData ressourceType = web.GetRessourceTypeFromId(storageData.RessourceType);
                quantityFlatLabel.Text  = "Quantité : " + storageData.Quantity.ToString("N0");
                unitPriceFlatLabel.Text = "Prix Unitaire : " + ressourceType.Price.ToString("C0");
                rentFlatLabel.Text      = (storageData.Quantity * ressourceType.Price).ToString("C0");
                belongToFlatLabel.Text  = storageData.BelongTo;
            }
        }
Ejemplo n.º 4
0
        private void ReloadStorageDetailData(int storage_id)
        {
            storageDetailDataGridView.Rows.Clear();

            if (storage_id != -1)
            {
                int space_used = 0;
                int pc_used;
                foreach (RPN_API_Json.StorageData storageData in web.GetStorageDataFromStorageId(storage_id))
                {
                    RPN_API_Json.RessourceTypeData ressourceTypeData = web.GetRessourceTypeFromId(storageData.RessourceType);
                    storageDetailDataGridView.Rows.Add(storageData.Id, ressourceTypeData.Name, storageData.Quantity, storageData.Quantity * ressourceTypeData.Mass);;
                    space_used += ressourceTypeData.Mass * storageData.Quantity;
                }

                RPN_API_Json.Storage         storage     = web.GetStorageFromId(storage_id);
                RPN_API_Json.StorageTypeData storageType = web.GetStorageTypeFromId(storage.StorageTypeId);

                storageTypeFlatLabel.Text = "Type : " + storageType.Name;
                pc_used = (int)(((float)space_used / (float)storageType.Size) * 100);
                storageSizeflatLabel.Text = "Taille : " + space_used.ToString("N0") + "/" + storageType.Size.ToString("N0") + " (Soit " + pc_used + "%)";
                if (pc_used >= 100)
                {
                    flatProgressBar1.Value = 100;
                }
                else if (pc_used <= 0)
                {
                    flatProgressBar1.Value = 0;
                }
                else
                {
                    flatProgressBar1.Value = pc_used;
                }
                ownerFlatLabel.Text = storage.Owner;
            }
            else
            {
                storageTypeFlatLabel.Text = "Type : X";
                storageSizeflatLabel.Text = "Taille : X/X (Soit XX%)";
                flatProgressBar1.Value    = 100;
                quantityFlatLabel.Text    = "Quantité : X";
                unitPriceFlatLabel.Text   = "Prix Unitaire : X€";
                rentFlatLabel.Text        = "X€";
            }

            storageDetailDataGridView.Refresh();
        }