private void myRadDataForm_DeletingItem(object sender, System.ComponentModel.CancelEventArgs e) { Window lWindows = Models.CommonFunction.GetApplicationWindow(); if (MessageBox.Show(lWindows, "Are you sure you want to delete?", "Delete", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { e.Cancel = true; } else { SunSeven.Models.HSEmployee lItem = myRadDataForm.CurrentItem as SunSeven.Models.HSEmployee; DataSource.JSDataContext lDataContext; lDataContext = new CommonFunction().JSDataContext(); try { var lDelEmpDept = lDataContext.Emp_Depts.Where(p => p.EmployeeId == lItem.Id); lDataContext.Emp_Depts.DeleteAllOnSubmit(lDelEmpDept); var lDelItem = lDataContext.Employees.Single(p => p.Id == lItem.Id); lDataContext.Employees.DeleteOnSubmit(lDelItem); lDataContext.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); e.Cancel = true; } } }
private int saveInvoiceStatus(string invoiceNo) { DataSource.Invoice lInvoice = lDataContext.Invoices.SingleOrDefault(p => p.InvoiceNo == invoiceNo); try { lInvoice.Status = 3; // Returned lDataContext.SubmitChanges(); return(0); } catch (Exception ex) { MessageBox.Show("Save Status : Can not find Invoice No [" + invoiceNo + "]"); //MessageBox.Show(ex.Message); return(-1); } }
private void OnApplyCommandExecuted(object id) { var luserScreen = lDataContext.UserScreens.Where(p => p.UserId == this.UserId); lDataContext.UserScreens.DeleteAllOnSubmit(luserScreen); foreach (JSScreen l in this.Where(p => p.IsSelected == true)) { DataSource.UserScreen lNewScreen = new DataSource.UserScreen(); lNewScreen.UserId = this.UserId; lNewScreen.ScreenId = l.ScreenAvailable.ScreenId; lNewScreen.Default = l.IsDefault; lDataContext.UserScreens.InsertOnSubmit(lNewScreen); } try { lDataContext.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }