void IBaseBOL.DeleteRecord(params string[] DelParam) { Resources ObjTable = dataContext.Resources.Single(p => p.Code.Equals(DelParam[0])); dataContext.Resources.DeleteOnSubmit(ObjTable); dataContext.SubmitChanges(); }
public void InsertNew() { ForgotPasswords ObjTable; ObjTable = new ForgotPasswords(); dataContext.ForgotPasswords.InsertOnSubmit(ObjTable); ObjTable.Code = this.Code; ObjTable.UserCode = this.UserCode; ObjTable.GenKey = this.GenKey; ObjTable.GenTime = this.GenTime; ObjTable.Used = this.Used; dataContext.SubmitChanges(); }
public bool SendEmailToFriends(int UserCode, string[] EmailArray) { try { bool AllSuccess = true; string CurEmail = ""; Tools tools = new Tools(); UsersDataContext dcUser = new UsersDataContext(); for (int i = 0; i < EmailArray.Length; i++) { CurEmail = EmailArray[i].Trim(); if (IsValidEmail(CurEmail)) { vActiveUsers ExistingUser = dcUser.vActiveUsers.SingleOrDefault(p => p.Email.Equals(CurEmail)); if (ExistingUser == null) { string RandKey = tools.GetRandString(50); Invitations NewInvitation = dcUser.Invitations.SingleOrDefault(p => p.Email.Equals(CurEmail) && p.EmailRemoved.Equals(true)); if (NewInvitation == null) { #region Send email NewInvitation = new Invitations(); NewInvitation.InviterUserCode = UserCode; NewInvitation.Email = CurEmail; NewInvitation.GenKey = RandKey; NewInvitation.HCInvitationsStatusCode = 1;//Invitation sent NewInvitation.EmailRemoved = false; NewInvitation.SendDate = DateTime.Now; dcUser.Invitations.InsertOnSubmit(NewInvitation); dcUser.SubmitChanges(); EmailTools emailTools = new EmailTools(); Users CurUser = dcUser.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); bool SendResult = emailTools.SendInvitationMessage(CurUser, CurEmail); if (!SendResult) { if (AllSuccess) { AllSuccess = false; } } #endregion } } else { Users FromUser = dcUser.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); Users ToUser = dcUser.Users.SingleOrDefault(p => p.Code.Equals(ExistingUser.Code)); BOLUserMessages UserMessagesBOL = new BOLUserMessages(); UserMessagesBOL.SendAddFriendMessage(FromUser, ToUser, ""); } } } return(AllSuccess); } catch { return(false); } }
internal void DeleteFriend(int UserCode, int FriendCode) { try { UsersDataContext dataContext = new UsersDataContext(); UserFriends CurRelation = dataContext.UserFriends.SingleOrDefault(p => p.UserCode.Equals(UserCode) && p.FriendCode.Equals(FriendCode)); dataContext.UserFriends.DeleteOnSubmit(CurRelation); dataContext.SubmitChanges(); CurRelation = dataContext.UserFriends.SingleOrDefault(p => p.UserCode.Equals(FriendCode) && p.FriendCode.Equals(UserCode)); dataContext.UserFriends.DeleteOnSubmit(CurRelation); dataContext.SubmitChanges(); } catch { } }
public int SaveChanges(bool IsNewRecord) { HttpSessionState Session = HttpContext.Current.Session; UserGroups ObjTable; if (IsNewRecord) { ObjTable = new UserGroups(); dataContext.UserGroups.InsertOnSubmit(ObjTable); } else { ObjTable = dataContext.UserGroups.Single(p => p.Code.Equals(this.Code)); } try { #region Save Detail Controls PropertyInfo piMasterCode = ObjTable.GetType().GetProperty("UserCode"); piMasterCode.SetValue(ObjTable, MasterCode, new object[] { }); 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", "UserGroups")) { dataContext.SubmitChanges(); } } catch (Exception exp) { throw exp; } return(ObjTable.Code); }
public void ActivateUser(int Code) { UsersDataContext dc = new UsersDataContext(); Users CurUser = dc.Users.SingleOrDefault(p => p.Code.Equals(Code)); if (CurUser != null) { CurUser.Active = true; dc.SubmitChanges(); } }
internal static void UpdateLastLoginTime(int Code) { try { UsersDataContext dc = new UsersDataContext(); Users CurUser = dc.Users.SingleOrDefault(p => p.Code.Equals(Code)); CurUser.LastLoginTime = DateTime.Now; dc.SubmitChanges(); } catch { } }
public void NewAction(int UserCode, string Comment, int HCActionTypeCode) { UsersDataContext dc = new UsersDataContext(); UserActions NewAction = new UserActions(); dc.UserActions.InsertOnSubmit(NewAction); NewAction.UserCode = UserCode; NewAction.HCActionTypeCode = HCActionTypeCode; NewAction.Comment = Comment; NewAction.ID = Tools.GetRandID(); NewAction.ActionDate = DateTime.Now; dc.SubmitChanges(); }
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); }
public int SaveChanges(bool IsNewRecord) { HttpSessionState Session = HttpContext.Current.Session; UserMessages ObjTable; if (IsNewRecord) { ObjTable = new UserMessages(); dataContext.UserMessages.InsertOnSubmit(ObjTable); ObjTable.SendDate = DateTime.Now; } else { ObjTable = dataContext.UserMessages.Single(p => p.Code.Equals(this.Code)); } try { #region Save changes after checking Access ObjTable.Code = this.Code; ObjTable.FromUserCode = this.FromUserCode; ObjTable.ToUserCode = this.ToUserCode; ObjTable.Title = this.Title; ObjTable.Message = this.Message; ObjTable.HCStatusCode = this.HCStatusCode; #endregion dataContext.SubmitChanges(); } catch (Exception exp) { throw exp; } return(ObjTable.Code); }
public int Insert(int UserCode, int HCSiteSectionCode, int ItemCode, string Comment, DateTime CommentDate, bool Active) { UsersDataContext dc = new UsersDataContext(); UserComments NewRecord = new UserComments(); dc.UserComments.InsertOnSubmit(NewRecord); NewRecord.UserCode = UserCode; NewRecord.HCSiteSectionCode = HCSiteSectionCode; NewRecord.ItemCode = ItemCode; NewRecord.Comment = Comment; NewRecord.CommentDate = CommentDate; NewRecord.Active = Active; dc.SubmitChanges(); return(NewRecord.Code); }
public static void SetPermission(decimal UserID, string FunctionName, TypeAudit audit) { if (!ntsSqlFunctions._IsRegis) { return; } UsersDataContext _vdata = new UsersDataContext(); tblFunction function = _vdata.tblFunctions.Where(p => p.functionName == FunctionName).FirstOrDefault(); if (function != null) { return; } tblUserPermiss permis = new tblUserPermiss(); permis.maNguoidungpr_sd = UserID; permis.tblFunction = function; permis.permission = ntsSecurity._mEncrypt(UserID.ToString() + ";" + function.functionIDpr.ToString() + ";" + ((int)audit).ToString(), "rateAnd2012", true); _vdata.tblUserPermisses.InsertOnSubmit(permis); _vdata.SubmitChanges(); }
protected void HandleRepeaterCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "ActivatePic") { Button btnPic = (Button)e.Item.FindControl("btnPic"); Label lblStatus = (Label)e.Item.FindControl("lblStatus"); int UserCode = Convert.ToInt32(btnPic.Attributes["UserCode"]); BOLUsers UsersBOL = new BOLUsers(); UsersDataContext dc = new UsersDataContext(); Khabardaan.Code.DAL.Users CurUser = dc.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); if (CurUser != null) { CurUser.HCPicStatusCode = 2; CurUser.UpdateTime = DateTime.Now; dc.SubmitChanges(); lblStatus.Text = "فعال"; } } if (e.CommandName == "DeletePic") { Button btnDelPic = (Button)e.Item.FindControl("btnDelPic"); Label lblStatus = (Label)e.Item.FindControl("lblStatus"); int UserCode = Convert.ToInt32(btnDelPic.Attributes["UserCode"]); BOLUsers UsersBOL = new BOLUsers(); UsersDataContext dc = new UsersDataContext(); Khabardaan.Code.DAL.Users CurUser = dc.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); if (CurUser != null) { CurUser.HCPicStatusCode = 1; CurUser.UpdateTime = DateTime.Now; CurUser.PicFile = null; CurUser.SmallPicFile = null; dc.SubmitChanges(); lblStatus.Text = "حذف شد"; } } }
public bool SendAddFriendMessage(Users FromUser, Users ToUser, string AddFriendMessage) { UsersDataContext dc = new UsersDataContext(); UserMessages NewMessage = new UserMessages(); NewMessage.HCStatusCode = 1; NewMessage.Message = AddFriendMessage; NewMessage.FromUserCode = FromUser.Code; NewMessage.SendDate = DateTime.Now; NewMessage.ID = Tools.GetRandID(); NewMessage.Title = FromUser.FirstName + " " + FromUser.LastName + " تقاضای دوستی با شما را دارد."; NewMessage.ToUserCode = ToUser.Code; dc.UserMessages.InsertOnSubmit(NewMessage); dc.SubmitChanges(); #region Send Email EmailTools emailTools = new EmailTools(); return(emailTools.SendAddFriendMessage(FromUser, ToUser)); #endregion }
protected void btnSendMessage_Click(object source, EventArgs e) { string UserImageUrl; int UserCode = (int)Session["UserCode"]; UsersDataContext dc = new UsersDataContext(); UserMessages NewMessage = new UserMessages(); NewMessage.HCStatusCode = 2; NewMessage.Message = txtMessageContent.Text; NewMessage.FromUserCode = UserCode; NewMessage.SendDate = DateTime.Now; NewMessage.Title = txtMessageSubject.Text; NewMessage.ID = Tools.GetRandID(); NewMessage.ToUserCode = ToUserCode; dc.UserMessages.InsertOnSubmit(NewMessage); dc.SubmitChanges(); string jsScript = @"$('#divSendMessage').modal('hide');"; ScriptManager.RegisterStartupScript(_upanel, _upanel.GetType(), "divSendMessage", jsScript, true); #region Send Email UtilDataContext dcUtil = new UtilDataContext(); Users ToUser = dc.Users.SingleOrDefault(p => p.Code.Equals(ToUserCode)); EmailTemplates CurTemplate = dcUtil.EmailTemplates.SingleOrDefault(p => p.Title.Equals("SendMessage")); if (Tools.GetValue(ToUser.ISendMessage)) { if (CurTemplate != null) { string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"]; Users FromUser = dc.Users.SingleOrDefault(p => p.Code.Equals(UserCode)); Tools tools = new Tools(); string MsgBody = CurTemplate.Template; string MessageUrl = SiteDomain + "Users/Messages.aspx?ID=" + NewMessage.ID; if (FromUser.PicFile == null || FromUser.PicFile == "") { UserImageUrl = SiteDomain + "Files/Users/man_icon.gif"; } else { UserImageUrl = SiteDomain + "Files/Users/" + FromUser.PicFile; } string RemoveEmailUrl = SiteDomain + "Users/Setting.aspx"; MsgBody = MsgBody.Replace("[UserFullName]", Session["FirstName"].ToString() + " " + Session["LastName"].ToString()); MsgBody = MsgBody.Replace("[UserEmail]", FromUser.Email); MsgBody = MsgBody.Replace("[MessageUrl]", MessageUrl); MsgBody = MsgBody.Replace("[ImageUrl]", UserImageUrl); MsgBody = MsgBody.Replace("[RemoveEmailUrl]", RemoveEmailUrl); MsgBody = MsgBody.Replace("[RecFirstName]", ToUser.FirstName); MsgBody = MsgBody.Replace("[UserUrl]", SiteDomain + "Users/Profile.aspx?ID=" + FromUser.ID); MsgBody = MsgBody.Replace("[UserFirstName]", FromUser.FirstName); int FriendCount = dc.UserFriends.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); int PhotoCount = dc.vUserAlbumPhotos.Where(p => p.UserCode.Equals(FromUser.Code)).Count(); MsgBody = MsgBody.Replace("[FriendCount]", FriendCount.ToString()); MsgBody = MsgBody.Replace("[PhotoCount]", PhotoCount.ToString()); string MsgSubject = Session["FirstName"].ToString() + " " + Session["LastName"].ToString() + " برای شما یک پیام در پارست ارسال کرده است"; bool SendResult = tools.SendEmail(MsgBody, MsgSubject, "<*****@*****.**>", ToUser.Email, "*****@*****.**", ""); } } #endregion pnlSendMessage.Visible = false; }