public static void SetItem(FieldValue item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("FieldValue"); tableObj.GetDataFromObject(item); string sql = $"Select 1 From FieldValue Where FormItemID = { item.FormItemID } AND FieldID = { item.FieldID }"; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj.Insert(); } else { tableObj.Remove("FormItemID"); tableObj.Remove("FieldID"); SQLData.ParameterCollection paras = new SQLData.ParameterCollection(); paras.Add("@FormItemID", item.FormItemID); paras.Add("@FieldID", item.FieldID); tableObj.Update(paras); } }
public static void SetItem(SiteLangMenuModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("SiteLangMenu"); tableObj.GetDataFromObject(item); string sql = "Select 1 From SiteLangMenu Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj["Sort"] = 1; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SiteID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; tableObj.Update(item.ID); } }
public static void SetItem(PageCommentsModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("PageComments"); tableObj.GetDataFromObject(item); DateTime now = DateTime.Now; string sql = "Select 1 From PageComments Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["ModifyTime"] = now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("PageSN"); tableObj.Remove("ParentID"); tableObj.Remove("PostDate"); tableObj.Remove("ShowStatus"); tableObj.Remove("MemberShipID"); Common.Member curUser = Common.Member.Current; tableObj["Modifier"] = curUser == null ? Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id : curUser.ID; tableObj["ModifyTime"] = now; tableObj.Update(item.ID); } }
public static MemberShipRegSocialSetModels GetSocialItem(long SiteID, int Sort, WorkV3.Models.MemberType SocialType, string SocialTitle) { string sql = $"SELECT * FROM MemberShipRegSocialSet WHERE SiteID={SiteID} AND SocialType={(int)SocialType} "; SQLData.Database db = new SQLData.Database(WebInfo.Conn); DataTable datas = db.GetDataTable(sql); DateTime now = DateTime.Now; if (datas == null || datas.Rows.Count <= 0) { MemberShipRegSocialSetModels m = new MemberShipRegSocialSetModels(); m.SiteID = SiteID; m.SocialType = SocialType; m.SocialTitle = SocialTitle; m.Sort = Sort; m.IsOpen = false; // default m.SecretKey = ""; m.AppID = ""; m.Scope = ""; m.Creator = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; m.CreateTime = now; m.Modifier = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; m.ModifyTime = now; m.BackendIsOpen = false; SQLData.TableObject tableObj = db.GetTableObject("MemberShipRegSocialSet"); tableObj["SiteID"] = m.SiteID; tableObj["SocialType"] = (int)m.SocialType; tableObj["SocialTitle"] = m.SocialTitle; tableObj["IsOpen"] = m.IsOpen; tableObj["SecretKey"] = m.SecretKey; tableObj["AppID"] = m.AppID; tableObj["Scope"] = m.Scope; tableObj["Sort"] = m.Sort; tableObj["Creator"] = m.Creator; tableObj["CreateTime"] = m.CreateTime; tableObj["Modifier"] = m.Modifier; tableObj["ModifyTime"] = m.ModifyTime; tableObj["BackendIsOpen"] = m.BackendIsOpen; tableObj.Insert(); return(m); } else { DataRow dr = datas.Rows[0]; MemberShipRegSocialSetModels m = new MemberShipRegSocialSetModels(); m.SiteID = (long)dr["SiteID"]; m.SocialType = (WorkV3.Models.MemberType)((int)dr["SocialType"]); m.SocialTitle = dr["SocialTitle"].ToString(); m.IsOpen = Convert.ToBoolean(dr["IsOpen"].ToString()); m.SecretKey = dr["SecretKey"].ToString(); m.AppID = dr["AppID"].ToString(); m.Scope = dr["Scope"].ToString(); m.Sort = (int)dr["Sort"]; m.Creator = (long)dr["Creator"]; m.CreateTime = (DateTime)dr["CreateTime"]; m.Modifier = (long)dr["Modifier"]; m.ModifyTime = (DateTime)dr["ModifyTime"]; return(m); } }
public static void SetItem(ParagraphModels item) { item.Title = item.Title ?? string.Empty; item.MatchType = item.MatchType ?? string.Empty; item.Contents = item.Contents ?? string.Empty; SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Paragraph"); tableObj.GetDataFromObject(item); string sql = "Select 1 From Paragraph Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SourceNo"); tableObj.Update(item.ID); } }
public static void SetMemberShipRegManagers(MemberShipRegEmailManagersModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("MemberShipRegEmailManagers"); tableObj.GetDataFromObject(item); string sql = $"Select 1 From MemberShipRegEmailManagers Where SiteID={item.SiteID} AND ManagerID='{item.ManagerID}'"; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { if (string.IsNullOrEmpty(item.ManagerID)) { tableObj["ManagerID"] = ""; } tableObj["Creator"] = MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SiteID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; tableObj.Update(item.ID); } }
public static void SetItem(IntraIPlimitModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("IntraIPlimit"); tableObj.GetDataFromObject(item); string sql = "Select 1 From IntraIPlimit Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["OpenStatus"] = item.OpenStatus == OpenStatus.Open ? 1 : 0; tableObj["Creator"] = MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; tableObj.Update(item.ID); } }
public static void SetItem(ArticleModels item, int cardStyleID = 1) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Article"); tableObj.GetDataFromObject(item); string sql = "Select 1 From Article Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { MenusModels menu = MenusDAO.GetInfo(item.SiteID, item.MenuID); long cardNo = WorkV3.Golbal.PubFunc.AddPage(item.SiteID, item.MenuID, menu.SN, "Article", "Content", true, item.Title, CardStyleId: cardStyleID); tableObj["CardNo"] = cardNo; tableObj["Creator"] = MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj["Sort"] = 1; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SiteID"); tableObj.Remove("MenuID"); tableObj.Remove("CardNo"); tableObj.Remove("Clicks"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; tableObj.Update(item.ID); } }
public static void SetCardInfo(CardsModels card) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Cards"); tableObj.GetDataFromObject(card); string sql = $"Select 1 From Cards Where No = { card.No } AND Lang = '{ card.Lang.Replace("'", "''") }' AND Ver = { card.Ver }"; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { string[] removeFields = { "No", "Lang", "Ver", "Creator", "CreateTime" }; foreach (string field in removeFields) { tableObj.Remove(field); } tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; SQLData.ParameterCollection keys = new SQLData.ParameterCollection(); keys.Add("@No", card.No); keys.Add("@Lang", card.Lang); keys.Add("@Ver", card.Ver); tableObj.Update(keys); } }
public static void SetItem(AdsStatisticsLabelsModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("AdsStatisticsLabels"); tableObj.GetDataFromObject(item); bool isNew = false; string sql = "Select 1 From AdsStatisticsLabels Where ID = " + item.ID; isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Title"] = item.Title; tableObj["LabelDate"] = item.LabelDate; tableObj["LabelColor"] = item.LabelColor; tableObj["ShowStatus"] = item.ShowStatus; tableObj["Creator"] = item.Creator; tableObj["CreateTime"] = item.CreateTime; tableObj.Insert(); } else { tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Title"] = item.Title; tableObj["LabelDate"] = item.LabelDate; tableObj["ShowStatus"] = item.ShowStatus; tableObj["LabelColor"] = item.LabelColor; tableObj["Modifier"] = item.Modifier; tableObj["ModifyTime"] = item.ModifyTime; tableObj.Update(item.ID); } }
public static void SetItem(SEOModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("SEO"); tableObj.GetDataFromObject(item); string sql = "Select 1 From SEO Where SourceNo = " + item.SourceNo; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj.Add("Creator", WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id); tableObj.Add("CreateTime", DateTime.Now); tableObj.Insert(); } else { tableObj.Remove("SourceNo"); tableObj.Remove("MenuID"); tableObj.Add("Modifier", WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id); tableObj.Add("ModifyTime", DateTime.Now); tableObj.Update(item.SourceNo); } }
public static bool SetMailTemplateItems(MailTemplateSetModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); item.AttFiles = item.AttFiles == null ? "" : item.AttFiles; SQLData.TableObject tableObj = db.GetTableObject("MailTemplateSet"); tableObj.GetDataFromObject(item); DateTime now = DateTime.Now; string sql = $"SELECT * FROM MailTemplateSet WHERE TemplateName='{ item.TemplateName.Replace("'", "")}' "; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = now; tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = now; tableObj.Insert(); } else { tableObj.Remove("TemplateName"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = now; tableObj.Update(item.TemplateName); } return(true); }
public static void Save_Single(MenusModels data) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject TableObj = db.GetTableObject("Menus"); TableObj.Add("Title", data.Title); //TableObj.Add("ParentID", data.ParentID); TableObj.Add("ShowStatus", data.ShowStatus); //TableObj.Add("Sort", data.Sort); TableObj.Add("Modifier", MemberDAO.SysCurrent.Id); TableObj.Add("ModifyTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); SQLData.ParameterCollection para = new SQLData.ParameterCollection(); para.Add("@ID", data.ID); TableObj.Update(para); PagesModels mPage = PagesDAO.GetPageInfo(data.SiteID, data.ID); if (mPage != null) { mPage.Title = data.Title; PagesDAO.SetPageInfo(mPage); } }
public static void SaveInfo(MenusModels data) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject TableObj = db.GetTableObject("Menus"); //TableObj.GetDataFromObject(data); TableObj.Add("Title", data.Title); TableObj.Add("ShowStatus", data.ShowStatus); SQLData.ParameterCollection para = new SQLData.ParameterCollection(); if (data.ID == 0) { TableObj.Add("ID", GetItem.NewSN()); TableObj.Add("SN", data.SN); TableObj.Add("SiteID", data.SiteID); TableObj.Add("AreaID", data.AreaID); TableObj.Add("ParentID", data.ParentID); TableObj.Add("DataType", data.DataType); TableObj.Add("Sort", data.Sort); TableObj.Add("Creator", MemberDAO.SysCurrent.Id); TableObj.Add("CreateTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); TableObj.Insert(); } else { TableObj.Add("Modifier", MemberDAO.SysCurrent.Id); TableObj.Add("ModifyTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); para.Add("@ID", data.ID); TableObj.Update(para); } }
public static void SetItem(ArticleIntroModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("ArticleIntro"); item.Icon = item.Icon ?? string.Empty; item.RemarkText = item.RemarkText ?? string.Empty; tableObj.GetDataFromObject(item); string sql = "Select 1 From ArticleIntro Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { long cardNo = WorkV3.Models.DataAccess.MenusDAO.GetFirstCardNo(item.MenuID, "ArticleIntro") ?? 0; tableObj.Add("CardNo", cardNo); tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("MenuID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj.Update(item.ID); } }
public static bool SetItem(SocialSettingModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("SocialSetting"); tableObj.GetDataFromObject(item); DateTime now = DateTime.Now; string sql = $"SELECT * FROM SocialSetting WHERE SiteID='{ item.SiteID }' "; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = now; tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = now; tableObj.Insert(); } else { tableObj.Remove("SiteID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = now; tableObj.Update(item.SiteID); } return(true); }
public static void SetItem(ArticlePosterModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("ArticlePoster"); tableObj.GetDataFromObject(item); string sql = "Select 1 From ArticlePoster Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("MenuID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj["Modifier"] = MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; tableObj.Update(item.ID); } }
public static void SetItem(ResourceImagesModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("ResourceImages"); tableObj.GetDataFromObject(item); string sql = "Select 1 From ResourceImages Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj.Insert(); } else { string[] removeFields = { "ID", "SiteID", "SourceNo", "SourceType", "Ver", "AreaID", "Creator", "CreateTime" }; foreach (string f in removeFields) { tableObj.Remove(f); } SQLData.ParameterCollection keys = new SQLData.ParameterCollection(); keys.Add("@ID", item.ID); keys.Add("@SiteID", item.SiteID); keys.Add("@SourceNo", item.SourceNo); keys.Add("@SourceType", item.SourceType); keys.Add("@Ver", item.Ver); keys.Add("@AreaID", item.AreaID); tableObj.Update(keys); } }
public static void SetItem(FormItem item, bool hasCreateDate = false) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("FormItem"); tableObj.GetDataFromObject(item); DateTime now = DateTime.Now; tableObj.Add("ModifyDate", now); string sql = "Select ID, CheckStatus From FormItem Where ID = " + item.ID; SQLData.SelectObject selectObj = db.GetSelectObject(sql); bool isNew = selectObj.Count == 0; if (isNew) { if (!hasCreateDate) { tableObj["CreateDate"] = now; } if (item.CheckStatus != (byte)FormCheckStatus.待審核) { tableObj["CheckDate"] = DateTime.Now; } tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("FormID"); tableObj.Remove("CreateDate"); tableObj.Remove("SN"); tableObj.Remove("IsTemp"); tableObj.Remove("IsBack"); tableObj.Remove("CheckDate"); tableObj.Remove("CheckInDate"); if (item.CheckStatus != (byte)FormCheckStatus.待審核 && (byte)selectObj["CheckStatus"] != item.CheckStatus) { tableObj.Add("CheckDate", DateTime.Now); } tableObj.Update(item.ID); } }
public static void Save_Folder(MenusModels data) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject TableObj = db.GetTableObject("Menus"); TableObj.Add("Title", data.Title); TableObj.Add("ShowStatus", data.ShowStatus); TableObj.Add("DataTypeValue", data.DataTypeValue); TableObj.Add("Modifier", MemberDAO.SysCurrent.Id); TableObj.Add("ModifyTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); SQLData.ParameterCollection para = new SQLData.ParameterCollection(); para.Add("@ID", data.ID); TableObj.Update(para); }
public static void UpdatePageInfo(PagesModels page) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Pages"); tableObj.GetDataFromObject(page); tableObj.Remove("No"); tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; SQLData.ParameterCollection keys = new SQLData.ParameterCollection(); keys.Add("@No", page.No); tableObj.Update(keys); }
/// <summary> /// 使用者動作儲存 /// </summary> /// <param name="AdsCustomizeID"></param> /// <param name="PageID"></param> /// <param name="Event"></param> /// <param name="MemberID"></param> public static void SetUserEventLog(long AdsCustomizeID, long PageID, string Event, long?MemberID) { if (AdsCustomizeID == 0 || PageID == 0 || string.IsNullOrWhiteSpace(Event)) { return; } if (Event != UserEvent.Browsing && Event != UserEvent.Click) { return; } AdsStatisticsModel item = new AdsStatisticsModel() { AdsCustomizeID = AdsCustomizeID, PageID = PageID, SessionID = System.Web.HttpContext.Current.Session.SessionID, DeviceID = WorkV3.Areas.Backend.Models.DataAccess.AdvertisementDAO.GetCpuID(), Browser = System.Web.HttpContext.Current.Request.Browser.Browser, Event = Event, IP = WorkLib.GetItem.IPAddr(), IPNum = (long)WorkLib.GetItem.GetIPNum(), MemberID = MemberID ?? 0, RecordDay = DateTime.Now, RecordTime = DateTime.Now }; SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("AdsStatistics"); tableObj.GetDataFromObject(item); string check = "Select 1 From AdsStatistics " + $"Where AdsCustomizeID={item.AdsCustomizeID} and " + $"PageID={item.PageID} and " + $"SessionID='{item.SessionID}' and " + $"Event='{item.Event}' and " + $"RecordDay='{item.RecordDay.ToString("yyyy/MM/dd")}'"; bool isNew = db.GetFirstValue(check) == null; if (isNew) { tableObj.Insert(); } }
public static void SaveInfo(SysLogModels data) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject TableObj = db.GetTableObject("Syslog"); TableObj.Add("ID", GetItem.NewSN()); if (MemberDAO.SysCurrent != null) { TableObj.Add("MemberID", MemberDAO.SysCurrent.Id); } if (data.MgrNo != null) { TableObj.Add("MgrNo", data.MgrNo); } TableObj.Add("Actions", data.Actions); if (data.SiteID != null) { TableObj.Add("SiteID", data.SiteID); } if (data.MenuID != null) { TableObj.Add("MenuID", data.MenuID); } if (data.SourceID != null) { TableObj.Add("SourceID", data.SourceID); } TableObj.Add("ReMark", data.ReMark); TableObj.Add("AddTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); string IP = GetItem.IPAddr(); TableObj.Add("IP", IP); TableObj.Add("IPNum", GetItem.GetIPNum(IP)); TableObj.Insert(); }
public static bool SetRelationItem(SocialRelationModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("SocialRelations"); tableObj.GetDataFromObject(item); DateTime now = DateTime.Now; string sql = $"SELECT * FROM SocialRelations WHERE ID={ item.ID } "; string sql_sort = $"SELECT Max(Sort) FROM SocialRelations WHERE RelationType='{(int)item.RelationType}' AND SiteID={item.SiteID} "; bool isNew = db.GetFirstValue(sql) == null; string sortIndex = db.GetFirstValue(sql_sort).ToString(); int newSortIndex = 1; if (!string.IsNullOrEmpty(sortIndex)) { newSortIndex = int.Parse(sortIndex) + 1; } if (isNew) { tableObj["ID"] = item.ID; tableObj["SocialTitle"] = GetSocialTypeTitle(item.SocialType); tableObj["Sort"] = newSortIndex; tableObj["LinkTitle"] = item.LinkTitle == null ? "" : item.LinkTitle; tableObj["LinkUrl"] = item.LinkUrl == null?"":item.LinkUrl; tableObj["Creator"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = now; tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj.Remove("Sort"); tableObj["SocialTitle"] = item.SocialTitle == null ? "" : item.SocialTitle; tableObj["LinkTitle"] = item.LinkTitle == null ? "" : item.LinkTitle; tableObj["LinkUrl"] = item.LinkUrl == null ? "" : item.LinkUrl; tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = now; tableObj.Update(item.ID); } return(true); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="IsManually">是否手動新增</param> public static void SetItem(PointsModel item, bool IsManually = false) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Points"); tableObj.GetDataFromObject(item); DateTime now = DateTime.Now; string sql = "Select 1 From Points Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; tableObj["SiteID"] = item.SiteID; tableObj["MemberShipID"] = item.MemberShipID; tableObj["Remark"] = string.IsNullOrEmpty(item.Remark) ? "" : item.Remark; tableObj["Description"] = string.IsNullOrEmpty(item.Description) ? "" : item.Description; tableObj["Point"] = item.Point; tableObj["IsManually"] = IsManually; tableObj["PointType"] = item.PointType; if (isNew) { if (item.Creator == 0) { tableObj["Creator"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; } tableObj["CreateTime"] = now; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SiteID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); Common.Member curUser = Common.Member.Current; tableObj["Modifier"] = curUser == null ? Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id : curUser.ID; tableObj["ModifyTime"] = now; tableObj.Update(item.ID); } }
public static void SetItem(ResourceVideosModels item) { item.Spec = item.Spec ?? string.Empty; item.Duration = item.Duration ?? string.Empty; item.Screenshot = item.Screenshot ?? string.Empty; SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("ResourceVideos"); tableObj.GetDataFromObject(item); string sql = "Select 1 From ResourceVideos Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { string[] removeFields = { "ID", "SiteID", "SourceNo", "SourceType", "Ver", "AreaID", "Code", "Creator", "CreateTime" }; foreach (string f in removeFields) { tableObj.Remove(f); } tableObj["Modifier"] = MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; SQLData.ParameterCollection keys = new SQLData.ParameterCollection(); keys.Add("@ID", item.ID); keys.Add("@SiteID", item.SiteID); keys.Add("@SourceNo", item.SourceNo); keys.Add("@SourceType", item.SourceType); keys.Add("@Ver", item.Ver); keys.Add("@AreaID", item.AreaID); tableObj.Update(keys); } }
public static void SetItem(MemberShipMailModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("MemberShipSendMail"); tableObj.GetDataFromObject(item); string sql = "Select 1 From MemberShipSendMail Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SendDate"); tableObj.Update(item.ID); } }
public static void Insert_Single(MenusModels data) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject TableObj = db.GetTableObject("Menus"); SQLData.ParameterCollection para = new SQLData.ParameterCollection(); TableObj.Add("Title", data.Title); TableObj.Add("ParentID", 0); TableObj.Add("ShowStatus", data.ShowStatus); TableObj.Add("Sort", 0); TableObj.Add("ID", data.ID); TableObj.Add("SN", data.SN); TableObj.Add("SiteID", data.SiteID); TableObj.Add("AreaID", data.AreaID); TableObj.Add("DataType", data.DataType); TableObj.Add("Creator", MemberDAO.SysCurrent.Id); TableObj.Add("CreateTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); TableObj.Add("DisableDelete", data.DisableDelete); TableObj.Insert(); }
public static void SetItem(FormModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Form"); tableObj.GetDataFromObject(item); string sql = "Select 1 From Form Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("SiteID"); tableObj.Remove("SourceID"); tableObj.Remove("IsRemove"); tableObj.Update(item.ID); } }
public static void SetItem(FieldModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Field"); tableObj.GetDataFromObject(item); string sql = "Select 1 From Field Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { sql = "Select IsNull(Max(SN), 0) From Field Where ParentID = " + item.ParentID; tableObj["SN"] = (int)db.GetFirstValue(sql) + 1; tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("ParentID"); tableObj.Remove("SN"); tableObj.Update(item.ID); } }