public Boolean ValidateAllowedMails() { try { objBL_Common = new BL_Common(); DataTable dtplantype = new DataTable(); string[] UPtype = new string[3]; dtplantype = objBL_Common.plantypedetails("b.*", "dbo.EC_UserLogin a inner join EC_UserPlan b on a.PK_UserID = b.FK_UserID", "a.FK_CompanyID =" + Convert.ToInt32(Session["CompanyID"].ToString()) + " and b.IsActive = 1"); Boolean validstatus = false; if (dtplantype.Rows.Count > 0) { string mailcount = objBL_CampaignQueue.SelectMailCount(Convert.ToInt32(Session["CompanyID"].ToString()), Convert.ToDateTime(dtplantype.Rows[0]["ActiveFrom"].ToString()), Convert.ToDateTime(dtplantype.Rows[0]["ActiveTo"].ToString())); //string mailcount = objBL_Common.IsValidUser("", "", ""); if (mailcount != "") { if (Session["lstUserPlanType"] != null) { UPtype = (string[])Session["lstUserPlanType"]; if (Session["SelectContactID"].ToString() != null) { int selectidcount = 0; if (Session["SelectContactID"].ToString().Contains(",")) { string[] arrcontactid = Session["SelectContactID"].ToString().Split(','); selectidcount = arrcontactid.Length; } if (Convert.ToInt32(mailcount) + selectidcount >= Convert.ToInt32(UPtype[2])) { if (Convert.ToInt32(mailcount) < Convert.ToInt32(UPtype[2])) ClientScript.RegisterStartupScript(Page.GetType(), "mykey66", "alert('Only " + Convert.ToInt32(Convert.ToInt32(UPtype[2]) - Convert.ToInt32(mailcount)) + " recepients are remaining from your plan to send mails!');", true); else ClientScript.RegisterStartupScript(Page.GetType(), "mykey26", "alert('You cannot send mails beyond your plan, Mail quota is completed!');", true); validstatus = false; } else validstatus = true; } } } } return validstatus; } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateCampign.aspx:ValidateAllowedMails() - " + ex.Message); return false; } }
public void InsertUserPlan(int loginid) { DataTable dtplantype = new DataTable(); objBL_Common = new BL_Common(); try { dtplantype = objBL_Common.plantypedetails("top 1 *", "EC_PlanType", "LOWER(PlanName)='FREE' and IsActive = 1 order by plandate desc"); if (dtplantype.Rows.Count > 0) { objUserPlan = new UserPlan(); objBL_UserPlan = new BL_UserPlan(); objUserPlan.FK_UserID = loginid; objUserPlan.FK_PlanID = Convert.ToInt32(dtplantype.Rows[0]["PK_PlanID"].ToString()); objUserPlan.ActiveFrom = DateTime.Now; objUserPlan.ActiveTo = DateTime.Now.AddMonths(1); objUserPlan.IsActive = true; objUserPlan.CreatedBy = loginid; objUserPlan.CreatedOn = DateTime.Now; objBL_UserPlan.AccessInsertUserPlan(objUserPlan); string[] UPtype = new string[3]; UPtype[0] = Convert.ToString(dtplantype.Rows[0]["IsSingleUser"]); UPtype[1] = Convert.ToString(dtplantype.Rows[0]["NOC"]); UPtype[2] = Convert.ToString(dtplantype.Rows[0]["AllowedMails"]); Session["lstUserPlanType"] = UPtype; objUserPlan = null; objBL_UserPlan = null; } } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("FreeAccountSignUp.aspx:InsertUserPlan() - " + ex.Message); } }
protected void btndelete_Click(object sender, EventArgs e) { try { string selectid = string.Empty; Boolean deletestatus = false; for (int i = 0; i < gvcampaign.Rows.Count; i++) { if (gvcampaign.Rows[i].RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)gvcampaign.Rows[i].Cells[0].FindControl("CheckBox1"); Label lblEmpID = (Label)gvcampaign.Rows[i].Cells[0].FindControl("lblEmpID"); if (chk.Checked) { DataTable dtplantype = new DataTable(); if (selectid == "") { if (!selectid.Contains(lblEmpID.Text.ToString())) { selectid = lblEmpID.Text; dtplantype = objBL_Common.plantypedetails("PK_CampaignID", "EC_Campaign", "FK_UserID in (" + lblEmpID.Text + ")"); if (dtplantype.Rows.Count > 0) { deletestatus = true; } else { objBL_Common = new BL_Common(); string emailid = "'" + gvcampaign.Rows[i].Cells[5].Text + "'"; objBL_Common.AccessDeletAlleCampaign("EC_InviteUser", "Emailid", emailid); objBL_Common = new BL_Common(); objBL_Common.AccessDeletAlleCampaign("EC_UserLogin", "PK_UserID", lblEmpID.Text); } } } else { if (!selectid.Contains(lblEmpID.Text.ToString())) { selectid = selectid + "," + lblEmpID.Text; dtplantype = objBL_Common.plantypedetails("PK_CampaignID", "EC_Campaign", "FK_UserID in (" + lblEmpID.Text + ")"); if (dtplantype.Rows.Count > 0) { deletestatus = true; } else { objBL_Common = new BL_Common(); string emailid = "'" + gvcampaign.Rows[i].Cells[5].Text + "'"; objBL_Common.AccessDeletAlleCampaign("EC_InviteUser", "Emailid", emailid); objBL_Common = new BL_Common(); objBL_Common.AccessDeletAlleCampaign("EC_UserLogin", "PK_UserID", lblEmpID.Text); } } } } } } if (selectid == "") { ClientScript.RegisterStartupScript(Page.GetType(), "mykey28", "alert('Select at least one record !');", true); } else { if (deletestatus == true) { ClientScript.RegisterStartupScript(Page.GetType(), "mykey29", "alert('You cannot delete these user, Since it is referred by campaign!');", true); } this.Bindrolegrid(); } } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("InviteUserList.aspx:btndelete_Click() - " + ex.Message); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { HttpCookie myCookie = new HttpCookie("myCookie"); bool IsRemember = chkRememberme.Checked; lstUserDetails = new List <UserDetails>(); lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsforLogin(txtUsername.Value.ToString(), txtpassword.Value.ToString()); if (lstUserDetails.Count > 0) { if (lstUserDetails[0].AccountActivated == true) { if (IsRemember) { myCookie.Values.Add("username", txtUsername.Value); myCookie.Values.Add("password", objCryptographicHashCode.EncryptPlainTextToCipherText(txtpassword.Value)); myCookie.Expires = DateTime.Now.AddDays(15); Response.Cookies.Add(myCookie); } else { myCookie.Values.Add("username", string.Empty); myCookie.Values.Add("password", string.Empty); myCookie.Expires = DateTime.Now.AddMinutes(5); Response.Cookies.Add(myCookie); } Session["UserID"] = lstUserDetails[0].PK_UserID; Session["Usertype"] = lstUserDetails[0].UserType; Session["CompanyID"] = lstUserDetails[0].FK_CompanyID; if (lstUserDetails[0].FirstName == "" && lstUserDetails[0].LastName == "") { Session["UserName"] = lstUserDetails[0].UserName; } else { Session["UserName"] = lstUserDetails[0].FirstName + " " + lstUserDetails[0].LastName; } if (Session["CompanyID"].ToString() != "") { Session["CompanyName"] = objBL_Common.IsValidUser("Company_Name", "EC_Company", "PK_CompanyID =" + Convert.ToInt32(Session["CompanyID"].ToString()) + ""); } else { Session["CompanyName"] = "-"; } if (Convert.ToInt64(Session["Usertype"].ToString()) == 10) { Response.Redirect("UserPlanTypeDetails.aspx", false); return; } if (lstUserDetails[0].FK_RoleID != null) { Session["RoleID"] = lstUserDetails[0].FK_RoleID; } if (lstUserDetails[0].UserType == 1) { if (lstUserDetails[0].FK_RoleID == null) { objRole = new Role(); objRole.RoleName = "Admin"; objRole.CampaignCreate = true; objRole.FK_CompanyID = Convert.ToInt32(Session["CompanyID"].ToString()); objRole.MailSend = true; objRole.CreateUser = true; objRole.CampaignDelete = true; objRole.ViewingReports = true; objRole.TemplateView = true; objRole.ListExports = true; objRole.CreatedOn = DateTime.Now; objRole.CreatedBy = Convert.ToInt32(Session["UserID"].ToString()); string pkcqid = objBL_Role.AccessInsertRole(objRole); if (pkcqid != "") { Session["RoleID"] = Convert.ToInt32(pkcqid); objBL_Common = new BL_Common(); objBL_Common.AccessUpdateAllCampaign("EC_UserLogin", "FK_RoleID = '" + Convert.ToInt32(pkcqid) + "'", "PK_UserID =" + Convert.ToInt32(Session["UserID"].ToString()) + ""); objBL_Common = null; } } } objBL_UserPlan = new BL_UserPlan(); lstUserPlan = new List <UserPlan>(); lstUserPlan = objBL_UserPlan.GetUserPlanBasedonCompanyID(Convert.ToInt32(Session["CompanyID"].ToString())); if (lstUserPlan.Count <= 0) { InsertUserPlan(Convert.ToInt32(Session["UserID"].ToString())); Response.Redirect("Dashboard.aspx", false); } else { Response.Redirect("Dashboard.aspx", false); DataTable dtplantype = new DataTable(); objBL_Common = new BL_Common(); dtplantype = objBL_Common.plantypedetails("*", "EC_PlanType", "PK_PlanID = " + Convert.ToInt32(lstUserPlan[0].FK_PlanID.ToString()) + " and IsActive = 1 order by plandate desc"); string[] UPtype = new string[3]; UPtype[0] = Convert.ToString(dtplantype.Rows[0]["IsSingleUser"]); UPtype[1] = Convert.ToString(dtplantype.Rows[0]["NOC"]); UPtype[2] = Convert.ToString(dtplantype.Rows[0]["AllowedMails"]); Session["lstUserPlanType"] = UPtype; } if (lstUserDetails[0].Email_id != null) { Session["AdminEmilid"] = lstUserDetails[0].Email_id; } if (lstUserDetails[0].FK_RoleID != 0) { roledetails(); } } else { lblerrormsg.Text = "<span style='color:#c85305;font-size:11.5px;'>You have to activate your account from mail sent. Then only you can access your account.</span>"; } } else { lblerrormsg.Text = "<span style='color:#c85305;font-size:11.5px;'>That account doesn't exist. Enter a different account detail or </span> <a href='FreeAccountSignUp.aspx' style='font-size:11.5px; color: #00acec;'>get a new account</a>"; } } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("UserLogin.aspx:btnSubmit_Click() - " + ex.Message); } }