/// <summary> /// 2 metody statyczne jakie obsługują serializacje /// </summary> /// <param name="client"></param> /// <param name="filePath"></param> public static void Serialize(Clients client, string filePath) { XmlSerializer serializer = new XmlSerializer(typeof(Clients)); TextWriter textWriter = new StreamWriter(filePath); serializer.Serialize(textWriter, client); textWriter.Close(); }
/// <summary> /// Metoda za pomącą jakiej tworzy nowego klienta lub edytuje dane /// </summary> /// <param name="value"></param> /// <returns></returns> public static bool AddOrEditClient(Clients value) { if (value.ClientId == 0) { value.ClientId = context.Clients.Count() > 0 ? context.Clients.Max(x => x.ClientId) + 1 : 1; context.Clients.Add(value); } else { Clients client = context.Clients.FirstOrDefault(x => x.ClientId == value.ClientId); if (client != null) { client.ClientName = value.ClientName; client.Address = value.Address; client.Discount = value.Discount; client.Vip = value.Vip; } } context.SaveChanges(); return true; }
public NewClientForm(Clients clientsData) { this.data = clientsData; InitializeComponent(); this.clientsBindingSource.DataSource = data; }