public static bool CheckUsedPasswordAgainstHashed(string username, string plainPassword) { var userFromDb = new UserBLL().getUserByEmail(username); var hashedPassword = userFromDb.Password; var doesPasswordMatch = Crypto.VerifyHashedPassword(hashedPassword, plainPassword); return doesPasswordMatch; }
public ActionResult CompleteOrder() { var myCart = getMyShoppingCart(); User myUser = new UserBLL().getUserByEmail(User.Identity.Name); if(myUser == null) SetSessionMessage(View(), SESSIONMESSAGE.FAIL, "Something went wrong. Please try again"); var myOrder = new Order(); myOrder.User = myUser; myOrder.DateTime = DateTime.Now; myOrder.Items = new List<OrderLine>(); var itemTransaction = new ItemBLL(); foreach(var item in myCart.Items) { item.InStock--; itemTransaction.Update(item); var orderLine = new OrderLine() { Amount = 1, Discount = 0, Item = item }; myOrder.Items.Add(orderLine); } var updatedOrder = new OrderBLL().Insert(myOrder); if(updatedOrder == null) SetSessionMessage(View(), SESSIONMESSAGE.FAIL, "Something went wrong. The order is not registered"); myCart.EmptyCart(); return SetSessionMessage(RedirectToAction("ListAll", "DisplayItems", new { area = "Common" }), SESSIONMESSAGE.SUCCESS, "The order is registered"); }
protected void btn_Sure_Click(object sender, EventArgs e) { UserBLL uBLL = new UserBLL(); string userID = Session["UserID"].ToString(); string oldPwd = txt_Old.Text.Trim(); string newPwd = txt_New.Text.Trim(); //判断旧密码是否正确 Model.User user = uBLL.GetModel(userID); if (user.Password != oldPwd) { UtilityService.Alert(this.Page,"旧密码不正确,请重新输入"); txt_Old.Focus(); return; } bool re = new UserBLL().UpdatePwd(userID, newPwd); if (re) { UtilityService.Alert(this.Page, "修改成功"); //Session["OrganID"] = null; //Session["UserID"] = null; //Session["UserName"] = null; //Session["FcList"] = null; ////Response.Redirect("UpdatePwd.aspx"); } else { UtilityService.Alert(this.Page, "修改失败!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string id = Request.QueryString["id"].ToString(); int postid = Convert.ToInt16(id); string emailid = Session["Email_ID"].ToString(); UserBLL ub = new UserBLL(); int userid = ub.ShowUserID(emailid); UserViewBLL uvb = new UserViewBLL(); int i = uvb.Check(postid, userid); if (i == 0) { Response.Write("<script language='javascript'>alert('You have given your rating !');</script>"); } else { DateTime date = DateTime.Now; int rate = Convert.ToInt16(ddlrating.SelectedValue); string opin = ""; if (rbtndislike.Checked == true) opin = rbtndislike.Text; else opin = rbtnlike.Text; int a = uvb.ProvideUserView(postid, userid, date, rate, opin); if (i == 1) Response.Write("<script language='javascript'>alert('Your rating has been added !');</script>"); else Response.Write("<script language='javascript'>alert('Your rating is failed to be added !');</script>"); } }
protected void btnLogin_Click(object sender, EventArgs e) { string email_id = txtEmail_ID.Text; string password = txtPassword.Text; UserBLL ub = new UserBLL(); int login= ub.Login(email_id,password); if (login == 1) { Session["Email_ID"] = email_id; Response.Redirect("ViewMyPost.aspx"); } else if (login == 10) { Session["Email_ID"] = email_id; Response.Redirect("Admin.aspx"); } else { Response.Write("<script language='javascript'>alert('Email_ID and Password are incorrect !');</script>"); Response.Redirect("Register.aspx"); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int userid = 0; userid = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); try { UserBLL ub = new UserBLL(); int i = ub.DeleteUser(userid); if(i==1) { Response.Write("<script language='javascript'>alert('User has been deleted !');</script>"); GridView1.DataBind(); } else Response.Write("<script language='javascript'>alert('User is failed to be deleted !');</script>"); } catch (SqlException ex) { Response.Write(ex.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { string authoremail = Session["Email_ID"].ToString(); UserBLL ub = new UserBLL(); int userid = ub.ShowUserID(authoremail); lblShowID.Text = userid.ToString(); }
protected void btn_Add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim().ToLower() == "admin") { UtilityService.Alert(this.Page,"admin是非法用户名,请换一个用户名称!"); return; } Model.User u = new Model.User(); u.UserID = txt_UM.Text.Trim(); u.UserName = txt_Name.Text.Trim(); //u.Password = txt_Pwd.Text.Trim(); u.Status = 1; u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"]; u.OpenDate = DateTime.Parse(txt_OpenDate.Text); u.InputBy = Session["UserID"].ToString(); DataSet oldU = new UserBLL().GetList(" UserID = '" + u.UserID + "'"); if (oldU != null && oldU.Tables[0].Rows.Count > 0) { UtilityService.Alert(this, "该用户名已存在!"); return; } int re = new UserBLL().Add(u); if (re > 0) { UtilityService.AlertAndRedirect(this, "添加成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this, "添加失败!"); } }
// GET: Customer/MyUser public ActionResult Index() { string myId = User.Identity.GetUserName(); User myUser = new UserBLL().getUserByEmail(myId); if (myUser == null) return SetSessionMessage(View(myUser), SESSIONMESSAGE.FAIL, "Could not get information for your user"); return View(myUser); }
public ActionResult Edit([Bind(Include = "UserID,FirstName,LastName,Address,PostCode, Email, Telephone")] BOL.Models.User User) { if (ModelState.IsValid) { var updatedUser = new UserBLL().Update(User); if(updatedUser != null) return SetSessionMessage(RedirectToAction("Index"), SESSIONMESSAGE.SUCCESS, "Your user account information is updated"); } return SetSessionMessage(View(User), SESSIONMESSAGE.FAIL, "Something went wrong. Please try again!"); }
protected void btnSubmit_Click(object sender, EventArgs e) { string email_id = txtEmailID.Text; string password = txtPassword1.Text; string fname = txtFirstName.Text; string lname = txtLastName.Text; string country = ddlCountry.SelectedValue; DateTime created = DateTime.Now; string status = "Valid"; string image; if (FileUpload1.PostedFile.ContentLength < 800000) { string fileFullname = this.FileUpload1.FileName; string dataName = DateTime.Now.ToString("yyyyMMddhhmmss"); string fileName = fileFullname.Substring(fileFullname.LastIndexOf("\\") + 1); // string type = fileFullname.Substring(fileFullname.LastIndexOf(".") , 3); string type = fileFullname; //string strFileName = DateTime.Now.ToString("MM-dd-yyyy_HHmmss"); //string strFileType = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); // string type = strFileName.Substring(strFileName.LastIndexOf(".") + 1); type = type.Substring(type.Length - 3); if (type == "bmp" || type == "jpg" || type == "gif" || type == "JPG" || type == "BMP" || type == "GIF") { this.FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/User") + "\\" + dataName + "." + type); // FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/" + fileName + type)); image = "~/images/User/" + dataName + "." + type; UserBLL ub = new UserBLL(); int i= ub.UserRegister(email_id,password,fname,lname,country,created,status,image); if (i > 0) { Response.Write("<script language='javascript'>alert('Your registeration succeed !');</script>"); Response.Redirect("Home.aspx"); } else if (i < 0) Response.Write("<script language='javascript'>alert('This EmailID has already exist, change to another emailID !');</script>"); else Response.Write("<script language='javascript'>alert('Your registeration failed !');</script>"); } else { Response.Write("<script language='javascript'>alert('Support format:|jpg|gif|bmp| !');</script>"); } } else { Response.Write("<script language='javascript'>alert('Your image exceeds 800K!');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { string authoremail = Session["Email_ID"].ToString(); UserBLL ub = new UserBLL(); User author = new User(); author = ub.Show(authoremail); lbl1.Text = author.Email_ID; lbl2.Text = author.FirstName; lbl3.Text = author.LastName; lbl4.Text = author.User_status; }
public void LoadService() { string uid = Request.QueryString["UID"].ToString(); Model.User _p = new UserBLL().GetModel(uid); if (_p != null) { txt_UM.Text = _p.UserID; txt_Name.Text = _p.UserName; ddl_Organ.SelectedValue = _p.OrganID.ToString(); txt_OpenDate.Text = _p.OpenDate.ToString(); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (Session["Email_ID"] == null || Session["Email_ID"] == " ") { string commentcontent = txtcommentcontent.Text; DateTime published = DateTime.Now; int postid = Convert.ToInt16(lblShowPostID.Text); string status = "Valid"; CommentBLL cb = new CommentBLL(); int i = cb.NewComment(postid, commentcontent, published, status); if (i == 1) { Response.Write("<script language='javascript'>alert('Your comment has been added !');</script>"); DataList1.DataBind(); } else { Response.Write("<script language='javascript'>alert('Your comment is failed to be added !');</script>"); DataList1.DataBind(); } } else { string emailid = Session["Email_ID"].ToString(); UserBLL ub = new UserBLL(); int userid = ub.ShowUserID(emailid); string commentcontent = txtcommentcontent.Text; DateTime published = DateTime.Now; int postid = Convert.ToInt16(lblShowPostID.Text); string status = "Valid"; CommentBLL cb = new CommentBLL(); int i = cb.NewComment(userid, postid, commentcontent, published, status); if (i == 1) { Response.Write("<script language='javascript'>alert('Your comment has been added !');</script>"); DataList1.DataBind(); txtcommentcontent.Text = ""; } else { Response.Write("<script language='javascript'>alert('Your comment is failed to be added !');</script>"); DataList1.DataBind(); txtcommentcontent.Text = ""; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string emailid = lbl1.Text; string password = txtPassword.Text; string country = ddlCountry.SelectedValue; UserBLL ub = new UserBLL(); int i= ub.UpdateUser(emailid,password,country); if(i==1) Response.Write("<script language='javascript'>alert('User Account has been updated !');</script>"); else Response.Write("<script language='javascript'>alert('User Account failed to be updated !');</script>"); }
protected void btnAddAsFriend_Click(object sender, EventArgs e) { btnAddAsFriend.Visible = false; btnAddAsFriend.Enabled = false; lblFriendRequestSent.Visible = true; string friendId = Userid; string userId = Session["UserId"].ToString(); FriendsBLL.sendFriendRequest(userId, friendId); UserBLL userbll = new UserBLL(); userbll.registerSubscriber(friendId, userId); btnCancelRequest.Visible = true; btnCancelRequest.Enabled = true; }
public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } User User = new UserBLL().GetById(id); if (User == null) { return HttpNotFound(); } return View(User); }
protected void Page_Load(object sender, EventArgs e) { if (Session["Email_ID"] == null) { Response.Redirect("Home.aspx"); } UserBLL ub = new UserBLL(); User currentauthor = ub.Show(Session["Email_ID"].ToString()); lblShowID.Text = Session["Email_ID"].ToString(); lblShowFirst.Text = currentauthor.FirstName; lblShowLast.Text = currentauthor.LastName; }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string emailid = ""; string userstatus = ""; emailid = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblemailid")).Text; userstatus = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtuserstatus")).Text; UserBLL ub = new UserBLL(); int i = ub.UpdateUser(emailid,userstatus); if (i == 1) Response.Write("<script language='javascript'>alert('User has been updated !');</script>"); else Response.Write("<script language='javascript'>alert('User is failed to be updated !');</script>"); }
protected void btn_Modity_Click(object sender, EventArgs e) { Model.User u = new Model.User(); u.UserID = txt_UM.Text.Trim(); u.UserName = txt_Name.Text.Trim(); u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"]; u.Status = 1; u.OpenDate = DateTime.Parse(txt_OpenDate.Text); bool re = new UserBLL().Update(u); if (re) { UtilityService.AlertAndRedirect(this, "修改成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this, "修改失败!"); } }
/// <summary> /// 设置密码事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rbtnSaveUser_Click(object sender, EventArgs e) { if (Request["UserID"] != null) { string strUserID = Request.QueryString["UserID"]; if (!string.IsNullOrEmpty(strUserID)) { tblUser tblUserObj; UserBLL UserBLLs = new UserBLL(); tblUserObj = UserBLLs.GetByID(strUserID); if (tblUserObj != null) { tblUserObj.LoginPwd = rtxtConfirmPassword.Text; UserBLLs.Update(tblUserObj); ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true); } } } }
public User createUserAndUpdateRole(User User) { using (var UserService = new UserBLL()) { var RoleService = new UserRoleBLL(); int roleId = 0; try { roleId = RoleService.GetList().Where(x => x.RoleStringId == "C").FirstOrDefault().RoleId; User.RoleId = roleId; } catch (Exception) { Role newRole = RoleService.Insert(new Role { RoleStringId = "C", RoleName = "Customer" }); User.RoleId = newRole.RoleId; } User.RoleStringId = "C"; User.Password = PasswordUtility.HashMyPassword(User.Password); return UserService.Insert(User); } }
protected void btn_Add_Click(object sender, EventArgs e) { if (list_Aim.Items.Count >= 0) { List<string> all = new List<string>(); string _userID = Request.QueryString["code"].ToString(); foreach (ListItem li in list_Aim.Items) { string c = li.Value.ToString(); all.Add(c); } int re = new UserBLL().AddRole2User(_userID, all); if (re > 0) { UtilityService.Alert(this, "设定完成!"); } else { UtilityService.Alert(this, "设定失败!"); } } }
protected void btn_Delete_Click(object sender, ImageClickEventArgs e) { string idList = string.Empty; foreach (GridViewRow dr in GridView1.Rows) { CheckBox chk = (CheckBox)dr.FindControl("chk"); if (chk != null && chk.Checked) { string _id = "'" + dr.Cells[1].Text.Trim() + "'"; string _name = dr.Cells[2].Text.Trim(); if (_name == "admin") { UtilityService.Alert(this.Page, "禁止删除系统管理员"); return; } idList += _id + ","; } } if (idList.Length > 0) { idList = idList.TrimEnd(','); bool re = new UserBLL().DeleteList(idList); if (re) { UtilityService.AlertAndRedirect(this.Page, "删除成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this.Page, "删除失败!"); } } }
private bool AuthenticateUser() { bool blnIsAuthenticated = true; User objUser = new User(); UserBLL objUserBll = new UserBLL(); try { string strLogin = txtUserName.Text.Trim(); string strPassword = txtPassword.Text.Trim(); if (!(string.IsNullOrEmpty(strLogin) && string.IsNullOrEmpty(strPassword))) { objUser.LoginID = strLogin; objUser.LoginPassword = strPassword; objUserBll.AuthenticationValidation(ref objUser); if (string.IsNullOrEmpty(objUser.FirstName)) { blnIsAuthenticated = false; } else { StoreValuesToSession(objUser); } } else { errMsg.InnerHtml = "Invalid login credentials"; } } catch (Exception ex) { SendMail.MailMessage("CSWeb > Error > "+ (new System.Diagnostics.StackTrace()).GetFrame(0).GetMethod().Name,ex.ToString()); } return blnIsAuthenticated; }
public string UserCurrentGetName() { return(UserBLL.UserCurrentGetName()); }
/// <summary> /// 执行Action之前触发 /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(HttpActionContext actionContext) { if (actionContext.Request.Method != HttpMethod.Get) { if (actionContext.ControllerContext.Controller.GetType().GetCustomAttributes(typeof(NotVerificationLoginAttribute), false).Length == 0) { string MeName = actionContext.ControllerContext.Request.RequestUri.Segments.Last(); if (actionContext.ControllerContext.Controller.GetType().GetMethod(MeName).GetCustomAttributes(typeof(NotVerificationLoginAttribute), false).Length == 0) { object obj = actionContext.ActionArguments.ToArray()[0].Value; Type objType = obj.GetType(); Type iVerificationLoginType = objType.GetInterface(nameof(IVerificationLoginModel)); if (iVerificationLoginType != null) { IVerificationLoginModel queryM = (IVerificationLoginModel)obj; if (queryM.LoginUserID != null && queryM.LoginUserToken != null) { TokenBLL tokenBLL = new TokenBLL(); bool resM = tokenBLL.TokenValid(queryM.LoginUserID, queryM.LoginUserToken, TokenTypeEnum.Login); if (resM) { #region 验证权限 UserBLL userBLL = new UserBLL(); object[] rightsCodeAttrs = actionContext.ControllerContext.Controller.GetType().GetCustomAttributes(typeof(PermissionsCodeAttribute), false); if (rightsCodeAttrs.Length > 0) { if (rightsCodeAttrs[0] is PermissionsCodeAttribute permissionsAttr) { if (userBLL.HasPermissions(queryM.LoginUserID, permissionsAttr.Code)) { base.OnActionExecuting(actionContext); } else { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Forbidden); } } } else { rightsCodeAttrs = actionContext.ControllerContext.Controller.GetType().GetMethod(MeName).GetCustomAttributes(typeof(PermissionsCodeAttribute), false); if (rightsCodeAttrs.Length > 0) { if (rightsCodeAttrs[0] is PermissionsCodeAttribute permissionsAttr) { if (userBLL.HasPermissions(queryM.LoginUserID, permissionsAttr.Code)) { base.OnActionExecuting(actionContext); } else { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Forbidden); } } } else { base.OnActionExecuting(actionContext); } } #endregion } else//Token过期或用户不存在 { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized); } } else//不包含所需参数400 { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest); } } else//不实现登录验证接口 { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest); } } } } }
public MainForm() { InitializeComponent(); userbll = UserBLL.GetBLLObject(); }
private void PopulateGrid() { try { if (txtSearch.Text.Trim() != "Search") { objPI.SearchText = txtSearch.Text.Trim(); } else { objPI.SearchText = ""; } if (objPI.SortDirection == null && objPI.SortColumnName == null) { objPI.SortDirection = Convert.ToString(ViewState[Constants.SORTDERECTION]); objPI.SortColumnName = Convert.ToString(ViewState[Constants.SORTCOLUMNNAME]); } UserBLL objUserBLL = new UserBLL(); List<User> objData = new List<User>(); objData = objUserBLL.GetAllUser(objData, objPI); gvGrid.DataSource = objData; gvGrid.ExportTemplate = "export_template_4Column.xlsx"; gvGrid.ExportCaption = ""; gvGrid.ExcelColumn = ""; gvGrid.DataBind(); if (objData != null) { if (!iFlag && lblMsg.Text == "") { int mintMode = Common.GetQueryStringIntValue("Mode"); if (mintMode > 0) { if (mintMode == 1) { divMess.Attributes.Add("class", "success"); divMess.Visible = true; lblMsg.Text = "-'" + objData[0].FirstName + "' " + Constants.Added; } else if (mintMode == 2) { } } else { divMess.Visible = false; lblMsg.Text = ""; } } else { if (lblMsg.Text == "") { divMess.Visible = false; lblMsg.Text = ""; } } } } catch (Exception ex) { SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString()); } }
private void SaveData(string vstrMode,int vintUserID ) { User objUser = new User(); UserBLL objUBLL=new UserBLL(); objUser.UserID=vintUserID; objUser.UserTypeID =Convert.ToInt32(ddlUserType.SelectedItem.Value.ToString()); objUser.FirstName = txtFirstName.Text.Trim(); objUser.LastName = txtLastName.Text.Trim(); objUser.LoginID = txtLoginID.Text.Trim(); objUser.LoginPassword = txtPassword.Text.Trim(); objUser.CommunicationEmailID = txtEmailID.Text.Trim(); Message objMsg = objUBLL.InsertUpdatePlatformUser(objUser); lblError.InnerHtml = objMsg.ReturnMessage; if (objMsg.ReturnValue > 0) { divMess.Visible = true; lblMsg.Text = objMsg.ReturnMessage; ViewState["intUserID"] = null; PopulateGrid(); } else { Page.ClientScript.RegisterStartupScript(GetType(), "AddEditUser", "ShowModalDiv('ModalWindow1','dvInnerWindow',0);", true); } }
private void LoadData(int vintUserID) { try { User objUser = new User(); UserBLL objUBLL = new UserBLL(); objUser.UserID = vintUserID; List<User> objList = objUBLL.GetPlatformUserByUserID(ref objUser); if (null != objList) { ddlUserType.SelectedValue = objList[0].UserTypeID.ToString(); txtFirstName.Text = objList[0].FirstName; txtLastName.Text = objList[0].LastName; txtLoginID.Text = objList[0].LoginID; txtPassword.Text = objList[0].LoginPassword; txtEmailID.Text = objList[0].CommunicationEmailID; ScriptManager.RegisterStartupScript(this, this.GetType(), "AddEditUser", "ShowModalDiv('ModalWindow1','dvInnerWindow',0);", true); } } catch (Exception ex) { SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString()); } }
protected void gvGrid_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Edit") { int intUserID = Convert.ToInt32(e.CommandArgument.ToString()); ViewState["intUserID"] = intUserID; LoadData(intUserID); } if (e.CommandName == "Delete") { Message vobjMsg = new Message(); int intUserID = Convert.ToInt32(e.CommandArgument.ToString()); User objUser = new User(); UserBLL objUBLL = new UserBLL(); objUser.UserID = intUserID; vobjMsg = objUBLL.DeletePlatformUser(objUser); if (vobjMsg.ReturnValue > 0) { divMess.Visible = true; lblMsg.Text = Constants.Deleted; divMess.Attributes.Add("class", "Deleted"); lblMsg.Style.Add("color", "Black"); } else { divMess.Visible = true; lblMsg.Style.Add("color", "Red"); divMess.Attributes.Add("class", "error"); lblMsg.Text = vobjMsg.ReturnMessage; } } } catch (Exception ex) { SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString()); } }
private void FrmMain_Load(object sender, EventArgs e) { try { uBll = new UserBLL(); uRights = new List <UserRight>(); this.prj = new ProjectDetail(); this.Text = this.prj.CompanyName + " - " + this.prj.ProjectTitle; uRights = uBll.GetUserRights(IsLoginUser); foreach (UserRight item in uRights) { if (item.Screen.ScreenName == "Patient Registration") { if (item.CanAccess == true) { tsPatientRegistration.Enabled = true; } else { tsPatientRegistration.Visible = false; } } if (item.Screen.ScreenName == "Doctor Checkup") { if (item.CanAccess == true) { tsDoctorsCheckup.Enabled = true; } else { tsDoctorsCheckup.Visible = false; } } if (item.Screen.ScreenName == "Room") { if (item.CanAccess == true) { tsRoom.Enabled = true; } else { tsRoom.Visible = false; } } if (item.Screen.ScreenName == "Print Summary") { if (item.CanAccess == true) { tsPrintSummary.Enabled = true; } else { tsPrintSummary.Visible = false; } } if (item.Screen.ScreenName == "Lab Test") { if (item.CanAccess == true) { tsLabTest.Enabled = true; } else { tsLabTest.Visible = false; } } if (item.Screen.ScreenName == "Create /Change User") { if (item.CanAccess == true) { tsUser.Enabled = true; } else { tsUser.Visible = false; } } if (item.Screen.ScreenName == "Backup Restore") { if (item.CanAccess == true) { tsBackup.Enabled = true; } else { tsBackup.Visible = false; } } if (item.Screen.ScreenName == "User Right") { if (item.CanAccess == true) { tsUserRight.Enabled = true; } else { tsUserRight.Visible = false; } } if (item.Screen.ScreenName == "Setup Led") { if (item.CanAccess == true) { tsSetupLED.Enabled = true; } else { tsSetupLED.Visible = false; } } } if (!this.IsLoginUser.IsAdmin) { //this.tsUser.Visible = false; //this.tsLabTest.Visible = false; } this.bgWorker.DoWork += new DoWorkEventHandler(this.bgWorker_DoWork); //this.bgWorker.RunWorkerAsync(); //if (!this.upDdBll.IsDBUpdated()) //{ // MessageBox.Show("Your current company is not setup.\r\nPlease update database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // FrmUpdateDB edb = new FrmUpdateDB(); // edb.ShowDialog(); // if (!edb.DataBaseUpdated) // { // MessageBox.Show("Your current company is not Setup properly.\r\n Please update database", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // this.tsPrintLabels.Visible = false; // } //} } catch (Exception exception) { MessageBox.Show(exception.Message, "frmMain_Load"); } }
protected void btnReturn_Click(object sender, EventArgs e) { try { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } if (string.IsNullOrEmpty(txtcomment.Text)) { modalErr.Visible = true; modalErr.InnerText = "Comment is required!!!"; mpeAppr.Show(); return; } bool isset = false; AppUser budgetInputer = new AppUser(); foreach (GridViewRow row in gvDept.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Label lbID = row.FindControl("lbRecID") as Label; int recID = int.Parse(lbID.Text); IncomeProjection expPro = CommonBLL.GetIncomePro(recID); if (expPro != null && expPro.Status == (int)Utility.BudgetItemStatus.Approved) { expPro.Status = (int)Utility.BudgetItemStatus.Returned_For_Correction; CommonBLL.UpdateIncomePro(expPro); budgetInputer = UserBLL.GetUserByUserName(expPro.AddeBy); isset = true; } } } if (isset) { BindGrid(); //sending mail string body = ""; string from = ConfigurationManager.AppSettings["exUser"].ToString(); string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string appLogo = ConfigurationManager.AppSettings["appLogoUrl"].ToString(); string hodEmail = UserBLL.GetApproverEmailByDept(budgetInputer.DepartmentID.Value); string subject = "Budget Item Correction Notification"; string FilePath = Server.MapPath("EmailTemplates/"); if (File.Exists(FilePath + "ReturnBudget.htm")) { FileStream f1 = new FileStream(FilePath + "ReturnBudget.htm", FileMode.Open); StreamReader sr = new StreamReader(f1); body = sr.ReadToEnd(); body = body.Replace("@add_appLogo", appLogo); body = body.Replace("@siteUrl", siteUrl); body = body.Replace("@BudgetElement", "Inflow Projection"); body = body.Replace("@add_Comment", txtcomment.Text); //Replace the values from DB or any other source to personalize each mail. f1.Close(); } string rst = ""; try { rst = Utility.SendMail(budgetInputer.Email, from, hodEmail, subject, body); } catch { } if (rst.Contains("Successful")) { success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully Returned for correction.Notification has been sent to Initiator"; return; } else { success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully Returned for correction.Notification could NOT be sent at this time"; return; } } else { BindGrid(); error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Either no record is selected OR some of selected record(s) could not be approved.If error persist contact Administrator!!."; } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.Message); } }