public int SaveChanges(bool IsNewRecord) { OrderProducts ObjTable; if (IsNewRecord) { ObjTable = new OrderProducts(); dataContext.OrderProducts.InsertOnSubmit(ObjTable); } else { ObjTable = dataContext.OrderProducts.Single(p => p.Code.Equals(this.Code)); } try { #region Save Detail Controls PropertyInfo piMasterCode = ObjTable.GetType().GetProperty("OrderCode"); piMasterCode.SetValue(ObjTable, MasterCode, new object[] { }); string BaseID = this.ToString().Substring(3, this.ToString().Length - 3); Tools tools = new Tools(); tools.AccessList = tools.GetAccessList(BaseID); foreach (WebControl wc in ObjectList) { string Property = wc.ID.Substring(3, wc.ID.Length - 3); PropertyInfo pi = ObjTable.GetType().GetProperty(Property); string FullPropName = BaseID + "." + Property; if (tools.HasAccess("Edit", BaseID + "." + Property)) { pi.SetValue(ObjTable, Tools.GetControlValue(wc), new object[] { }); } } #endregion dataContext.SubmitChanges(); } catch (Exception exp) { throw exp; } return(ObjTable.Code); }
public bool UpdateTransactionCode(int OrderCode, int UserTransactionCode) { try { OrdersDataContext dc = new OrdersDataContext(); Orders CurOrder = dc.Orders.SingleOrDefault(p => p.Code.Equals(OrderCode)); CurOrder.UserTransactionCode = UserTransactionCode; dc.SubmitChanges(); return(true); } catch (Exception err) { HttpContext.Current.Response.Write(err.Message); return(false); } }