public void SaveMainRowExc() { if (TransactionHeader.DetailsList != null) { foreach (var Item in TransactionHeader.DetailsList) { var save = Item.Glserial == 0; var saveRow = new TblPromoDetail(); saveRow.InjectFrom(Item); saveRow.Glserial = TransactionHeader.GlSerial; if (save) { if (AllowAdd) { Loading = true; Client.UpdateAndInsertTblPromoDetailAsync(saveRow, save, TransactionHeader.DetailsList.IndexOf(Item), LoggedUserInfo.DatabasEname); } else { MessageBox.Show("You are Not Allowed to Add"); } } else { if (AllowUpdate) { Loading = true; Client.UpdateAndInsertTblPromoDetailAsync(saveRow, save, TransactionHeader.DetailsList.IndexOf(Item), LoggedUserInfo.DatabasEname); } else { MessageBox.Show("You are Not Allowed to Update"); } } } //var valiationCollection = new List<ValidationResult>(); // var isvalid = Validator.TryValidateObject(TransactionHeader.DetailsList, new ValidationContext(SelectedDetailRow, null, null), valiationCollection, true); //if (isvalid) //{ // var save = SelectedDetailRow.Iserial == 0; //} } }
private int DeleteTblPromoDetail(TblPromoDetail row, string company) { using (var db = new ccnewEntities(GetSqlConnectionString(company))) { var oldRow = (from e in db.TblPromoDetails where e.Glserial == row.Glserial select e).SingleOrDefault(); if (oldRow != null) { db.DeleteObject(oldRow); } db.SaveChanges(); } return(row.Glserial); }
public TblPromoDetail UpdateAndInsertTblPromoDetail(TblPromoDetail newRow, bool save, int index, out int outindex, string company) { using (var db = new ccnewEntities(GetSqlConnectionString(company))) { outindex = index; if (save) { db.TblPromoDetails.AddObject(newRow); } else { var oldRow = (from e in db.TblPromoDetails where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, db); } } db.SaveChanges(); return(newRow); } }