protected void activate_Click(object sender, EventArgs e)
        {
            //string ms = null;
            try
            {
                activateReview review = new activateReview();
                string         qatr   = qtr.SelectedValue;
                string         years  = yr.SelectedValue;
                string         stat   = act.Text;

                db.SaveChanges();
            }
            catch {
                var com     = db.activateReviews.Where(co => co.Id == 1).First();
                int id      = com.Id;
                var cstatus = db.activateReviews.FirstOrDefault(cs => cs.Id == 1);
                if (act.Checked)
                {
                    cstatus.status = "active";
                    msg.Text       = "appraisal activated";
                }
                else
                {
                    cstatus.status = "inactive";
                    msg.Text       = "appraisal deactivated";
                }
                db.SaveChanges();
            }
        }
        protected void update_Click(object sender, EventArgs e)
        {
            try
            {
                string uname      = Session["fullName"].ToString();
                string assetid    = aid.Text;
                var    result     = db.assetRecords.Where(at => at.assetId == assetid).First();
                string name       = result.name;
                string dept       = result.receivingDept;
                string rem        = result.remark;
                string sumins     = result.sumInsured.ToString();
                string coverdate  = result.coverDate.ToShortDateString();
                string expirydate = result.expirydate.ToShortDateString();
                string cstatus    = result.status;
                var    message    = " An update occured on asset No: " + assetid + " by   ";
                message += uname + " Initial Record: Asset Name: " + name + ", Department: " + dept + ", Sum Insured" + sumins + ", Cover Date:" + coverdate + ", Expiry Date" + expirydate + ", Remark:" + rem + ", Status: " + status;
                message += "New Record: Asset Name:" + aname.Text + ", Department:" + rdept.Text + ",Sum Insured: " + sum.Text + "Cover Date:" + cdate.Text + "" + ", Expiry date" + edate.Text + ", Remark:" + remark.Text + ",Status:" + status.Text;

                var ar = db.assetRecords.FirstOrDefault(ai => ai.assetId == assetid);
                ar.name          = aname.Text;
                ar.receivingDept = rdept.Text;
                ar.remark        = remark.Text;
                if (status.Checked)
                {
                    ar.status = "active";
                }
                else
                {
                    ar.status = "inactive";
                }


                ar.datePurchased = DateTime.Parse(dp.Text);
                ar.cost          = Convert.ToDecimal(cp.Text);
                ar.insurance     = ins.Text;
                ar.policyNumber  = pnumber.Text;
                ar.sumInsured    = Convert.ToDecimal(sum.Text);
                ar.coverDate     = DateTime.Parse(cdate.Text);
                ar.expirydate    = DateTime.Parse(edate.Text);


                db.SaveChanges();

                assetUpdateHistory auh = new assetUpdateHistory();
                auh.assetId    = assetid;
                auh.updateDate = DateTime.Now;
                auh.message    = message;
                db.assetUpdateHistories.Add(auh);
                db.SaveChanges();
                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""Asset Updated Successfully... click OK to continue!"")</SCRIPT>"));
                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""viewNiaAsset.aspx"") </SCRIPT>"));
                // msg.Text = "Record Updated Successfully";
            }
            catch (Exception)
            {
                msg.Text = "update failed";
            }
        }
Beispiel #3
0
        protected void create_Click(object sender, EventArgs e)
        {
            try{
                qualification qu = new qualification();

                qu.staffId = sid.Text;
                qu.name    = basicQ.Text;
                string      day      = qday.Text;
                string      month    = qmonth.Text;
                string      year     = qyear.Text;
                string      result   = day + "-" + month + "-" + year;
                CultureInfo provider = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = provider;
                DateTime dateo = DateTime.Parse(result);
                qu.dateObtained        = dateo;
                qu.typeOfQualification = degree.Text;
                qu.institution         = inst.Text;
                db.qualifications.Add(qu);
                db.SaveChanges();
                Response.Redirect("enterEmploymentRecord.aspx?staffId=" + sid.Text);
            }
            catch (Exception ex)
            {
                msg.Text = ex.Message;
            }
        }
Beispiel #4
0
 protected void activate_Click(object sender, EventArgs e)
 {
     try
     {
         var com     = db.activateReviews.Where(co => co.Id == 1).First();
         int id      = com.Id;
         var cstatus = db.activateReviews.FirstOrDefault(cs => cs.Id == 1);
         if (act.Checked)
         {
             cstatus.status   = "active";
             cstatus.reviewId = id + 1;
             string qatr  = qtr.SelectedValue;
             string years = yr.SelectedValue;
             string stat  = act.Text;
             //  msg.Text = "appraisal activated successfully";
             System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""appraisal activated successfully... click OK to continue!"")</SCRIPT>"));
             System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""superAdminDashboard.aspx"") </SCRIPT>"));
         }
         else
         {
             cstatus.status   = "inactive";
             cstatus.reviewId = id - 1;
             System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""appraisal deactivated successfully... click OK to continue!"")</SCRIPT>"));
             System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""superAdminDashboard.aspx"") </SCRIPT>"));
             // msg.Text = "appraisal deactivated successfully";
         }
         db.SaveChanges();
     }
     catch (Exception) {
         msg.Text = "action failed... try again!";
     }
 }
        protected void create_Click(object sender, EventArgs e)
        {
            try
            {
                niapsEntities1     db  = new niapsEntities1();
                currentStaffRecord cst = new currentStaffRecord();
                cst.staffId       = sid.Text;
                cst.designation   = designation.Text;
                cst.department    = dept.Text;
                cst.qualification = qualification.Text;
                string      djDay      = doeday.Text;
                string      djMonth    = doemonth.Text;
                string      djYear     = doeyear.Text;
                string      dateJoined = djDay + "-" + djMonth + "-" + djYear;
                CultureInfo provider   = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = provider;
                cst.date_Joined = DateTime.Parse(dateJoined);
                cst.degree      = degree.Text;

                cst.probationPeriod    = Int32.Parse(pperiod.Text);
                cst.dateOfConfirmation = DateTime.Parse(confirm.Text);
                db.currentStaffRecords.Add(cst);
                db.SaveChanges();
                // db.Dispose();
                string message = "Registration Completed Successfully";
                Response.Redirect("message.aspx?msg=" + message);
            }
            catch (Exception ex)
            {
                msg.Text  = "Error creating Current Employment Records";
                msg.Text += ex;
            }
        }
        protected void modify_Click(object sender, EventArgs e)
        {
            try
            {
                string firstPsw   = psw.Text;
                string confirmPsw = cpsw.Text;

                if (firstPsw == confirmPsw)
                {
                    niapsEntities1 ctx    = new niapsEntities1();
                    int            id     = Int32.Parse(Request.QueryString["uid"].ToString());
                    var            result = ctx.adminUsers.FirstOrDefault(us => us.userId == id);
                    result.password = CreateHash(firstPsw);
                    ctx.SaveChanges();
                    msg.Text  = "Password modified successfully";
                    cpsw.Text = "";
                    psw.Text  = "";
                }
                else
                {
                    msg.Text = "Password does not match! try again";
                }
            }
            catch
            {
                msg.Text = "Password does not match! try again";
            }
        }
        protected void update_Click(object sender, EventArgs e)
        {
            try
            {
                int qid = Int32.Parse(Request.QueryString["Id"].ToString());
                var ufq = db.employmentRecords.FirstOrDefault(uf => uf.Id == qid);
                ufq.company   = coy.Text;
                ufq.startDate = DateTime.Parse(sdate.Text);
                ufq.endDate   = DateTime.Parse(edate.Text);
                ufq.postHeld  = ph.Text;
                ufq.duties    = duties.Text;
                db.SaveChanges();

                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""updated Successfully... click OK to continue!"") </SCRIPT>"));
                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""updateEmpRec.aspx"") </SCRIPT>"));

                sdate.Text  = "";
                coy.Text    = "";
                edate.Text  = "";
                ph.Text     = "";
                duties.Text = "";
            }
            catch (Exception)
            {
                msg.Text = "update failed";
            }
            //Response.Redirect("updateS.aspx");
        }
        protected void update_Click(object sender, EventArgs e)
        {
            try
            {
                int qid = Int32.Parse(Request.QueryString["qid"].ToString());
                var ufq = db.qualifications.FirstOrDefault(uf => uf.qualificationId == qid);
                ufq.institution         = inst.Text;
                ufq.dateObtained        = DateTime.Parse(dobt.Text);
                ufq.typeOfQualification = degree.Text;
                ufq.name = bq.Text;
                db.SaveChanges();

                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""updated Successfully... click OK to continue!"") </SCRIPT>"));
                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""updateS.aspx"") </SCRIPT>"));

                sname.Text  = "";
                inst.Text   = "";
                dobt.Text   = "";
                degree.Text = "";
                bq.Text     = "";
            }
            catch (Exception)
            {
                msg.Text = "update failed";
            }
            //Response.Redirect("updateS.aspx");
        }
        protected void create_Click(object sender, EventArgs e)
        {
            try
            {
                staffNextOfKin st   = new staffNextOfKin();
                string         sId  = Request.QueryString["staffId"].ToString();
                string         name = Request.QueryString["name"].ToString();

                st.staffId       = sId;
                st.fName         = fname.Text;
                st.lname         = ln.Text;
                st.gender        = sex.Text;
                st.address       = addr.Text;
                st.contactMobile = phone.Text;
                st.relationship  = rel.Text;
                db.staffNextOfKins.Add(st);
                db.SaveChanges();
                // msg.Text = "Registration Completed Successfully";

                // Response.Redirect("enterQualification.aspx?staffId=" + sId);

                //Response.Redirect("../PrivateWeb/message.aspx?msg=" + msg);
            }

            catch (Exception exc) {
                msg.Text += exc.Message;
            }
        }
        protected void btnReview_Click(object sender, EventArgs e)
        {
            niapsEntities1 db = new niapsEntities1();

            // string sId = Session["staffId"].ToString();
            try
            {
                string sId    = stId.Text;
                var    update = db.answerToQuestions.FirstOrDefault(up => up.staffId == sId);
                update.answer1  = TextBox1.Text;
                update.answer2  = TextBox2.Text;
                update.answer3  = TextBox3.Text;
                update.answer4  = TextBox4.Text;
                update.answer5  = TextBox5.Text;
                update.answer6  = TextBox6.Text;
                update.answer7  = TextBox7.Text;
                update.answer8  = TextBox8.Text;
                update.answer9  = TextBox9.Text;
                update.answer10 = TextBox10.Text;
                update.answer11 = TextBox11.Text;
                update.answer12 = TextBox12.Text;
                update.answer13 = TextBox13.Text;
                update.answer14 = TextBox14.Text;
                update.answer15 = TextBox15.Text;
                update.answer16 = TextBox16.Text;
                db.SaveChanges();
                msg.Text = "Update Successful";
            }
            catch (Exception)
            {
                msg.Text = "Update failed";
            }
        }
 protected void deleteUser_Click(object sender, EventArgs e)
 {
     {
         if (dt.Checked)
         {
             int uId  = Int32.Parse(Request.QueryString["uid"].ToString());
             var stud = new adminUser {
                 userId = uId
             };
             db.adminUsers.Attach(stud);
             db.adminUsers.Remove(stud);
             db.SaveChanges();
             uname.Text = "";
             rol.Text   = "";
             dt.Checked = false;
             msg.Text   = "user deleted successfully";
             // Response.Redirect("sviewUsers.aspx?msg="+msg);
         }
         else
         {
             msg.Text = "Please Check the delete box to confirm";
             // Response.Redirect("sviewUsers.aspx?msg=" + msg);
         }
     }
 }
        protected void btnPost_Click(object sender, EventArgs e)
        {
            niapsEntities1 db   = new niapsEntities1();
            question       qstn = new question();

            qstn.question1 = qst.Text;
            qstn.qstId     = Int32.Parse(qstno.Text);
            db.questions.Add(qstn);
            db.SaveChanges();
        }
        protected void deactivate_Click(object sender, EventArgs e)
        {
            niapsEntities1 db     = new niapsEntities1();
            string         stid   = Request.QueryString["staffId"];
            var            update = db.staffRecords.FirstOrDefault(cs => cs.staffId == stid);

            if (dt.Checked)
            {
                update.status = "inactive";
                db.SaveChanges();
                msg.Text = "staff deactivated";
            }
            else
            {
                update.status = "active";
                db.SaveChanges();
                msg.Text = "staff activated";
            }
        }
Beispiel #14
0
        protected void update_Click(object sender, EventArgs e)
        {
            int uId    = Int32.Parse(Request.QueryString["uid"].ToString());
            var update = db.adminUsers.FirstOrDefault(cs => cs.userId == uId);

            if (dt.Checked)
            {
                update.status = "inactive";
                db.SaveChanges();
                msg.Text = "user deactivated";
                // Response.Redirect("sviewUsers.aspx?msg=" + msgs);
            }
            else
            {
                update.status = "active";
                db.SaveChanges();
                msg.Text = "user activated";
                //  Response.Redirect("sviewUsers.aspx?msg=" + mesg);
            }
        }
        protected void btnUser_Click(object sender, EventArgs e)
        {
            niapsEntities1 db   = new niapsEntities1();
            adminUser      admu = new adminUser();

            if (usname.Text == string.Empty)
            {
                unameMsg.Text = "*";
                pswMsg.Text   = "";
                fnameMsg.Text = "";
            }
            else if (psword.Text == string.Empty)
            {
                pswMsg.Text   = "*";
                fnameMsg.Text = "";
                unameMsg.Text = "";
            }
            else if (fname.Text == string.Empty)
            {
                fnameMsg.Text = "*";
                unameMsg.Text = "";
                pswMsg.Text   = "";
            }
            else
            {
                try
                {
                    var test = db.adminUsers.Where(u => u.userName == usname.Text).First();
                    if (test.userName != string.Empty)
                    {
                        unameMsg.Text = "user name already taken";
                    }
                }
                catch (Exception)
                {
                    admu.userName  = usname.Text;
                    admu.full_name = fname.Text;
                    admu.password  = CreateHash(psword.Text);
                    admu.role      = roles.SelectedValue;
                    admu.status    = "active";
                    db.adminUsers.Add(admu);
                    db.SaveChanges();
                    unameMsg.Text = "";
                    usname.Text   = "";
                    psword.Text   = "";
                    pswMsg.Text   = "";
                    fname.Text    = "";
                    fnameMsg.Text = "";
                    roles.Text    = "-select-";
                    msg.Text      = "User Created Successfully";
                }
            }
        }
        protected void btnUser_Click(object sender, EventArgs e)
        {
            string rol      = Session["role"].ToString();
            string userName = Session["uname"].ToString();
            string password = oldPsw.Text;

            try
            {
                using (niapsEntities1 ctx = new niapsEntities1())
                {
                    try
                    {
                        var myp = ctx.adminUsers.Where(cp => cp.userName ==
                                                       userName && cp.role == rol).First();
                        if (ValidatePassword(password, myp.password) == true)
                        {
                            //try
                            //{
                            string firstPsw   = psw.Text;
                            string confirmPsw = cpsw.Text;

                            if (firstPsw == confirmPsw)
                            {
                                int id     = myp.userId;
                                var result = ctx.adminUsers.FirstOrDefault(us => us.userId == id);
                                result.password = CreateHash(firstPsw);
                                ctx.SaveChanges();
                                msg.Text    = "Password changed successfully";
                                cpsw.Text   = "";
                                psw.Text    = "";
                                oldPsw.Text = "";
                            }
                        }
                    }
                    catch
                    {
                        msg.Text = "Password Confirmation Failed! Your password is wrong";
                    }
                }

                //  oldPsw.Text = mycompany.email;
            }

            catch (Exception)
            {
                msg.Text = "The Passwords did not Match";
            }
        }
        protected void done_Click(object sender, EventArgs e)
        {
            int uId    = Int32.Parse(Request.QueryString["uid"].ToString());
            var update = db.adminUsers.FirstOrDefault(cs => cs.userId == uId);

            if (dt.Checked)
            {
                update.status = "inactive";
            }
            else
            {
                update.status = "active";
            }
            db.SaveChanges();
            msg.Text = "updated successfully";
        }
Beispiel #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int uId = Int32.Parse(Request.QueryString["uid"].ToString());
            // var d = db.adminUsers.FirstOrDefault(cs => cs.userId == uId);
            //db.d
            //var stud = (from s1 in db.adminUsers where s1.userId == uId select s1).FirstOrDefault();
            //db.rem
            var stud = new adminUser {
                userId = uId
            };

            db.adminUsers.Attach(stud);
            db.adminUsers.Remove(stud);
            db.SaveChanges();
            msg.Text = "user deleted successfully";
        }
Beispiel #19
0
 protected void activate_Click(object sender, EventArgs e)
 {
     try
     {
         var idc = db.indicators.FirstOrDefault(ic => ic.IndicatorId == "fi");
         idc.quarter = qtr.SelectedValue;
         idc.year    = yr.SelectedValue;
         db.SaveChanges();
         db.Dispose();
         System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""indicator added successfully... click OK to continue!"")</SCRIPT>"));
         System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""superAdminDashboard.aspx"") </SCRIPT>"));
     }
     catch (Exception) {
         msg.Text = "update failed... pls, try again";
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string name = Session["fullName"].ToString();
                string role = Session["role"].ToString();
            }
            catch (Exception)
            {
                Response.Redirect("../Default.aspx");
            }
            if (!IsPostBack)
            {
                niapsEntities1 db       = new niapsEntities1();
                int            sId      = Int32.Parse(getStaffId());
                var            staffRec = db.currentStaffRecords.Where(st => st.Id == sId).First();
                stid.Text = staffRec.staffId;

                dept.Text        = staffRec.department;
                degree.Text      = staffRec.degree;
                doj.Text         = (staffRec.date_Joined).ToString();
                disc.Text        = staffRec.qualification;
                doc.Text         = staffRec.dateOfConfirmation.ToString();
                designation.Text = staffRec.designation;
                var ste = db.staffRecords.Where(s => s.staffId == staffRec.staffId).First();
                lname.Text = ste.lName;
                fname.Text = ste.fName;
            }

            try
            {
                niapsEntities1 db   = new niapsEntities1();
                string         name = Session["fullName"].ToString();
                // Insert the update transaction into the staff update history table first
                staffUpdateHistory stu = new staffUpdateHistory();
                stu.staffId   = stid.Text;
                stu.updatDate = DateTime.Now;
                stu.updatedBy = name;
                string message = getOldRecord();
                // message += ": New Record: Staff Name:" + lname.Text + ", " + fname.Text + " " + mname.Text + ", Designation:" + des.Text + ",GSM: " + gsm.Text + "Email:" + email.Text + "" + ", Address" + address.Text + ", Marital Status:" + mstatus.Text + ",Status:" + status.Text;
                stu.description = message;
                db.staffUpdateHistories.Add(stu);
                db.SaveChanges();
            }
            catch (Exception)
            { }
        }
Beispiel #21
0
        protected void done_Click(object sender, EventArgs e)
        {
            try
            {
                int sId = Int32.Parse(Request.QueryString["qid"]);
                var ar  = db.questions.FirstOrDefault(ai => ai.id == sId);
                ar.qstId     = Int32.Parse(no.Text);
                ar.question1 = qst.Text;
                db.SaveChanges();

                msg.Text = "Question Updated Successfully";
            }
            catch (Exception ex)
            {
                msg.Text = ex.Message;
            }
        }
Beispiel #22
0
 protected void btnPost_Click(object sender, EventArgs e)
 {
     try
     {
         int nId    = Int32.Parse(Request.QueryString["newsId"].ToString());
         var update = db.news.FirstOrDefault(cs => cs.newsId == nId);
         update.newsBy   = author.Text;
         update.postebBy = postBy.Text;
         update.message  = news.Text;
         db.SaveChanges();
         msg.Text = "news updated successfully";
     }
     catch (Exception)
     {
         msg.Text = "news update failed";
     }
 }
        protected void update_Click(object sender, EventArgs e)
        {
            niapsEntities1 db  = new niapsEntities1();
            string         i   = Request.QueryString["eid"].ToString();
            int            sid = Int32.Parse(i);
            var            str = db.currentStaffRecords.FirstOrDefault(ai => ai.Id == sid);

            //  DateTime result;
            str.department = dept.Text;

            str.designation   = designation.Text;
            str.qualification = disc.Text;
            str.degree        = degree.Text;

            db.SaveChanges();
            msg.Text = "Record updated successfully";
            // Response.Redirect("viewCurrentStaffRec.aspx?msg=" + msgs);
        }
 protected void btnPLeave_Click(object sender, EventArgs e)
 {
     if (pleave.Text == string.Empty)
     {
         plError.Text = "*";
     }
     try
     {
         plError.Text = "";
         string sid = sname.SelectedValue;
         var    pl  = db.pendingLeaves.FirstOrDefault(p => p.staffId == sid);
         pl.staffPendingLeave = Convert.ToInt32(pleave.Text);
         db.SaveChanges();
         msg.Text = "Pending Leave Updated Successfully";
     }
     catch (Exception)
     {
         plError.Text = "";
         msg.Text     = "Update Failled";
     }
 }
Beispiel #25
0
 protected void btnPost_Click(object sender, EventArgs e)
 {
     if (author.Text == string.Empty)
     {
         aError.Text = "*";
     }
     else if (postBy.Text == string.Empty)
     {
         tError.Text = "*";
     }
     else if (news.Text == string.Empty)
     {
         nError.Text = "*";
     }
     else
     {
         try
         {
             news ne = new news();
             ne.newsBy   = author.Text;
             ne.postebBy = postBy.Text;
             ne.message  = news.Text;
             DateTime dt = DateTime.Now;
             ne.date = dt;
             db.news.Add(ne);
             db.SaveChanges();
             db.Dispose();
             System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""News Posted Successfully... click OK to continue!"")</SCRIPT>"));
             System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""postNews.aspx"") </SCRIPT>"));
             // msg.Text = "News posted successfully";
             author.Text = "";
             postBy.Text = "";
             news.Text   = "";
         }
         catch (Exception)
         {
             msg.Text = "News failed";
         }
     }
 }
Beispiel #26
0
        protected void answer_Click(object sender, EventArgs e)
        {
            try
            {
                string qid = Request.QueryString["qId"].ToString();
                int    qd  = Int32.Parse(qid);
                var    iq  = db.queries.FirstOrDefault(i => i.staffId == staffid.Text && i.Id == qd);
                iq.status      = "replied";
                iq.reply       = ans.Text;
                iq.index       = 1;
                iq.dateReplied = DateTime.Now;

                db.SaveChanges();
                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""Reply posted successfully... click OK to continue!"")</SCRIPT>"));
                System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""index.aspx"") </SCRIPT>"));
                // msg.Text = "Query updated successfully";
            }
            catch (Exception)
            {
                msg.Text = "Error, update failed";
            }
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string theFile  = txtFile.PostedFile.FileName;
            string filepath = MapPath("images/") + theFile;

            //Response.Write(filepath);
            try{
                txtFile.PostedFile.SaveAs(filepath);
            }catch (Exception) {
                throw new Exception("File was not saved!");
            }
            staffRecord st     = new staffRecord();
            string      sId    = Request.QueryString["staffId"].ToString();
            string      name   = Request.QueryString["name"].ToString();
            var         result = db.staffRecords.Where(est => est.staffId == sId).First();

            result.passport = "~/PrivateWeb/images/" + theFile.ToString();
            // st.passport = filepath;
            //db.staffRecords.Add(result);
            db.SaveChanges();
            Response.Redirect("../PrivateWeb/enterEmploymentRecord.aspx?staffId=" + sId + "&name=" + name + "next");
        }
Beispiel #28
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (actionT.Text == string.Empty)
     {
         aError.Text = "*";
     }
     try
     {
         string sId = Request.QueryString["staffId"].ToString();
         int    qId = Int32.Parse(Request.QueryString["queryId"]);
         var    iq  = db.queries.FirstOrDefault(i => i.staffId == sId && i.Id == qId);
         iq.actionTaken            = actionT.Text;
         iq.disciplinaryEffectDate = DateTime.Parse(discDate.Text);
         db.SaveChanges();
         System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(""query updated successfully... click OK to continue!"")</SCRIPT>"));
         System.Web.HttpContext.Current.Response.Write(string.Format(@"<SCRIPT LANGUAGE=""JavaScript"">alert(window.location = ""viewQuery.aspx"") </SCRIPT>"));
         // msg.Text = "Query updated successfully";
     }
     catch (Exception)
     {
         msg.Text = "Error, update failed";
     }
 }
Beispiel #29
0
        protected void update_Click(object sender, EventArgs e)
        {
            try
            {
                niapsEntities1     db    = new niapsEntities1();
                string             uname = Session["fullName"].ToString();
                staffUpdateHistory stu   = new staffUpdateHistory();
                stu.staffId   = stid.Text;
                stu.updatDate = DateTime.Now;
                stu.updatedBy = uname;
                string message = getOldRecord();
                stu.description = message;
                db.staffUpdateHistories.Add(stu);
                db.SaveChanges();
                niapsEntities1 db2 = new niapsEntities1();
                string         sid = stid.Text;
                var            str = db2.staffRecords.FirstOrDefault(ai => ai.staffId == sid);
                // str.staffId = sid;
                str.lName  = lname.Text;
                str.fName  = fname.Text;
                str.gender = gender.Text;
                string   date1   = dob.Text;
                DateTime dobirth = DateTime.Parse(date1);
                str.dateOfBirth = dobirth;
                str.middleName  = mname.Text;
                // str.designation = des.Text;
                str.age    = Int32.Parse(age.Text);
                str.mobile = gsm.Text;

                var    lg  = db.LGAs.Where(l => l.name == lga.Text).First();
                string loc = lg.LGACode.ToString();
                str.Lga = loc;

                var ste = db.states.Where(s => s.state1 == state.Text).First();

                str.state                = ste.stateCode;
                str.address              = address.Text;
                str.email                = email.Text;
                str.marritalStatus       = mstatus.Text;
                str.formOfIdentification = foid.Text;
                str.idNumber             = idNumber.Text;
                db2.SaveChanges();

                niapsEntities1 db3 = new niapsEntities1();
                string         sId = Request.QueryString["staffId"].ToString();
                var            kin = db3.staffNextOfKins.FirstOrDefault(ki => ki.staffId == sId);
                kin.lname         = kinLastName.Text;
                kin.fName         = kinFirstName.Text;
                kin.address       = kinAddress.Text;
                kin.gender        = kinGender.Text;
                kin.contactMobile = kinGsm.Text;
                kin.relationship  = relationship.Text;
                db3.SaveChanges();

                niapsEntities1 db4  = new niapsEntities1();
                var            empl = db4.currentStaffRecords.FirstOrDefault(emp => emp.staffId == sId);
                empl.degree             = degree.Text;
                empl.designation        = designation.Text;
                empl.qualification      = disc.Text;
                empl.dateOfConfirmation = DateTime.Parse(dc.Text);
                empl.date_Joined        = DateTime.Parse(djoined.Text);
                empl.probationPeriod    = Int32.Parse(pbp.Text);
                empl.department         = dept.Text;
                db4.SaveChanges();

                stid.Text   = "";
                lname.Text  = "";
                fname.Text  = "";
                gender.Text = "";
                dob.Text    = "";
                mname.Text  = "";
                age.Text    = "";
                gsm.Text    = "";

                lga.Text = "";

                state.Text    = "";
                address.Text  = "";
                email.Text    = "";
                mstatus.Text  = "";
                foid.Text     = "";
                idNumber.Text = "";

                kinLastName.Text  = "";
                kinFirstName.Text = "";
                kinAddress.Text   = "";
                kinGender.Text    = "";
                kinGsm.Text       = "";
                relationship.Text = "";
                degree.Text       = "";
                designation.Text  = "";
                disc.Text         = "";
                dc.Text           = "";
                djoined.Text      = "";
                pbp.Text          = "";

                msg.Text = "staff updated successfully";
            }
            catch (Exception)
            {
                msg.Text = "error occured! could not update";
            }
        }
        protected void btnUser_Click1(object sender, EventArgs e)
        {
            if (oldPsw.Text == string.Empty)
            {
                opError.Text = "*";
                cError.Text  = "";
                npError.Text = "";
            }
            if (psw.Text == string.Empty)
            {
                npError.Text = "*";
                opError.Text = "";
                cError.Text  = "";
            }
            if (cpsw.Text == string.Empty)
            {
                cError.Text  = "*";
                npError.Text = "";
                opError.Text = "";
            }

            string rol      = Session["role"].ToString();
            string userName = Session["uname"].ToString();
            string password = oldPsw.Text;

            cError.Text  = "";
            npError.Text = "";
            opError.Text = "";
            try
            {
                using (niapsEntities1 ctx = new niapsEntities1())
                {
                    var myp = ctx.adminUsers.Where(cp => cp.userName ==
                                                   userName && cp.role == rol).First();
                    if (ValidatePassword(password, myp.password) == true)
                    {
                        try
                        {
                            string firstPsw   = psw.Text;
                            string confirmPsw = cpsw.Text;

                            if (firstPsw.Equals(confirmPsw))
                            {
                                int id     = myp.userId;
                                var result = ctx.adminUsers.FirstOrDefault(us => us.userId == id);
                                result.password = CreateHash(firstPsw);
                                ctx.SaveChanges();
                                msg.Text    = "Password changed successfully";
                                cpsw.Text   = "";
                                psw.Text    = "";
                                oldPsw.Text = "";
                            }
                            else
                            {
                                msg.Text = "passwords did not match";
                            }
                        }
                        catch
                        {
                            msg.Text     = "passwords did not match";
                            npError.Text = "";
                            cError.Text  = "";
                            npError.Text = "";
                        }
                    }
                    else
                    {
                        msg.Text     = "old password is wrong!...try again";
                        npError.Text = "";
                        cError.Text  = "";
                        npError.Text = "";
                    }
                }
            }
            catch (Exception)
            {
                msg.Text     = "passwords did not Match";
                npError.Text = "";
                cError.Text  = "";
                npError.Text = "";
            }
        }