2016-01-05 6 views
-1

Так что я пытаюсь создать что-то, что будет хранить номер счета вместе с пользователем; поэтому я создал класс и расширил базовый класс. Я нахожу это очень трудно объяснить, почему так я просто поместить код в первый:Пользовательский список <Of Something>

Базовый класс:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Drawing; 
namespace AMS 
{ 
    public class AMSclient 
    { 
     private string clientFirstName;  //Client first name 
     private string clientLastName;  //Client last name 
     private string phoneNumber;   //Client phone number. 
     private string streetAddress;  //Client street address. 
     private string state;    //Client state. 
     private string zip;     //Client zip. 
     private string paymentMethod;  //Client payment method (Credit card, BTC, cash) 
     private DateTime dateCreated;  //Date + time client is created. 
     private string email;    //Client email. 
     private int lockedUser;    //If you need a password to view client. 
     private string userPassword;  //empty is default if lockedUser != 1 
     private string groupName;   //If client is in group. 
     private string clientImage;   //Client Image. 
     private long clientID;    //Clients ID number. 
     #region Getters/Setters and all that good shit. 
     public string ClientFirstName 
     { 
      get 
      { 
       return clientFirstName; 
      } 

      set 
      { 
       clientFirstName = value; 
      } 
     } 

     public string ClientLastName 
     { 
      get 
      { 
       return clientLastName; 
      } 

      set 
      { 
       clientLastName = value; 
      } 
     } 

     public string PhoneNumber 
     { 
      get 
      { 
       return phoneNumber; 
      } 

      set 
      { 
       phoneNumber = value; 
      } 
     } 

     public string StreetAddress 
     { 
      get 
      { 
       return streetAddress; 
      } 

      set 
      { 
       streetAddress = value; 
      } 
     } 

     public string State 
     { 
      get 
      { 
       return state; 
      } 

      set 
      { 
       state = value; 
      } 
     } 

     public string Zip 
     { 
      get 
      { 
       return zip; 
      } 

      set 
      { 
       zip = value; 
      } 
     } 

     public string PaymentMethod 
     { 
      get 
      { 
       return paymentMethod; 
      } 

      set 
      { 
       paymentMethod = value; 
      } 
     } 

     public DateTime DateCreated 
     { 
      get 
      { 
       return dateCreated; 
      } 

      set 
      { 
       dateCreated = value; 
      } 
     } 

     public string Email 
     { 
      get 
      { 
       return email; 
      } 

      set 
      { 
       email = value; 
      } 
     } 

     public int LockedUser 
     { 
      get 
      { 
       return lockedUser; 
      } 

      set 
      { 
       lockedUser = value; 
      } 
     } 

     public string UserPassword 
     { 
      get 
      { 
       return userPassword; 
      } 

      set 
      { 
       userPassword = value; 
      } 
     } 

     public string GroupName 
     { 
      get 
      { 
       return groupName; 
      } 

      set 
      { 
       groupName = value; 
      } 
     } 
     public string imageClient 
     { 
      get 
      { 
       return clientImage; 
      } 

      set 
      { 
       clientImage = value; 
      } 

     } 

     public long clientsID 
     { 
      get 
      { 
       return clientID; 
      } 

      set 
      { 
       clientID = value; 
      } 
     } 



     #endregion 

     //Contruct that shit, and fuck you I like the 'this'. 
     public AMSclient(string first, string last, string number, string address, 
     string state, string zip, string method, DateTime date, string email, int locked, string userPass, string group, string i) 
     { 
      this.clientFirstName = first; 
      this.clientLastName = last; 
      this.phoneNumber = number; 
      this.streetAddress = address; 
      this.state = state; 
      this.zip = zip; 
      this.paymentMethod = method; 
      this.dateCreated = date; 
      this.email = email; 
      this.lockedUser = locked; 
      this.userPassword = userPass; 
      this.groupName = group; 
      this.clientImage = i; 

      //ClientID set and save via Settings. 
      this.clientID = AMS.Properties.Settings.Default.clientIDValue; 
      this.clientID += 1; 
      AMS.Properties.Settings.Default.clientIDValue += 1; 
      AMS.Properties.Settings.Default.Save(); 



     } 
    } 
} 

Расширение Класс:

using System; 
using System.Collections; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace AMS 
{ 

    public class AMSInvoiceList : AMSclient 
    { 
     private AMSclient c; 
     private string btcInvoiceNum; 

     public AMSInvoiceList(AMSclient client, string invoicenum) : base(client.ClientFirstName, client.ClientLastName,client.PhoneNumber, 
      client.StreetAddress, client.State, client.Zip, client.PaymentMethod, client.DateCreated, client.Email, client.LockedUser, client.UserPassword, client.GroupName, client.imageClient) 
     { 
      this.c = client; 
      this.btcInvoiceNum = invoicenum; 
     } 

    } 
} 

Класс Счет:

//Creates an invoice number for the BTC Transaction. 
     //1000 - "1" before the "0"s represent a BTC type invoice. 
     public string createInvoiceNumber(long clientid) 
     { 
      AMS.Properties.Settings.Default.btcInvoiceValue += 1; 
      return clientid + "-" + "1000" + AMS.Properties.Settings.Default.btcInvoiceValue; 

     } 
    } 

То, что я пытаюсь сделать, это сделать так, чтобы я мог хранить счета этого метода оплаты в «обычном» t список ype; Я перечислю, что будет содержать все из базового класса + номер счета-фактуры, который был создан, я надеюсь, что это имеет смысл. Итак, если я делаю это (просто сказать):

AMSInvoiceList a = new AMSInvoiceList(client, "edsudiopjsipodjips"); 
     List<AMSInvoiceList> ax = new List<AMSInvoiceList>(); 

что, когда я делаю счет, я могу просто позвонить AMSInvoiceList a = new AMSInvoiceList(client, "edsudiopjsipodjips");, а затем добавить его в глобальный список («топор», например); так что, когда я хочу, я могу просто позвонить ax[0], и вся информация из базового класса (вся информация о клиенте) будет отображаться вместе с номером счета-фактуры. Надеюсь, в этом есть смысл, ребята, я просто не могу сделать головы или хвосты здесь!

+4

Есть ли причина, по которой вы не можете использовать словарь '? – Ani

+5

Первое, что нужно сделать: узнать о автоматически реализованных свойствах. Они резко уменьшат размер вашего кода *. –

+0

Я никогда не использовал словарь, который действительно застрял в списке Можете ли вы дать мне пример того, как это могло бы пойти + какая-то информация в ответе :)? –

ответ

0

Dictionary<String, AMSClient> - ответ (от ananthonlinecomment), который решил мою проблему, спасибо вам, ребята!

Смежные вопросы