private void Button_Click(object sender, RoutedEventArgs e) { string deal1_id; if (deal_idd == null) //add new deal { deal1_id = DateTime.Now.ToString("yyyyMMdd-HHMMss"); Deal deal1 = new Deal(deal1_id, deal_total.Text, deal_type.Text, deal_desc.Text, service.shift.shift_id); service.shift.deal_list.Add(deal1); DB_connector.AddNewDeal(deal1); //insert the deal to database this.Close(); } else //edit { deal1_id = deal_idd; Deal deal2 = new Deal(deal1_id, deal_total.Text, deal_type.Text, deal_desc.Text, service.shift.shift_id); foreach (var m in service.shift.deal_list) { if (m.deal_id.Equals(deal_idd)) { service.shift.deal_list.Remove(m); DB_connector.UpdateDeal(deal2, deal_idd); //update deal in DB //DB_connector.RemoveDeal(m); break; } } service.shift.deal_list.Add(deal2); //DB_connector.AddNewDeal(deal2); this.Close(); } }
private void Button_Click(object sender, RoutedEventArgs e) { string deal1_id = "note"; //deal id use guid Deal deal1 = new Deal(deal1_id, "0", "note", note.Text, service.shift.shift_id); service.shift.deal_list.Add(deal1); DB_connector.AddNewDeal(deal1); this.Close(); }