public override void AfterCancelEdit() { context.Refresh(RefreshMode.StoreWins, context.Delivery.First(p => p.DeliveryID == PrimaryID)); context.Refresh(RefreshMode.StoreWins, context.DeliveryDetails.Where(p => p.DeliveryID == PrimaryID)); //取得所有新增的出貨單明細 foreach (var AddedEntry in context.ObjectStateManager .GetObjectStateEntries(EntityState.Added)) { if (!AddedEntry.IsRelationship) { if (AddedEntry.Entity is DeliveryDetails) { var curr = ((DeliveryDetails)(AddedEntry.Entity)); deliveryDetailsBindingSource.Remove(curr); } } } //取消後 if (deliveryIDLabel.Text == String.Empty) { //取消後若無記錄,客戶簡稱、銷售金額、營業稅與總計金額清空 attribNameLabel.Text = ""; subTotalTextBox.Text = ""; valueAddTaxTextBox.Text = ""; amountTextBox.Text = ""; } else { //取消後若有記錄,取得目前客戶的: //客戶簡稱、銷售金額、營業稅與總計金額 //客戶簡稱 attribNameLabel.Text = XIN.GetCustomerAttribName( customerIDTextBox.Text); //銷售金額 subTotalTextBox.Text = ((Delivery)(deliveryBindingSource.Current)) .SubTotal.ToString("#,##0"); //營業稅 valueAddTaxTextBox.Text = ((Delivery)(deliveryBindingSource.Current)) .ValueAddTax.ToString("#,##0"); //總計金額 amountTextBox.Text = ((Delivery)(deliveryBindingSource.Current)) .Amount.ToString("#,##0"); } //變更DataGridView控制項的虛擬模式 deliveryDetailsDataGridView.VirtualMode = false; }
private void customerIDTextBox_Validated(object sender, EventArgs e) { if (customerIDTextBox.Text == String.Empty) { //假如沒有輸入客戶編號,清空客戶簡稱 attribNameTextBox.Text = ""; } else { //取得客戶簡稱 attribNameTextBox.Text = XIN.GetCustomerAttribName( customerIDTextBox.Text); } }