Exemple #1
0
        public static void FillShopsLV(IListView listView, IModel model)
        {
            try {
                listView.Clear();
                listView.AddColumn(Localizer.LS(LSID.Name), 120, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Address), 120, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Telephone), 120, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.WebSite), 120, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Email), 120, true, BSDTypes.HorizontalAlignment.Left);

                var records = model.QueryShops();
                foreach (Shop rec in records)
                {
                    var item = listView.AddItem(rec,
                                                rec.Name,
                                                rec.Address,
                                                rec.Telephone,
                                                rec.WebSite,
                                                rec.Email
                                                );
                }

                listView.Sort(0, BSDTypes.SortOrder.Ascending);
            } catch (Exception ex) {
                fLogger.WriteError("FillShopsLV()", ex);
            }
        }
Exemple #2
0
        public static void FillPricelistLV(IListView listView, IModel model, IList <Transfer> records)
        {
            if (listView == null)
            {
                return;
            }

            try {
                listView.Clear();
                listView.AddColumn(Localizer.LS(LSID.Type), 80, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Brand), 50, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Item), 140, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Shop), 180, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Date), 80, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.UnitPrice), 80, true, BSDTypes.HorizontalAlignment.Right);

                foreach (Transfer rec in records)
                {
                    if (rec.Type == TransferType.Purchase && rec.UnitPrice != 0.0f)
                    {
                        ItemType itemType = rec.ItemType;
                        var      itemRec  = model.GetRecord(itemType, rec.ItemId);
                        string   itName   = (itemRec == null) ? string.Empty : itemRec.ToString();

                        var    brandedItem = itemRec as IBrandedItem;
                        string brand       = (brandedItem == null) ? "-" : brandedItem.Brand;

                        listView.AddItem(rec,
                                         Localizer.LS(ALData.ItemTypes[(int)rec.ItemType].Name),
                                         brand,
                                         itName,
                                         rec.Shop,
                                         ALCore.GetDateStr(rec.Timestamp),
                                         ALCore.GetDecimalStr(rec.UnitPrice)
                                         );
                    }
                }

                listView.Sort(2, BSDTypes.SortOrder.Ascending);
            } catch (Exception ex) {
                fLogger.WriteError("FillPricelistLV()", ex);
            }
        }
Exemple #3
0
        public static void FillInhabitantLV(IListView listView, ILabel footer, IModel model)
        {
            try {
                listView.Clear();
                listView.AddColumn(Localizer.LS(LSID.Name), 200, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Sex), 50, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Quantity), 50, true, BSDTypes.HorizontalAlignment.Right);
                listView.AddColumn(Localizer.LS(LSID.SpeciesS), 150, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.State), 80, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.Aquarium), 150, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.InclusionDate), 150, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.ExclusionDate), 150, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn(Localizer.LS(LSID.LifeSpan), 150, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn("Temp", 100, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn("PH", 100, true, BSDTypes.HorizontalAlignment.Left);
                listView.AddColumn("GH", 100, true, BSDTypes.HorizontalAlignment.Left);

                Average            avgLifespan = new Average();
                IList <Inhabitant> records     = model.QueryInhabitants();
                foreach (Inhabitant rec in records)
                {
                    Species spc = model.GetRecord <Species>(rec.SpeciesId);

                    SpeciesType spType;
                    string      spName, spTemp, spGH, spPH;
                    if (spc == null)
                    {
                        spType = SpeciesType.Fish;
                        spName = string.Empty;
                        spTemp = string.Empty;
                        spGH   = string.Empty;
                        spPH   = string.Empty;
                    }
                    else
                    {
                        spType = spc.Type;
                        spName = spc.Name;
                        spTemp = spc.GetTempRange();
                        spGH   = spc.GetGHRange();
                        spPH   = spc.GetPHRange();
                    }

                    SpeciesType speciesType = model.GetSpeciesType(rec.SpeciesId);
                    ItemType    itemType    = ALCore.GetItemType(speciesType);

                    rec.Quantity = model.QueryInhabitantsCount(rec.Id, itemType);
                    bool fin = (rec.Quantity == 0);

                    if (fin && ALSettings.Instance.HideLosses)
                    {
                        continue;
                    }

                    int      currAqmId = 0;
                    DateTime inclusionDate, exclusionDate;
                    model.GetInhabitantDates(rec.Id, itemType, out inclusionDate, out exclusionDate, out currAqmId);

                    string aqmName       = model.GetRecordName(ItemType.Aquarium, currAqmId);
                    string strInclusDate = ALCore.IsZeroDate(inclusionDate) ? string.Empty : ALCore.GetDateStr(inclusionDate);
                    string strExclusDate = ALCore.IsZeroDate(exclusionDate) || !fin ? string.Empty : ALCore.GetDateStr(exclusionDate);

                    DateTime endDate     = ALCore.IsZeroDate(exclusionDate) || !fin ? DateTime.Now.Date : exclusionDate;
                    string   strLifespan = ALCore.IsZeroDate(inclusionDate) ? string.Empty : ALCore.GetTimespanText(inclusionDate, endDate);

                    if (!ALCore.IsZeroDate(exclusionDate))
                    {
                        int iDays = (exclusionDate - inclusionDate).Days;
                        avgLifespan.AddValue(iDays);
                    }

                    ItemState itemState;
                    string    strState = model.GetItemStateStr(rec.Id, itemType, out itemState);
                    if (itemState == ItemState.Unknown || !fin)
                    {
                        strState = Localizer.LS(ALData.ItemStates[(int)rec.State]);
                    }
                    string sx = ALCore.IsAnimal(spType) ? Localizer.LS(ALData.SexNames[(int)rec.Sex]) : "–";

                    var item = listView.AddItem(rec,
                                                rec.Name,
                                                sx,
                                                rec.Quantity.ToString(),
                                                spName,
                                                strState,
                                                aqmName,
                                                strInclusDate,
                                                strExclusDate,
                                                strLifespan,
                                                spTemp,
                                                spPH,
                                                spGH
                                                );

                    if (fin)
                    {
                        item.SetForeColor(BSDConsts.Colors.Gray); // death, sale or gift?
                    }
                }

                listView.Sort(6, BSDTypes.SortOrder.Ascending);

                footer.Text = string.Format(Localizer.LS(LSID.LifeExpectancy) + ": {0}", ALCore.GetTimespanText((int)avgLifespan.GetResult()));
            } catch (Exception ex) {
                fLogger.WriteError("FillInhabitantLV()", ex);
            }
        }