Пример #1
0
        public JsonResult Login(LoginModel login)
        {
            string result  = "Error";
            string pass    = Encrypt_Decrypt.Encrypt(login.Password, Password);
            var    loggedU = Connection.SMGT_UserLogin(login.UserName, pass).FirstOrDefault();

            if (loggedU != null)
            {
                USession.Email_        = loggedU.LoginEmail;
                USession.Is_Active     = loggedU.IsActive;
                USession.Job_          = loggedU.JobDescription;
                USession.Mobile_       = loggedU.Mobile;
                USession.Person_Name   = loggedU.PersonName;
                USession.School_Id     = loggedU.SchoolId;
                USession.User_Category = loggedU.UserCategory;
                USession.User_Id       = loggedU.UserId;

                Session["User_Name"] = loggedU.UserId;

                result = "Succes";
            }
            else
            {
                result = "Failed";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
 public HttpResponseMessage reg(Employee emp)
 {
     if (System.Web.HttpContext.Current.Session["GeneratedOTP"].Equals(emp.OTP.ToString()))
     {
         var    emailID_lowercase = emp.EmailID.ToLower();
         string encPassword;
         var    empname_Corrected = new System.Globalization.CultureInfo("en-US", false).TextInfo.ToTitleCase(emp.EmpName.ToLower());
         //Module for Encryption
         #region EncryptPassword
         Encrypt_Decrypt ObjEnc = new Encrypt_Decrypt();
         ObjEnc.Password           = emp.EmpPass;
         ObjEnc.saltValue          = "sALtValue";
         ObjEnc.passwordIterations = 7;
         ObjEnc.initVector         = "~1B2c3D4e5F6g7H8";
         ObjEnc.keySize            = 256;
         encPassword = ObjEnc.Encrypt(ObjEnc);// Converting the password to an encrypted one
         #endregion
         var entity = entities.usp_RegEmployee(emp.EmpID, empname_Corrected, emailID_lowercase, encPassword, emp.IsOrganiser);
         if (entity != null)
         {
             // HttpContext.Current.Session["UserID"] = emp.EmailID;//Just to check the value entered here is getting recieved in login page or not
             return(Request.CreateResponse(HttpStatusCode.Created, entity));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee not found"));
         }
     }
     else
     {
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Incorrect OTP"));
     }
 }
Пример #3
0
        public JsonResult NewUser(UserModel Model)
        {
            try
            {
                string  pass = Encrypt_Decrypt.Encrypt(Model.Password, Password);
                tblUser user = new tblUser();

                user.PersonName     = Model.PersonName;
                user.CreatedBy      = "ADMIN";
                user.CreatedDate    = DateTime.Now;
                user.IsActive       = "Y";
                user.JobDescription = Model.JobDescription;
                user.LoginEmail     = Model.LoginEmail;
                user.Mobile         = Model.Mobile;
                user.Password       = pass;
                user.UserCategory   = Model.UserCategory;
                user.UserId         = Model.UserId;
                user.SchoolId       = "GD";

                Connection.tblUsers.Add(user);
                Connection.SaveChanges();

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch (Exception Ex)
            {
                Errorlog.ErrorManager.LogError("NewUser(UserModel Model)@ UserController", Ex);
                return(Json("Exception", JsonRequestBehavior.AllowGet));
            }
        }
Пример #4
0
        public HttpResponseMessage validate(Employee emp)
        {
            string encPassword;
            var    emailID_lowercase = emp.EmailID.ToLower();

            HttpContext.Current.Session["UserEmail"] = emp.EmailID;  // Session of user as Email ID
            #region DecryptEnteredPassword
            Encrypt_Decrypt ObjEnc = new Encrypt_Decrypt();
            ObjEnc.Password           = emp.EmpPass;//Providing Password to Encrypt
            ObjEnc.saltValue          = "sALtValue";
            ObjEnc.passwordIterations = 7;
            ObjEnc.initVector         = "~1B2c3D4e5F6g7H8";
            ObjEnc.keySize            = 256;
            encPassword = ObjEnc.Encrypt(ObjEnc);// Converting the password to an encrypted one
            #endregion
            var    entity      = entities.usp_LoginValidate(emailID_lowercase, encPassword).ToList();
            var    entity1     = entity[0].Split(':').ToArray();
            string resultStore = entity1[0];
            if (entity1.Length == 2)
            {
                string EmpNameLogin = entity1[1];
                HttpContext.Current.Session["UserName"] = EmpNameLogin;
            }
            if (entity != null && resultStore == "Match")
            {
                return(Request.CreateResponse(HttpStatusCode.OK, entity[0]));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Username/Password"));
            }
        }
Пример #5
0
        public string setNewUser(M_Users Model, string Createdby)
        {
            try
            {
                bool Uname = checkUserName(Model.UserId);
                if (Uname)
                {
                    return("IN");
                }
                string pass = Encrypt_Decrypt.Encrypt(Model.Password_, Password);
                using (DBLinqDataContext datacontext = new DBLinqDataContext())
                {
                    datacontext.Connection.ConnectionString = Connection_;

                    datacontext._setNewUser(Model.UserId, Model.UserGroup, Model.UserName, pass,
                                            Model.Designation, Model.Email, Createdby);
                    datacontext.SubmitChanges();
                    return("Success");
                }
            }
            catch (Exception ex)
            {
                // Console.WriteLine(ex.Message.ToString());
                ErrorLog.LogError(ex);
                return("Error");
            }
        }
Пример #6
0
        public void Execute(object parameter)
        {
            var passwordUser = Encrypt_Decrypt.Encrypt((parameter as PasswordBox).Password);
            var item         = loginViewModel.Users.FirstOrDefault(x => x.Username == loginViewModel.CurrentUser.Username && x.Password == passwordUser);

            if (item != null)
            {
                var index = loginViewModel.Users.IndexOf(item);
                loginViewModel.Users[index].Presently = true;
                App.Db.UserRepository.Update(loginViewModel.Users[index]);
                Window1 window1 = new Window1();
                loginViewModel.Login.Close();
                window1.ShowDialog();
            }
            else
            {
                if (loginViewModel.Users.FirstOrDefault(x => x.Username == loginViewModel.CurrentUser.Username) == null)
                {
                    loginViewModel.Login.Username.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xFF, 0, 0));
                }
                if (loginViewModel.Users.FirstOrDefault(x => x.Password == loginViewModel.CurrentUser.Password) == null)
                {
                    loginViewModel.Login.Password.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xFF, 0, 0));
                }
            }
        }
    protected void dlOrderList_ItemCommand(object source, DataListCommandEventArgs e)
    {
        string command = e.CommandName;
        int    Index   = e.Item.ItemIndex;

        switch (command)
        {
        case "Exp_Col":
        {
            DataListItem item = dlOrderList.Items[Index];
            //Label test = item.FindControl("lblC_P") as Label;
            ImageButton img = item.FindControl("ibtnNOExpColap") as ImageButton;
            if (img.ImageUrl == "~/images/expand.JPG")
            {
                ((ImageButton)dlOrderList.Items[Index].FindControl("ibtnNOExpColap")).ImageUrl = "~/images/collapse.JPG";
                ((GridView)dlOrderList.Items[Index].FindControl("gvNewOrder")).Visible         = true;
            }
            else if (img.ImageUrl == "~/images/collapse.JPG")
            {
                ((ImageButton)dlOrderList.Items[Index].FindControl("ibtnNOExpColap")).ImageUrl = "~/images/expand.JPG";
                ((GridView)dlOrderList.Items[Index].FindControl("gvNewOrder")).Visible         = false;
            }
        }
        break;

        case "BranchOrder":
        {
            Session["sOrderID"] = Encrypt_Decrypt.Encrypt(((LinkButton)dlOrderList.Items[Index].FindControl("lbtnOrderID")).Text, true);
            Response.Redirect("~/mudar/UpdateOrder.aspx");
        }
        break;

        case "Display":
        {
            string str = ((HiddenField)dlOrderList.Items[Index].FindControl("hfOrderPdf")).Value.ToString();
            //ifOrderPdf.Attributes.Add("src", str);
            //ifOrderPdf.Attributes.Add("src", "../Attachments/OrderPDF/1015/1015_PO201296.pdf");
        }
        break;

        case "Download":
        {
            string       str      = ((HiddenField)dlOrderList.Items[Index].FindControl("hfOrderPdf")).Value.ToString();
            WebClient    req      = new WebClient();
            HttpResponse response = HttpContext.Current.Response;
            response.Clear();
            response.ClearContent();
            response.ClearHeaders();
            response.Buffer = true;
            response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(str) + "\"");
            byte[] data = req.DownloadData(Server.MapPath(str));
            response.BinaryWrite(data);
            response.End();
        }
        break;
        }
    }
        /*
         *  Member Login Button Click Event Handler - Lecture 24 Slide 43
         */
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string filePath = HttpRuntime.AppDomainAppPath + @"\Account\App_Data\Members.xml";

            string user = txtUsername.Text;
            string password = txtPassword.Text;

            string pwdEncrypt = "";

            /* IMPLEMENT OUR ENCRYPTION/DECRYPTION */
            pwdEncrypt = Encrypt_Decrypt.Encrypt(password);

            /* Create XmlDocument and load the Members.xml data into it */
            XmlDocument myDoc = new XmlDocument();
            myDoc.Load(filePath);

            XmlElement rootElement = myDoc.DocumentElement;     // open file

            foreach(XmlNode node in rootElement.ChildNodes)
            {

                // if username and pw match, create login cookie and redirect to MemberPage
                // else, diplay invalid credentials
                if(node["Username"].InnerText == user)
                {
                    // compare encrypted passwords to see if they are the same,
                    // cannot get my decryption to work (Encrypt_Decrypt.Decrypt(node["Password"].InnerText))
                    if(node["Password"].InnerText == pwdEncrypt)
                    {
                        errorLabel.Visible = false;

                        HttpCookie myCookies = new HttpCookie("myCookieId");
                        myCookies["Username"] = user;
                        myCookies["Password"] = password;
                        Response.Cookies.Add(myCookies);

                        Session["MemberName"] = user;
                        Session["MemberID"] = 1;
                        Response.Redirect("MemberPage.aspx");
                        return;
                    }
                    // Username exists but pw doesnt match
                    else
                    {
                        errorLabel.Text = "*Invalid Credentials";
                        errorLabel.Visible = true;
                        return;
                    }
                }
            }

            errorLabel.Text = "*Invalid Credentials";
            errorLabel.Visible = true;
            return;
        }
Пример #9
0
        public ActionResult ChangePassword(LoginModel login)
        {
            string  result = "Error";
            string  Uid    = Session["VerifiedUserID"].ToString();
            tblUser Usre   = Connection.tblUsers.Where(u => u.UserId == Uid).FirstOrDefault();
            string  pass   = Encrypt_Decrypt.Encrypt(login.Password, Password);

            if (Usre != null)
            {
                Usre.Password = pass;
                Connection.SaveChanges();
                result = "Success";
                Session.Remove("VerifiedUserID");
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #10
0
        public void Execute(object parameter)
        {
            var item  = userViewModel.Users.FirstOrDefault(x => x.Id == userViewModel.CurrentUser.Id);
            int index = userViewModel.Users.IndexOf(item);

            if (userViewModel.CurrentUser.Password != userViewModel.Users[index].Password)
            {
                userViewModel.CurrentUser.Password = Encrypt_Decrypt.Encrypt(userViewModel.CurrentUser.Password);
            }
            item.Password = userViewModel.CurrentUser.Password;
            userViewModel.Users[index] = userViewModel.CurrentUser;
            App.Db.UserRepository.Update(userViewModel.CurrentUser);
            (parameter as PasswordBox).Password = string.Empty;

            userViewModel.CurrentUser = new UserEntity();
            userViewModel.SelectUser  = new UserEntity();
        }
Пример #11
0
        private string getTaskLinkEnc(string taskID)
        {
            string link = "";
            Task   task = new Task();

            task.LoadByPrimaryKey(long.Parse(taskID));
            if (task.RowCount > 0 && task.s_TaskPage != "" && task.s_RefrenceNumber != "")
            {
                link = task.TaskPage + task.RefrenceNumber;
            }
            else
            {
                string url      = "/Tasks/TaskDetails.aspx?Task=";
                string queryStr = Encrypt_Decrypt.Encrypt(taskID, UserID.ToString());
                link = url + Server.UrlEncode(queryStr);
            }
            return(link);
        }
Пример #12
0
        public M_Login getUserLogin(M_Login Usr)
        {
            try
            {
                using (DBLinqDataContext datacontext = new DBLinqDataContext())
                {
                    datacontext.Connection.ConnectionString = Connection_;
                    M_Login usr  = new M_Login();
                    string  pass = Encrypt_Decrypt.Encrypt(Usr.Password_, Password);

                    System.Data.Linq.ISingleResult <_getUserloginResult> loggedUser = datacontext._getUserlogin(Usr.User_ID, pass);
                    foreach (_getUserloginResult result in loggedUser)
                    {
                        if (result.UserId.Equals(Usr.User_ID) && result.Password.Equals(pass))
                        {
                            usr.User_ID      = result.UserId;
                            usr.UserGroup_ID = result.UserGroupID;

                            usr.Is_Active = result.IsActive;
                            // usr.Is_Vat = result.IsVat;
                            usr.PassowordExpiry_Date = result.PassowordExpiryDate.ToString();
                            usr.Person_Name          = result.PersonName;
                            usr.Customer_ID          = result.ParentCustomerId;
                            if (usr.Is_Active == "N")
                            {
                                return(null);
                            }
                            else
                            {
                                return(usr);
                            }
                        }
                    }
                    return(null);
                }
            }
            catch (Exception ex)
            {
                // Console.WriteLine(ex.Message.ToString());
                ErrorLog.LogError(ex);
                return(null);
            }
        }
Пример #13
0
        public bool ResetPassword(M_Users Model)
        {
            try
            {
                string pass = Encrypt_Decrypt.Encrypt(Model.Password_, Password);
                using (DBLinqDataContext datacontext = new DBLinqDataContext())
                {
                    datacontext.Connection.ConnectionString = Connection_;

                    datacontext._setResetPassword(Model.UserId, pass);
                    datacontext.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                // Console.WriteLine(ex.Message.ToString());
                ErrorLog.LogError(ex);
                return(false);
            }
        }
Пример #14
0
 protected void rptrMyTeam_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     try
     {
         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
         {
             DataRow   teamMate            = ((DataRow)e.Item.DataItem);
             HyperLink lnkTeamMateRep      = ((HyperLink)e.Item.FindControl("lnkTeamMate"));
             Image     imgTeamMatePhotoRep = ((Image)e.Item.FindControl("imgTeamMatePhoto"));
             Label     lblTeamMateNameRep  = ((Label)e.Item.FindControl("lblTeamMateName"));
             lnkTeamMateRep.NavigateUrl = "/Employees/EmployeeDetails.aspx?Employee=" +
                                          Encrypt_Decrypt.Encrypt(teamMate["ID"].ToString(), key);
             imgTeamMatePhotoRep.ImageUrl = getTeamMatePhoto(teamMate["ID"].ToString());
             imgTeamMatePhotoRep.ToolTip  = teamMate["FirstName"].ToString() + " " + teamMate["LastName"].ToString();
             lblTeamMateNameRep.Text      = teamMate["FirstName"].ToString();
         }
     }
     catch (Exception ex)
     {
         //Logger.LogException(ex);
     }
 }
Пример #15
0
        public ActionResult PasswordChange(LoginModel login)
        {
            string  result  = "Error";
            tblUser Usre    = Connection.tblUsers.Where(u => u.UserId == USession.User_Id).FirstOrDefault();
            string  oldpass = Encrypt_Decrypt.Encrypt(login.Password, Password);
            string  newpass = Encrypt_Decrypt.Encrypt(login.NewPassword, Password);

            if (Usre != null)
            {
                if (Usre.Password == oldpass)
                {
                    Usre.Password = newpass;
                    Connection.SaveChanges();
                    result = "Success";
                }
                else
                {
                    result = "Wrong";
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #16
0
        public void Execute(object parameter)
        {
            var item = userViewModel.Users.FirstOrDefault(x => x.Username == userViewModel.CurrentUser.Username);

            if (item == null)
            {
                if (userViewModel.Users.Count != 0)
                {
                    userViewModel.CurrentUser.Id = userViewModel.Users[userViewModel.Users.Count - 1].Id + 1;
                }
                else
                {
                    userViewModel.CurrentUser.Id = 1;
                }
                userViewModel.CurrentUser.Password = (parameter as PasswordBox).Password;
                userViewModel.CurrentUser.Password = Encrypt_Decrypt.Encrypt(userViewModel.CurrentUser.Password);
                userViewModel.Users.Add(userViewModel.CurrentUser);
                App.Db.UserRepository.Insert(userViewModel.CurrentUser);
                (parameter as PasswordBox).Password = string.Empty;
                userViewModel.CurrentUser           = new UserEntity();
                userViewModel.SelectUser            = new UserEntity();
            }
        }
Пример #17
0
        public HttpResponseMessage UpdatePass(Employee emp)

        {
            int      x     = 0;
            DateTime dtOtp = Convert.ToDateTime(System.Web.HttpContext.Current.Session["OTPTimeStamp"]);
            DateTime dtNow = DateTime.Now;

            if (emp.OTP.ToString().Equals(System.Web.HttpContext.Current.Session["GeneratedOTP"]) &&
                dtNow.Subtract(dtOtp).TotalMinutes < 16)
            {
                #region EncryptNewPassword
                Encrypt_Decrypt ObjEnc = new Encrypt_Decrypt();
                ObjEnc.Password           = emp.EmpPass;//Providing Password to Encrypt
                ObjEnc.saltValue          = "sALtValue";
                ObjEnc.passwordIterations = 7;
                ObjEnc.initVector         = "~1B2c3D4e5F6g7H8";
                ObjEnc.keySize            = 256;
                string encPassword = ObjEnc.Encrypt(ObjEnc);
                #endregion
                //Updating the new password as encrypted value in db
                var entity = entities.usp_UpdateEmployee(x, x.ToString(), HttpContext.Current.Session["UserEmail"].ToString(), encPassword, false);
                if (entity != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.Created, entity));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Updation of password failed"));
                }
            }

            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "OTP did not match"));
            }
        }
Пример #18
0
 protected void rptFiveLotSamples_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     Session["sOrderID"] = Encrypt_Decrypt.Encrypt(e.CommandArgument.ToString(), true);
     Response.Redirect("~/Orders/BranchOrder.aspx");
 }
Пример #19
0
        public ActionResult Create(ParentModel Model)
        {
            using (var scope = new TransactionScope())
            {
                try
                {
                    String result = "error";


                    string _path  = "";
                    string _pathL = "";
                    Model.IsActive  = "Y";
                    Model.CreatedBy = "User1";
                    //   Model.UserId = "User1";
                    if (ModelState.IsValid)
                    {
                        if (Model.File == null)
                        {
                        }
                        else
                        {
                            if (Model.File.ContentLength > 0)
                            {
                                string fnm        = DateTime.Now.ToString("");
                                string nwString22 = fnm.Replace("-", ".");
                                string nwString   = nwString22.Replace("/", ".");
                                string nwString2  = nwString.Replace(" ", ".");
                                string time       = nwString2.Replace(":", ".");

                                string _FileName = time + "_" + Path.GetFileName(Model.File.FileName);
                                _pathL = Path.Combine(Server.MapPath("~/Uploads/Parent/Photo"), _FileName);
                                _path  = "~/Uploads/Parent/Photo/" + _FileName;
                                Model.File.SaveAs(_pathL);
                            }
                        }



                        Connection.SMGTsetParent(Model.ParentName, Model.RelationshipId, Model.Address1, Model.Address2, Model.Address3, Model.HomeTelephone, Model.PersonalEmail, Model.PersonalMobile, Model.Occupation, Model.OfficeAddress1, Model.OfficeAddress2, Model.OfficeAddress3, Model.OfficePhone, Model.officeEmail, Model.NIC, Model.UserId, _path, Model.DateofBirth, Model.CreatedBy, Model.IsActive, USession.School_Id);
                        Connection.SaveChanges();
                        var Count = Connection.tblUsers.Count(X => X.UserId == Model.UserId);
                        if (Count == 0)
                        {
                            tblUser usr = new tblUser();
                            usr.CreatedBy      = USession.User_Id;
                            usr.CreatedDate    = DateTime.Now;
                            usr.LoginEmail     = Model.PersonalEmail;
                            usr.Mobile         = Model.PersonalMobile;
                            usr.UserCategory   = "PARNT";
                            usr.JobDescription = Model.Occupation;
                            usr.SchoolId       = USession.School_Id;

                            string pass = Encrypt_Decrypt.Encrypt(Model.Password, Password);

                            usr.Password   = pass;
                            usr.UserId     = Model.UserId;
                            usr.PersonName = Model.ParentName;
                            usr.IsActive   = "Y";

                            Connection.tblUsers.Add(usr);
                            Connection.SaveChanges();


                            List <tblParent> prntRlist = Connection.tblParents.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.ParentlList = new SelectList(prntRlist, "ParentId", "ParentName");

                            List <tblRelashionship> SRlist = Connection.tblRelashionships.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.RelationshipList = new SelectList(SRlist, "RelashionshipId", "RelashionshipName");
                            List <tblSchool> Schoollist = Connection.tblSchools.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.SchoolDrpDown = new SelectList(Schoollist, "SchoolId", "SchoolName");
                            List <tblGrade> gradelist = Connection.tblGrades.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.SchoolGradeList = new SelectList(gradelist, "GradeId", "GradeName");
                            List <tblClass> Classlist = Connection.tblClasses.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.classDrpDown = new SelectList(Classlist, "ClassId", "ClassName");
                            List <tblStudent> Studentlist = Connection.tblStudents.Where(X => X.IsActive == "Y" && X.SchoolId == USession.School_Id).ToList();
                            ViewBag.StudentIdList = new SelectList(Studentlist, "StudentId", "StudentName");
                            String             parentid = "2";
                            var                STQlist  = Connection.SMGTgetParentStudentadd(parentid, "%").ToList();
                            List <ParentModel> List     = STQlist.Select(x => new ParentModel
                            {
                                StudentId   = x.StudentId,
                                ParentName  = x.ParentName,
                                ParentId    = x.ParentId.ToString(),
                                StudentName = x.studentName
                            }).ToList();

                            Model.UserId = "Parent1";



                            //  scope.Complete();


                            scope.Complete();
                            result = "Success";
                            ModelState.Clear();
                            return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            result = "Exits";

                            List <tblParent> prntRlist = Connection.tblParents.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.ParentlList = new SelectList(prntRlist, "ParentId", "ParentName");

                            List <tblRelashionship> SRlist = Connection.tblRelashionships.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.RelationshipList = new SelectList(SRlist, "RelashionshipId", "RelashionshipName");
                            List <tblSchool> Schoollist = Connection.tblSchools.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.SchoolDrpDown = new SelectList(Schoollist, "SchoolId", "SchoolName");
                            List <tblGrade> gradelist = Connection.tblGrades.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.SchoolGradeList = new SelectList(gradelist, "GradeId", "GradeName");
                            List <tblClass> Classlist = Connection.tblClasses.Where(X => X.IsActive == "Y").ToList();
                            ViewBag.classDrpDown = new SelectList(Classlist, "ClassId", "ClassName");
                            List <tblStudent> Studentlist = Connection.tblStudents.Where(X => X.IsActive == "Y" && X.SchoolId == USession.School_Id).ToList();
                            ViewBag.StudentIdList = new SelectList(Studentlist, "StudentId", "StudentName");
                            String             parentid = "2";
                            var                STQlist  = Connection.SMGTgetParentStudentadd(parentid, "%").ToList();
                            List <ParentModel> List     = STQlist.Select(x => new ParentModel
                            {
                                StudentId   = x.StudentId,
                                ParentName  = x.ParentName,
                                ParentId    = x.ParentId.ToString(),
                                StudentName = x.studentName
                            }).ToList();

                            Model.UserId = "Parent1";



                            scope.Dispose();

                            return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json(result, JsonRequestBehavior.AllowGet));
                    }
                }
                catch
                {
                    String           result    = "Exception";
                    List <tblParent> prntRlist = Connection.tblParents.Where(X => X.IsActive == "Y").ToList();
                    ViewBag.ParentlList = new SelectList(prntRlist, "ParentId", "ParentName");

                    List <tblRelashionship> SRlist = Connection.tblRelashionships.Where(X => X.IsActive == "Y").ToList();
                    ViewBag.RelationshipList = new SelectList(SRlist, "RelashionshipId", "RelashionshipName");
                    List <tblSchool> Schoollist = Connection.tblSchools.Where(X => X.IsActive == "Y").ToList();
                    ViewBag.SchoolDrpDown = new SelectList(Schoollist, "SchoolId", "SchoolName");
                    List <tblGrade> gradelist = Connection.tblGrades.Where(X => X.IsActive == "Y").ToList();
                    ViewBag.SchoolGradeList = new SelectList(gradelist, "GradeId", "GradeName");
                    List <tblClass> Classlist = Connection.tblClasses.Where(X => X.IsActive == "Y").ToList();
                    ViewBag.classDrpDown = new SelectList(Classlist, "ClassId", "ClassName");
                    List <tblStudent> Studentlist = Connection.tblStudents.Where(X => X.IsActive == "Y" && X.SchoolId == USession.School_Id).ToList();
                    ViewBag.StudentIdList = new SelectList(Studentlist, "StudentId", "StudentName");
                    String             parentid = "2";
                    var                STQlist  = Connection.SMGTgetParentStudentadd(parentid, "%").ToList();
                    List <ParentModel> List     = STQlist.Select(x => new ParentModel
                    {
                        StudentId   = x.StudentId,
                        ParentName  = x.ParentName,
                        ParentId    = x.ParentId.ToString(),
                        StudentName = x.studentName
                    }).ToList();

                    Model.UserId = "Parent1";


                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
        }
Пример #20
0
        /*
         * Login Button Click
         */
        protected void LoginFunc(object sender, EventArgs e)
        {
            string filePath = HttpRuntime.AppDomainAppPath + @"\Protected\App_Data\Staff.xml";

            string user     = UserName.Text;
            string password = Password.Text;

            string fLocation = Path.Combine(Request.PhysicalApplicationPath, @"\Protected\App_Data\Staff.xml");

            bool redirect = false;  // used for testing purposes only

            /* ENCRYPTION/DECRYPTION */
            string pwEncrypt = Encrypt_Decrypt.Encrypt(Password.Text);



            /* Create XmlDocument and load the Members.xml data into it */
            XmlDocument myDoc = new XmlDocument();

            myDoc.Load(filePath);

            XmlElement rootElement = myDoc.DocumentElement;     // open file

            foreach (XmlNode node in rootElement.ChildNodes)
            {
                // if username and pw match, create login cookie and redirect to MemberPage
                // else, diplay invalid credentials
                if (node["Username"].InnerText == user && node["Password"].InnerText == pwEncrypt)
                {
                    // compare encrypted passwords to see if they are the same,
                    // cannot get my decryption to work (Encrypt_Decrypt.Decrypt(node["Password"].InnerText))
                    if (node["Password"].InnerText == pwEncrypt)
                    {
                        Output.Visible = false;

                        if (Persistent.Checked)
                        {
                            Session["MemberName"] = user;
                            Session["MemberID"]   = 2;

                            HttpCookie myCookies = new HttpCookie("SmyCookieId");
                            myCookies["SUsername"] = user;
                            myCookies["SPassword"] = password;
                            Response.Cookies.Add(myCookies);
                        }


                        Response.Redirect("Protected/StaffPage.aspx");
                        return;
                    }
                    // Username exists but pw doesnt match
                    else
                    {
                        Output.Text    = "Invalid Password";
                        Output.Visible = true;
                        return;
                    }
                }
            }

            Output.Text    = "Username does not exist";
            Output.Visible = true;
            return;
        }
Пример #21
0
        public string SetCustomerParentRequest(M_CustomerParentRequest pr)
        {
            try
            {
                string PRequesNo   = string.Empty;
                string EncriptPass = Encrypt_Decrypt.Encrypt(pr.Admin_Password, Password);
                using (DBLinqDataContext dbContext = new DBLinqDataContext())
                {
                    dbContext.Connection.ConnectionString = Connection_;
                    dbContext.Connection.Open();

                    try
                    {
                        dbContext.Transaction = dbContext.Connection.BeginTransaction();

                        B_RecordSequence CParentId = new B_RecordSequence();
                        Int64            RequestNo = CParentId.getNextSequence("ParentRequestNo", dbContext);
                        PRequesNo = "PCRN" + RequestNo.ToString();
                        dbContext.DCISsetParentCustomerRequest(PRequesNo,
                                                               pr.Customer_Name,
                                                               pr.Telephone,
                                                               pr.Email,
                                                               pr.Fax,
                                                               "P",
                                                               pr.Address1,
                                                               pr.Address2,
                                                               pr.Address3,
                                                               "",
                                                               pr.IsVat,
                                                               pr.Admin_UserId,
                                                               EncriptPass,
                                                               pr.ContactPersonName,
                                                               pr.ContactPersonDesignation,
                                                               pr.ContactPersonDirectPhone,
                                                               pr.ContactPersonMobile,
                                                               pr.ContactPersonEmail,
                                                               pr.IsNCEMember,
                                                               pr.Admin_Name);

                        dbContext.SubmitChanges();
                        dbContext.Transaction.Commit();
                        return(PRequesNo);
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.LogError("B_Customer", ex);
                        dbContext.Transaction.Rollback();
                        return(null);
                    }
                    finally
                    {
                        dbContext.Connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                return(null);
            }
        }
        /*
         *  Register New Staff Member Button *Hidden within register panel*
         *
         */
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            registerPanel.Visible = true;

            bool txtEmpty = false;

            string username = "";
            string password = "";
            string pwEnrypt = "";

            string first = "";
            string last  = "";

            /* Set our Missing Data Asterisks visibility to false */
            userMissingLabel.Visible  = false;
            pwMissingLabel.Visible    = false;
            firstMissingLabel.Visible = false;
            lastMissingLabel.Visible  = false;


            // set forecolor of responseLabel to Red for errors, green for success
            responseLabel.ForeColor = Color.Red;

            XmlDocument myDoc = new XmlDocument();      // used to help check our Staff.xml doc

            // file path to our Staff.xml document
            string filePath = HttpRuntime.AppDomainAppPath + @"\Protected\App_Data\Staff.xml";

            // IMPLEMENTATION BELOW

            // if the text boxes that hold our username, password, and First & Last Name are not empty, move on.
            if (txtStaffPassword.Text.ToString() != String.Empty && txtStaffUser.Text.ToString() != String.Empty && txtFirstName.Text.ToString() != String.Empty && txtLastName.Text.ToString() != String.Empty)
            {
                // assign the username and password and NAME to our variables for XML search/check
                username = txtStaffUser.Text;
                password = txtStaffPassword.Text;
                first    = txtFirstName.Text;
                last     = txtLastName.Text;

                //IMPLEMENT ENCRYPTION/DECRYPTION

                //STORE ENCRYPTED PW IN pwEncrypt using Encrypt_Decrypt_Lib
                pwEnrypt = Encrypt_Decrypt.Encrypt(password);

                myDoc.Load(filePath);                           // load Staff.xml into myDoc

                XmlElement rootElement = myDoc.DocumentElement; //open file

                foreach (XmlNode node in rootElement.ChildNodes)
                {
                    // in our xml doc, any child node entitled Username that has its innertext
                    // equal to the username trying to be registered, error message will be displayed
                    if (node["Username"].InnerText == username)
                    {
                        responseLabel.Text    = String.Format("Staff with username {0} already exists.", username);
                        responseLabel.Visible = true;
                        return;
                    }
                }

                //userErrorLabel.Visible = false;
            }

            else
            {
                txtEmpty = true;
            }

            //if textboxes are empty, display error and return avoid nullreference error acception
            if (txtEmpty == true)
            {
                responseLabel.Text = "Missing Information";

                // Sequence of if statements to display red asterisks next
                // to each text box that is "Missing Information"
                if (txtStaffUser.Text.ToString() == String.Empty)
                {
                    userMissingLabel.Visible = true;
                }
                if (txtStaffPassword.Text.ToString() == String.Empty)
                {
                    pwMissingLabel.Visible = true;
                }
                if (txtFirstName.Text.ToString() == String.Empty)
                {
                    firstMissingLabel.Visible = true;
                }
                if (txtLastName.Text.ToString() == String.Empty)
                {
                    lastMissingLabel.Visible = true;
                }

                return;
            }

            /* IF THE USERNAME DOESN'T ALREADY EXIST AND NONE OF THE TEXTBOXES WERE EMPTY, CONTINUE */

            /* ADD A NEW USER TO OUR XML DOCUMENT
             * (insert here because if Username is found we return, so this code will be
             * unreachable at that time, so do not have to worry about adding duplicates)
             */
            XmlElement myNewMember = myDoc.CreateElement("Member", myDoc.NamespaceURI);

            myDoc.DocumentElement.AppendChild(myNewMember);


            // add Last Name
            XmlElement userLast = myDoc.CreateElement("Last", myDoc.NamespaceURI);

            myNewMember.AppendChild(userLast);
            userLast.InnerText = last;
            // add First Name
            XmlElement userFirst = myDoc.CreateElement("First", myDoc.NamespaceURI);

            myNewMember.AppendChild(userFirst);
            userFirst.InnerText = first;
            // add Username
            XmlElement newUser = myDoc.CreateElement("Username", myDoc.NamespaceURI);

            myNewMember.AppendChild(newUser);
            newUser.InnerText = username;
            // add password
            XmlElement userPwd = myDoc.CreateElement("Password", myDoc.NamespaceURI);

            myNewMember.AppendChild(userPwd);
            userPwd.InnerText = pwEnrypt;


            myDoc.Save(filePath);
            responseLabel.ForeColor = Color.Green;  // set color to green to show SUCCESS, otherwise red
            responseLabel.Text      = "SAVE SUCCESS";
        }
    protected void dlOrderList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string command = e.CommandName;
        int    Index   = e.Item.ItemIndex;

        switch (command)
        {
        case "Exp_Col":
        {
            ImageButton img = e.Item.FindControl("ibtnNOExpColap") as ImageButton;
            if (img.ImageUrl == "~/images/expand.JPG")
            {
                ((ImageButton)e.Item.FindControl("ibtnNOExpColap")).ImageUrl = "~/images/collapse.JPG";
                ((GridView)e.Item.FindControl("gvNewOrder")).Visible         = true;
                ((HtmlTableRow)dlOrderList.Items[Index].FindControl("trSubTable")).Style.Add(HtmlTextWriterStyle.Display, "''");
            }
            else if (img.ImageUrl == "~/images/collapse.JPG")
            {
                ((ImageButton)e.Item.FindControl("ibtnNOExpColap")).ImageUrl = "~/images/expand.JPG";
                ((GridView)e.Item.FindControl("gvNewOrder")).Visible         = false;
                ((HtmlTableRow)dlOrderList.Items[Index].FindControl("trSubTable")).Style.Add(HtmlTextWriterStyle.Display, "none");
            }
        }
        break;

        case "BranchOrder":
        {
            Session["sOrderID"] = Encrypt_Decrypt.Encrypt(e.CommandArgument.ToString(), true);
            Response.Redirect("~/mudar/UpdateAdminOrder.aspx");
        }
        break;

        case "Display":
        {
            string str = ((HiddenField)e.Item.FindControl("hfOrderPdf")).Value.ToString();
            //ifOrderPdf.Attributes.Add("src", str);
            //ifOrderPdf.Attributes.Add("src", "../Attachments/OrderPDF/1015/1015_PO201296.pdf");
        }
        break;

        case "Download":
        {
            try
            {
                string       str      = ((HiddenField)e.Item.FindControl("hfOrderPdf")).Value.ToString();
                WebClient    req      = new WebClient();
                HttpResponse response = HttpContext.Current.Response;
                response.Clear();
                response.ClearContent();
                response.ClearHeaders();
                response.Buffer = true;
                if (!File.Exists(Server.MapPath(str)))
                {
                    throw new FileNotFoundException();
                }
                response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(str) + "\"");
                byte[] data = req.DownloadData(Server.MapPath(str));
                response.BinaryWrite(data);
                response.End();
            }
            catch (FileNotFoundException ex)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "downloaderror", "fnShowMessage('PO does not exists')", true);
            }
            catch (Exception ex)
            {
                Session["ErrorMsg"] = ex.Message;
                //Response.Redirect("~/NoAccess.aspx", false);
                ScriptManager.RegisterStartupScript(this, typeof(Page), "downloaderror", "fnShowMessage('Error while downloading PO')", true);
            }
        }
        break;

        case "cancel":
        {
            #region old code
            //    DataListItem item = dlOrderList.Items[Index];
            //    DataTable dt = orderobj.GetCollectionTransactions(((LinkButton)dlOrderList.Items[Index].FindControl("lbtnOrderID")).Text);
            //    if (dt.Rows.Count > 0)
            //    {
            //        foreach (DataRow items in dt.Rows)
            //        {
            //            string[] BlendingBID = items["Blending_BatchID"].ToString().Split('@');
            //            string[] PlantationID = items["PlantationID"].ToString().Split('@');
            //            string[] CollectionQty = items["CollectionQty"].ToString().Split('@');
            //            string blendingBatchId = items["Blending_BatchID"].ToString();
            //            if (!string.IsNullOrEmpty(blendingBatchId) && blendingBatchId.Contains("@"))
            //            {
            //                if (BlendingBID[0].ToString().Trim() == string.Empty)
            //                {
            //                    string[] PlantationID1 = PlantationID[0].ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            //                    string[] CollectionQty1 = CollectionQty[0].ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            //                    for (int i = 0; i < PlantationID1.Length; i++)
            //                    {
            //                        result1 = orderobj.UpdateSoldQtyforCancelOrder(Convert.ToDecimal(CollectionQty1[i].ToString()), Convert.ToInt32(PlantationID1[i].ToString()), Convert.ToInt32(((LinkButton)dlOrderList.Items[Index].FindControl("lbtnOrderID")).Text));
            //                    }
            //                }
            //                if (BlendingBID[1].ToString() != string.Empty)
            //                {
            //                    string[] BlendingBID2 = BlendingBID[1].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            //                    string[] CollectionQty2 = CollectionQty[1].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            //                    for (int j = 0; j < BlendingBID2.Length; j++)
            //                    {
            //                        result2 = orderobj.PreOrderUpdateSoldQtyforCancelOrder(Convert.ToDecimal(CollectionQty2[j].ToString()), BlendingBID2[j].ToString());
            //                    }
            //                }
            //            }
            //            else
            //            {
            //                if (BlendingBID[0].ToString() != string.Empty)
            //                {
            //                    string[] BlendingBID2 = BlendingBID[0].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            //                    string[] CollectionQty2 = CollectionQty[1].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            //                    for (int j = 0; j < BlendingBID2.Length; j++)
            //                    {
            //                        result2 = orderobj.PreOrderUpdateSoldQtyforCancelOrder(Convert.ToDecimal(CollectionQty2[j].ToString()), BlendingBID2[j].ToString());
            //                    }
            //                }
            //            }
            //        }
            //        if (result1 == true || result2 == true)
            //        {
            //            result = orderobj.CancelOrders("CANCEL", ((LinkButton)dlOrderList.Items[Index].FindControl("lbtnOrderID")).Text);
            //            if (result)
            //            {
            //                BinddlOrderList();
            //                ((Button)dlOrderList.Items[Index].FindControl("btnUpdate")).Visible = false;
            //                ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('!!! Order Canceled !!!');</script>");
            //            }
            //        }
            //    }
            //    else
            //    {
            //        result = orderobj.CancelOrders("CANCEL", ((LinkButton)dlOrderList.Items[Index].FindControl("lbtnOrderID")).Text);
            //        if (result)
            //        {
            //            BinddlOrderList();
            //            ((Button)dlOrderList.Items[Index].FindControl("btnUpdate")).Visible = false;
            //            ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('!!! Order Canceled !!!');</script>");
            //        }
            //    }
            #endregion
        }
        break;
        }
    }
Пример #24
0
        public JsonResult CreateTeacher(TeacherModel Model)
        {
            string result = "Error";

            using (SchoolMGTEntitiesConnectionString Connection = new SchoolMGTEntitiesConnectionString())
            {
                using (var scope = new TransactionScope())
                {
                    try
                    {
                        tblTeacher Newt = new tblTeacher();

                        Newt.CreatedBy         = _session.User_Id;
                        Newt.CreatedDate       = DateTime.Now;
                        Newt.TeacherCategoryId = 0;
                        Newt.TeacherCategoryId = Model.TeacherCategoryId;
                        Newt.DateOfBirth       = Model.DateOfBirth;
                        Newt.Address1          = Model.Address1;
                        Newt.Address2          = Model.Address2;
                        Newt.Address3          = Model.Address3;
                        Newt.Telephone         = Model.Telephone;
                        Newt.Gender            = Model.Gender;
                        Newt.Description       = Model.Description;
                        Newt.EmployeeNo        = Model.EmployeeNo;
                        Newt.DrivingLicense    = Model.DrivingLicense;
                        Newt.NIC      = Model.NIC;
                        Newt.Name     = Model.Name;
                        Newt.Passport = Model.Passport;
                        Newt.UserId   = Model.UserId;
                        Newt.IsActive = "Y";

                        Connection.tblTeachers.Add(Newt);
                        Connection.SaveChanges();

                        var TID = Connection.tblTeachers.Where(b => b.UserId == Model.UserId).FirstOrDefault();

                        tblTeacherSchool ts = new tblTeacherSchool();
                        ts.SchoolId          = Model.SchoolID;
                        ts.TeacherCategoryId = TID.TeacherCategoryId;
                        ts.TeacherId         = TID.TeacherId;
                        ts.CreatedBy         = _session.User_Id;
                        ts.CreatedDate       = DateTime.Now;
                        ts.IsActive          = "Y";

                        tblUser user = new tblUser();

                        string pass = Encrypt_Decrypt.Encrypt(Model.Password, Password);

                        user.PersonName     = Model.Name;
                        user.CreatedBy      = _session.User_Id;
                        user.CreatedDate    = DateTime.Now;
                        user.IsActive       = "Y";
                        user.JobDescription = "School Teacher";
                        user.LoginEmail     = Model.LoginEmail;
                        user.Mobile         = Model.Telephone;
                        user.Password       = pass;
                        user.UserCategory   = TeacherCatID;
                        user.UserId         = Model.UserId;
                        user.SchoolId       = Model.SchoolID;

                        Connection.tblUsers.Add(user);
                        Connection.tblTeacherSchools.Add(ts);

                        Connection.SaveChanges();

                        result = "Success";
                        scope.Complete();
                    }
                    catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                    {
                        //Exception raise = dbEx;
                        //foreach (var validationErrors in dbEx.EntityValidationErrors)
                        //{
                        //    foreach (var validationError in validationErrors.ValidationErrors)
                        //    {
                        //        string message = string.Format("{0}:{1}",
                        //            validationErrors.Entry.Entity.ToString(),
                        //            validationError.ErrorMessage);
                        //        // raise a new exception nesting
                        //        // the current instance as InnerException
                        //        raise = new InvalidOperationException(message, raise);
                        //    }
                        //}
                        Errorlog.ErrorManager.LogError("public JsonResult CreateTeacher(TeacherModel Model) @TeacherController", dbEx);
                        // throw raise;
                    }
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #25
0
        /*
         *  Register new account button
         *
         *  Need to search xml doc to see if username exists already,
         *  if not then add the new account information to our XML doc (Members.xml)
         *
         *  Also, on click it checks to see if our user string matches the captcha
         *
         */
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            bool captchaCheck   = true;
            bool userpwtxtCheck = true;

            string user     = "";
            string password = "";
            string pwEnrypt = "";

            XmlDocument myDoc = new XmlDocument();      // used to help check our Members.xml doc


            if (Session["generatedString"].Equals(txtCaptcha.Text))
            {
                captchaErrorLabel.Text = "";
            }
            else
            {
                captchaErrorLabel.Text = "Incorrect. Please try again.";
                return;
            }


            // file path to our Members.xml document
            string filePath = HttpRuntime.AppDomainAppPath + @"\Account\App_Data\Members.xml";

            // if the text boxes that hold our username and password are not empty, move on.
            if (txtPassword.Text.ToString() != String.Empty && txtUsername.Text.ToString() != String.Empty)
            {
                //if the captcha is not empty, then continue to move forward, else set captchaCheck = false;
                if (txtCaptcha.Text.ToString() != String.Empty)
                {
                    // assign the username and password to our variables for XML search/check
                    user     = txtUsername.Text;
                    password = txtPassword.Text;

                    //IMPLEMENT ENCRYPTION/DECRYPTION

                    //STORE ENCRYPTED PW IN pwEncrypt using Encrypt_Decrypt_Lib
                    pwEnrypt = Encrypt_Decrypt.Encrypt(password);


                    //
                    myDoc.Load(filePath);                           // load Members.xml into myDoc

                    XmlElement rootElement = myDoc.DocumentElement; //open file

                    foreach (XmlNode node in rootElement.ChildNodes)
                    {
                        // in our xml doc, any child node entitled Username that has its innertext
                        // equal to the username trying to be registered, error message will be displayed
                        if (node["Username"].InnerText == user)
                        {
                            userErrorLabel.Text    = String.Format("Account with username {0} already exists.", user);
                            userErrorLabel.Visible = true;
                            return;
                        }
                    }

                    //userErrorLabel.Visible = false;
                }
                else
                {
                    captchaCheck = false;
                }
            }

            else
            {
                userpwtxtCheck = false;
            }

            //if username and/or pw is empty and return to avoid nullreference error acception
            if (userpwtxtCheck == false)
            {
                userErrorLabel.Text = "Please input a username and/or password.";
                return;
            }



            /* ADD A NEW USER TO OUR XML DOCUMENT
             * (insert here because if Username is found we return, so this code will be
             * unreachable at that time, so do not have to worry about adding duplicates)
             */
            XmlElement myNewMember = myDoc.CreateElement("Member", myDoc.NamespaceURI);

            myDoc.DocumentElement.AppendChild(myNewMember);

            // add Username
            XmlElement newUser = myDoc.CreateElement("Username", myDoc.NamespaceURI);

            myNewMember.AppendChild(newUser);
            newUser.InnerText = user;

            // add password
            XmlElement userPwd = myDoc.CreateElement("Password", myDoc.NamespaceURI);

            myNewMember.AppendChild(userPwd);
            userPwd.InnerText = pwEnrypt;


            myDoc.Save(filePath);

            userErrorLabel.Text   = "SAVE SUCCESS";
            Session["MemberName"] = user;
            Session["MemberID"]   = 1;
            Response.Redirect("MemberPage.aspx");
        }
Пример #26
0
        private void LoadReportData()
        {
            try
            {
                bool ViewAll = Common.CheckUserInRole(UserID, 4); // view all daily reports
                ReportDT = InitializeReportGridViewDataTable();
                V_DailyReport report = new V_DailyReport();
                if (!ViewAll)
                {
                    report.Where.UserID.Value = UserID;
                }
                else
                {
                    report.Where.BranchID.Value = Common.GetUserBranchID(UserID);
                    //report.Where.Status.Value = "Not Filled";
                    //report.Where.Status.Operator = MyGeneration.dOOdads.WhereParameter.Operand.NotEqual;
                }
                report.Query.AddOrderBy(V_DailyReport.ColumnNames.ReprotDate, MyGeneration.dOOdads.WhereParameter.Dir.DESC);
                if (report.Query.Load())
                {
                    do
                    {
                        DataRow dr = ReportDT.NewRow();
                        dr["ID"]           = report.ID;
                        dr["ReportDate"]   = report.ReprotDate.ToString("dd/MM/yyyy");
                        dr["UserName"]     = report.FirstName + " " + report.LastName;
                        dr["ModifiedDate"] = report.ModifiedDate.ToString("dd/MM/yyyy");
                        dr["Status"]       = report.Status;
                        dr["ViewURL"]      = "ViewReport.aspx?RID=" + Server.UrlEncode(Encrypt_Decrypt.Encrypt(report.s_ID, key));
                        dr["Review"]       = report.s_Review;
                        dr["Reviewed"]     = report.Reviewed;
                        if (UserID == report.UserID && report.Status == "Not Filled")
                        {
                            dr["CanEdit"] = true;
                            dr["URL"]     = "EditReport.aspx?RID=" + Server.UrlEncode(Encrypt_Decrypt.Encrypt(report.s_ID, key));
                        }
                        else
                        {
                            dr["CanEdit"] = false;
                            dr["URL"]     = "#";
                        }
                        List <string> groups = new List <string>();
                        groups.Add("SalesManagers");
                        if (Common.CheckUserInGroups(UserID, groups) && report.Status == "Pending Verification")
                        {
                            dr["CanVer"] = true;
                            dr["URL"]    = "VarifyReport.aspx?RID=" + Server.UrlEncode(Encrypt_Decrypt.Encrypt(report.s_ID, key));
                        }
                        else
                        {
                            dr["CanVer"] = false;
                            //   dr["URL"] = "#";
                        }

                        if (UserID == report.UserID || (report.Status != "Not Filled"))
                        {
                            ReportDT.Rows.Add(dr);
                        }
                    }while (report.MoveNext());
                }
                GV_Reports.DataSource = ReportDT;
                GV_Reports.DataBind();
                ViewState["ReportDT"] = ReportDT;
            }
            catch (Exception ex)
            {
                Page.Response.Write(ex.Message);
            }
        }