public int SaveChanges(bool IsNewRecord) { News ObjTable; if (IsNewRecord) { ObjTable = new News(); ObjTable.CreateDate = DateTime.Now; ObjTable.NewsDate = DateTime.Now; dataContext.News.InsertOnSubmit(ObjTable); } else { ObjTable = dataContext.News.Single(p => p.Code.Equals(this.Code)); } try { #region Save Controls 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 if (tools.HasAccess("Edit", "News")) { dataContext.SubmitChanges(); } if (IsNewRecord) { if (!string.IsNullOrEmpty(ObjTable.NewsNumber)) { ObjTable.NewsNumber = ObjTable.Code.ToString(); dataContext.SubmitChanges(); } } } catch (Exception exp) { throw exp; } if (IsNewRecord && string.IsNullOrEmpty(ObjTable.NewsNumber)) { ObjTable.NewsNumber = ObjTable.Code.ToString(); dataContext.SubmitChanges(); } return(ObjTable.Code); }
public int SaveChanges(bool IsNewRecord) { string NewsTitle = ""; Courses ObjTable; if (IsNewRecord) { ObjTable = new Courses(); dataContext.Courses.InsertOnSubmit(ObjTable); } else { ObjTable = dataContext.Courses.Single(p => p.Code.Equals(this.Code)); } try { #region Save Controls 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[] { }); } if (Property == "Title") { NewsTitle = ((TextBox)wc).Text; } } #endregion if (tools.HasAccess("Edit", "Courses")) { dataContext.SubmitChanges(); } } catch (Exception exp) { throw exp; } if (IsNewRecord) { BOLNews NewsBOL = new BOLNews(); NewsBOL.Insert(NewsTitle, "Courses.aspx"); } return(ObjTable.Code); }
public int SaveChanges(bool IsNewRecord) { Users ObjTable; if (IsNewRecord) { ObjTable = new Users(); ObjTable.LoginTimes = 0; ObjTable.CreateDate = DateTime.Now; dataContext.Users.InsertOnSubmit(ObjTable); Tools tool1 = new Tools(); ObjTable.ID = tool1.GetRandNumber(20); } else { ObjTable = dataContext.Users.Single(p => p.Code.Equals(this.Code)); } try { #region Save Controls string BaseID = this.ToString().Substring(3, this.ToString().Length - 3); Tools tools = new Tools(); tools.AccessList = tools.GetAccessList(BaseID); foreach (WebControl wc in ObjectList) { if ((wc as AKP.Web.Controls.Common.ICustomControlsBase).DisplayMode == AKP.Web.Controls.Common.EnmDisplayMode.EditMode) { 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 if (tools.HasAccess("Edit", "Users")) { dataContext.SubmitChanges(); } } catch (Exception exp) { throw exp; } return(ObjTable.Code); }
public int SaveChanges(bool IsNewRecord) { HttpSessionState Session = HttpContext.Current.Session; NewsNewsFlows ObjTable; if (IsNewRecord) { ObjTable = new NewsNewsFlows(); dataContext.NewsNewsFlows.InsertOnSubmit(ObjTable); } else { ObjTable = dataContext.NewsNewsFlows.Single(p => p.Code.Equals(this.Code)); } try { #region Save Detail Controls PropertyInfo piMasterCode = ObjTable.GetType().GetProperty("NewsCode"); 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 if (tools.HasAccess("Edit", "NewsNewsFlows")) { dataContext.SubmitChanges(); } } catch (Exception exp) { throw exp; } return(ObjTable.Code); }
public int SaveChanges(bool IsNewRecord) { HttpSessionState Session = HttpContext.Current.Session; GroupResources ObjTable; if (IsNewRecord) { ObjTable = new GroupResources(); dataContext.GroupResources.InsertOnSubmit(ObjTable); } else { ObjTable = dataContext.GroupResources.Single(p => p.Code.Equals(this.Code)); } try { #region Save Detail Controls PropertyInfo piMasterCode = ObjTable.GetType().GetProperty("GroupCode"); 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); ObjTable.GroupCode = this.GroupCode; ObjTable.ResourceCode = this.ResourceCode; ObjTable.AccessType = this.AccessType; #endregion dataContext.SubmitChanges(); } catch (Exception exp) { throw exp; } return(ObjTable.Code); }