public int InsertPartsDetail(PartsDetail partsDetail) { try { var id = 0; decimal unitPrice = 0; partsDetail.CompanyId = _user.CompanyId; foreach (var item in partsDetail.StoreInfoes) { item.CompanyId = _user.CompanyId; item.PartsId = partsDetail.PartsId; unitPrice = (decimal)item.UnitPrice; } partsDetail.UnitPrice = unitPrice; if (partsDetail.PartsId > 0) { var storeInf = partsDetail.StoreInfoes.FirstOrDefault(); partsDetail.StoreInfoes = null; id = _partsDetailsRepo.UpdatePartsDetail(partsDetail); _storeInfoRepo.InsertStoreInfo(storeInf); _storeInfoRepo.save(); } else { id = _partsDetailsRepo.InsertPartsDetail(partsDetail); } return(id); } catch (Exception ex) { throw ex; } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { try { if (dtgItems.SelectedItem != null) { PartsDetail oPartsDetail = (PartsDetail)dtgItems.SelectedItem; ucAddEditPartsDetail oucAddEditPartsDetail = new ucAddEditPartsDetail(oPartsDetail, true); winDialog oDialog = new winDialog(oucAddEditPartsDetail) { ShowInTaskbar = true, WindowTitle = "Edit Parts", Height = 240, Width = 560 }; oDialog.ShowDialog(); dtgItems.Items.Refresh(); } else { MessageBox.Show("Please select a parts"); } } catch (Exception) { MessageBox.Show("Can not add parts"); } }
private void OpenUsePartWindow() { try { if (dtgItems.SelectedItem != null) { PartsDetail oPartsDetail = (PartsDetail)dtgItems.SelectedItem; winDialog oDialog = new winDialog(new ucDelivery(oPartsDetail)) { ShowInTaskbar = true, WindowTitle = "Use tool in car", Height = 530, Width = 600 }; oDialog.ShowDialog(); dtgItems.Items.Refresh(); } else { MessageBox.Show("Please select a part"); } } catch (Exception) { MessageBox.Show("Can not use part"); } }
private void dtgItems_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (dtgItems.SelectedItem != null) { PartsDetail oPartsDetail = (PartsDetail)dtgItems.SelectedItem; winDialog oDialog = new winDialog(new ucDelivery(oPartsDetail)) { ShowInTaskbar = false, Height = 530, Width = 600 }; oDialog.ShowDialog(); dtgItems.Items.Refresh(); } else { MessageBox.Show("Please select a tool"); } } catch (Exception) { MessageBox.Show("Can not use part"); } }
public ucDelivery(PartsDetail oPartsDetail) { InitializeComponent(); this.oPartsDetail = oPartsDetail; InitializeWindow(); oAllCarList = App.oAllCarList; this.oAllReapirsHistory = App.oAllRepairsHistory; dtgCars.ItemsSource = oAllCarList; }
public ucAddEditPartsDetail(PartsDetail oPartsDetail, bool isEdit) { InitializeComponent(); try { this.oPartsDetail = oPartsDetail; this.isEdit = isEdit; cboParts.ItemsSource = new Parts().SelectAll(); cboManufacturer.ItemsSource = new Manufacturer().SelectAll(); if (isEdit) { InitializeWindow(); } } catch (Exception) { MessageBox.Show("Can not initialize window"); } }
private void btnAddPartsDetail_Click(object sender, RoutedEventArgs e) { try { PartsDetail oPartsDetail = new PartsDetail(); ucAddEditPartsDetail oucAddEditPartsDetail = new ucAddEditPartsDetail(oPartsDetail, false); winDialog oDialog = new winDialog(oucAddEditPartsDetail) { ShowInTaskbar = true, WindowTitle = "Add a new Parts", Height = 240, Width = 560 }; oDialog.ShowDialog(); dtgItems.Items.Refresh(); } catch (Exception) { MessageBox.Show("Can not add parts"); } }
public int UpdatePartsDetail(PartsDetail partsDetail) { _context.PartsDetails.AddOrUpdate(partsDetail); _context.SaveChanges(); return(1); }
public int InsertPartsDetail(PartsDetail partsDetail) { _context.PartsDetails.Add(partsDetail); _context.SaveChanges(); return(partsDetail.PartsId); }