public StockWindow(StockAssignmentView StockAssignment) : this() { s = new Stock(); s.ID = StockAssignment.SrlNo; s.StockEnd = StockAssignment.EndNumber; s.StockStart = StockAssignment.StartNumber; Employee selectedEmp = emp.SingleOrDefault(x => x.Name == StockAssignment.EmployeeName); s.UserId = selectedEmp.Id; s.Employee = selectedEmp; s.BookNo = StockAssignment.BookNo; s.cost = StockAssignment.CostPerSlip; s.Date = StockAssignment.AddDate; int tempDays; if (int.TryParse(ExpectedDayBox.Text, out tempDays)) { s.DeliveryTime = tempDays; } s.desc = StockAssignment.Description; isUpdate = true; AssignCombo.IsEnabled = false; filldetails(s); }
private void UpdateStockButton_Click(object sender, RoutedEventArgs e) { if (StockAssignmentDatagrid.SelectedItems.Count != 1) { MessageBox.Show("Please select 1 Entry to edit.", "Info"); return; } StockAssignmentView AssignmentEntry = (StockAssignmentView)StockAssignmentDatagrid.SelectedItem; StockWindow window = new StockWindow(AssignmentEntry); window.Closed += window_Closed; window.Show(); }
private void ViewStockButton_Click(object sender, RoutedEventArgs e) { if (StockAssignmentDatagrid.SelectedItems.Count != 1) { MessageBox.Show("Please select one stock entry.."); return; } else { StockAssignmentView stock = (StockAssignmentView)StockAssignmentDatagrid.SelectedItem; ViewUnassignedStock stockWin = new ViewUnassignedStock(stock); stockWin.Show(); } }
public ViewUnassignedStock(StockAssignmentView stock) { InitializeComponent(); BillingDataDataContext db = new BillingDataDataContext(); List <string> UsedConnsignmentNo = db.Transactions.Where(x => String.Compare(stock.StartNumber, x.ConnsignmentNo) <= 0 && String.Compare(stock.EndNumber, x.ConnsignmentNo) >= 0) .OrderBy(y => y.ConnsignmentNo) .Select(x => x.ConnsignmentNo).ToList(); string seriesCommon = new string((stock.StartNumber.ToCharArray().Where(x => char.IsLetter(x) == true)).ToArray()); int seriesStart = int.Parse(stock.StartNumber.Substring(seriesCommon.Length)); int seriesEnd = int.Parse(stock.EndNumber.Substring(seriesCommon.Length)); List <int> AvailableConn = Enumerable.Range(seriesStart, seriesEnd - seriesStart + 1).ToList(); List <int> UsedConn = UsedConnsignmentNo.Select(x => int.Parse(new string(x.ToCharArray().Where(y => char.IsDigit(y)).ToArray()))).ToList(); List <string> UnusedConn = AvailableConn.Except(UsedConn).Select(x => seriesCommon + x.ToString()).ToList(); CollectionViewSource viewSource = (CollectionViewSource)FindResource("ListSource"); viewSource.Source = UnusedConn; }
private void DeleteStockButton_Click(object sender, RoutedEventArgs e) { if (StockAssignmentDatagrid.SelectedItems.Count != 1) { MessageBox.Show("Please select delete Entry to edit.", "Info"); return; } if (MessageBox.Show("Are you sure want to delete this entry. This cant be undone!!", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { StockAssignmentView AssignmentEntry = (StockAssignmentView)StockAssignmentDatagrid.SelectedItem; BillingDataDataContext db = new BillingDataDataContext(); Stock selectedStock = db.Stocks.SingleOrDefault(x => x.ID == AssignmentEntry.SrlNo); if (selectedStock == null) { MessageBox.Show("Selected stock doesn't exists..", "Error"); return; } db.Stocks.DeleteOnSubmit(selectedStock); db.SubmitChanges(); } }