Exemple #1
0
        protected void grdFiles_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            foreach (GridViewRow r in grdFiles.Rows)
            {
                HiddenField hfFileGroupID = (HiddenField)r.FindControl("hfFileID");

                LinkButton lbCH = (LinkButton)r.FindControl("lbch");

                LinkButton lbRe = (LinkButton)r.FindControl("lbRe");
                LinkButton lbGu = (LinkButton)r.FindControl("lbGu");

                int FileGroupID = Convert.ToInt32(hfFileGroupID.Value);

                using (RiskManagementEntities db = new RiskManagementEntities())
                {
                    var n = (from a in db.Files
                             where a.FileGroupID == FileGroupID
                             select a).FirstOrDefault();

                    if (n.CHName.Length <= 0)
                    {
                        lbCH.Enabled = false;
                    }
                    if (n.RGName.Length <= 0)
                    {
                        lbRe.Enabled = false;
                    }
                    if (n.GUName.Length <= 0)
                    {
                        lbGu.Enabled = false;
                    }
                }
            }
        }
Exemple #2
0
        protected void btnInsert_OnClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    if (HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        string userId = HttpContext.Current.User.Identity.Name;

                        int id = Convert.ToInt32(userId);

                        using (RiskManagementEntities db = new RiskManagementEntities())
                        {
                            string password = Helper.CreateHashPassword(txtPassword.Text);

                            Users user = db.Users
                                         .FirstOrDefault(current => current.UserID == id);

                            user.Password      = password;
                            user.IsChangedPass = true;

                            db.SaveChanges();

                            RedirectToPage(user.RoleID);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
        }
Exemple #3
0
        private void GridViewBind()
        {
            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                var n = from us in db.Users
                        join rl in db.Users
                        on us.SupervisorUserId equals rl.UserID into g
                        from a in g.DefaultIfEmpty()

                        where us.RoleID == 3

                        select new
                {
                    UserID          = us.UserID,
                    Username        = us.Username,
                    Password        = us.Password,
                    UserCompanyName = a.Username,
                    Email           = us.Email,
                    Name            = us.Name,
                    Family          = us.Family,
                };
                grdUsers.DataSource = n;
                grdUsers.DataBind();
            }
        }
Exemple #4
0
        protected void grdUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "DoEdit":
            {
                ViewState["UserID"]   = Convert.ToInt32(e.CommandArgument);
                ViewState["EditMode"] = "Edit";
                LoadForm();
                mvUsers.SetActiveView(vwEdit);
                break;
            }

            case "DoDelete":
            {
                ViewState["UserID"] = Convert.ToInt32(e.CommandArgument);
                int UserID = Convert.ToInt32(ViewState["UserID"]);


                ViewState["EditMode"] = "Delete";
                using (RiskManagementEntities db = new RiskManagementEntities())
                {
                    var n = (from us in db.Users
                             where us.UserID == UserID
                             select us).FirstOrDefault();

                    lblUserDelete.Text = n.Username;
                    mvUsers.SetActiveView(vwDelete);
                }
                break;
            }
            }
        }
Exemple #5
0
        private void UpdateForm()
        {
            int UserID = Convert.ToInt32(ViewState["UserID"]);

            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                var n = (from us in db.Users
                         where us.UserID == UserID
                         select us).FirstOrDefault();
                if (ddlUser.SelectedValue != "-1")
                {
                    n.SupervisorUserId = Convert.ToInt32(ddlUser.SelectedValue);
                }
                else
                {
                    n.SupervisorUserId = null;
                }


                n.Username = txtUsername.Text;
                n.Password = txtPassword.Text;

                n.Email = txtEmail.Text;

                n.Name   = txtName.Text;
                n.Family = txtFamily.Text;

                db.SaveChanges();
            }
        }
Exemple #6
0
        private void LoadForm()
        {
            int UserID = Convert.ToInt32(ViewState["UserID"]);

            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                var n = (from us in db.Users
                         where us.UserID == UserID
                         select us).FirstOrDefault();

                if (n != null)
                {
                    if (n.SupervisorUserId != null)
                    {
                        ddlUser.SelectedValue = n.SupervisorUserId.ToString();
                    }
                    txtUsername.Text = n.Username.ToString();


                    txtPassword.Text = n.Password.ToString();
                    txtEmail.Text    = n.Email.ToString();

                    txtName.Text   = n.Name.ToString();
                    txtFamily.Text = n.Family.ToString();
                }
                ;
            }
        }
Exemple #7
0
        private void Delete()
        {
            int UserID = Convert.ToInt32(ViewState["UserID"]);

            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                (from us in db.Users
                 where us.UserID == UserID
                 select us).ToList().ForEach(db.DeleteObject);
                db.SaveChanges();
            }
        }
Exemple #8
0
        protected void btnEvalRisk_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow r in grdRisks.Rows)
            {
                HiddenField  hfRisk            = (HiddenField)(r.FindControl("hfRisk"));
                DropDownList ddlProb           = (DropDownList)r.FindControl("ddlProb");
                Label        lblRisk           = (Label)(r.FindControl("lblRisk"));
                DropDownList ddlInt            = (DropDownList)r.FindControl("ddlInt");
                int          RiskIntensityID   = Convert.ToInt32(ddlInt.SelectedValue);
                int          RiskProbabilityID = Convert.ToInt32(ddlProb.SelectedValue);

                using (RiskManagementEntities db = new RiskManagementEntities())
                {
                    var n = (from re in db.RiskEvaluations
                             where re.RiskIntensityID == RiskIntensityID &&
                             re.RiskProbabilityID == RiskProbabilityID
                             select re).FirstOrDefault();


                    if (n != null)
                    {
                        if (n.RiskEvaluationNumber >= 1 &&
                            n.RiskEvaluationNumber <= 3)
                        {
                            lblRisk.Text = n.RiskEvaluationNumber.ToString() + "-" +
                                           "قابل قبول بدون نیاز به بازنگری";
                        }
                        else if (n.RiskEvaluationNumber >= 4 &&
                                 n.RiskEvaluationNumber <= 11)
                        {
                            lblRisk.Text = n.RiskEvaluationNumber.ToString() + "-" +
                                           "قابل قبول با نیاز به بازنگری";
                        }
                        else if (n.RiskEvaluationNumber >= 12 &&
                                 n.RiskEvaluationNumber <= 15)
                        {
                            lblRisk.Text = n.RiskEvaluationNumber.ToString() + "-" +
                                           "نامطلوب ، نیاز به تصمیم گیری";
                        }
                        else if (n.RiskEvaluationNumber >= 16 &&
                                 n.RiskEvaluationNumber <= 20)
                        {
                            lblRisk.Text = n.RiskEvaluationNumber.ToString() + "-" +
                                           "غیر قابل قبول";
                        }
                    }
                }
            }
            btnInsert.Visible = true;
        }
Exemple #9
0
        public void LoadIntDDL(DropDownList ddlInt)
        {
            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                var n = from p in db.RiskIntensities
                        orderby p.RiskIntensityLevel ascending
                        select p;

                ddlInt.DataSource     = n;
                ddlInt.DataValueField = "RiskIntensityID";
                ddlInt.DataTextField  = "RiskIntensityTitle";
                ddlInt.DataBind();
            }
        }
Exemple #10
0
        protected void cvOldPassword_OnServerValidate(object source, ServerValidateEventArgs args)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                string userId = HttpContext.Current.User.Identity.Name;

                int id = Convert.ToInt32(userId);

                using (RiskManagementEntities db = new RiskManagementEntities())
                {
                    string password = Helper.CreateHashPassword(txtoldPassword.Text);

                    Users user = db.Users
                                 .FirstOrDefault(current => current.UserID == id && current.Password == password);

                    args.IsValid = user != null;
                }
            }
        }
Exemple #11
0
 public void loadCompanies()
 {
     using (RiskManagementEntities db = new RiskManagementEntities())
     {
         var n = from a in db.Users
                 where a.RoleID == 2
                 select new
         {
             a.UserID,
             a.Username
         };
         ddlUser.Items.Clear();
         ddlUser.Items.Add(new ListItem("پیمانکار", "-1"));
         foreach (var i in n)
         {
             ddlUser.Items.Add(new ListItem(i.Username, i.UserID.ToString()));
         }
     }
 }
        protected void grdAdvanceSearch_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ShowAll")
            {
                int ID = Convert.ToInt32(e.CommandArgument);

                string SearchType = GetDropDownData();

                if (SearchType == "Operation")
                {
                    Response.Redirect("~/Admin/ActSetting.aspx?ID=" + ID);
                }
                else if (SearchType == "Act")
                {
                    Response.Redirect("~/Admin/StageSetting.aspx?ID=" + ID);
                }
                else if (SearchType == "Stage")
                {
                    Response.Redirect("~/Admin/RiskSetting.aspx?ID=" + ID);
                }
                else if (SearchType == "Risk")
                {
                    Response.Redirect("~/Admin/ControllSetting.aspx?ID=" + ID);
                }
                else if (SearchType == "Control")
                {
                    using (RiskManagementEntities db = new RiskManagementEntities())
                    {
                        var n = (from a in db.ControlingWorks
                                 where a.ControlID == ID
                                 select a).FirstOrDefault();


                        Response.Redirect("~/Admin/ControllSetting.aspx?ID=" + n.RiskID);
                    }
                }
                //   }
            }
        }
Exemple #13
0
        private void InsertForm()
        {
            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                Users us = new Users();

                us.RoleID   = 3;
                us.Username = txtUsername.Text;
                us.Password = txtPassword.Text;

                us.Email = txtEmail.Text;

                us.Name   = txtName.Text;
                us.Family = txtFamily.Text;
                if (ddlUser.SelectedValue != "-1")
                {
                    us.SupervisorUserId = Convert.ToInt32(ddlUser.SelectedValue);
                }


                db.Users.AddObject(us);
                db.SaveChanges();
            }
        }
        protected void btnDearch_Click(object sender, EventArgs e)
        {
            string SearchType = GetDropDownData();

            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                if (SearchType == "Operation")
                {
                    if (txtSearch.Text.Length > 0)
                    {
                        var n = from a in db.Operations
                                where a.OperationTitle.Contains(txtSearch.Text)
                                select new
                        {
                            Tittle     = a.OperationTitle,
                            ID         = a.OperationID,
                            GroupTitle = "عملیات"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                    else
                    {
                        var n = from a in db.Operations
                                select new
                        {
                            Tittle     = a.OperationTitle,
                            ID         = a.OperationID,
                            GroupTitle = "عملیات"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                }

                else if (SearchType == "Act")
                {
                    if (txtSearch.Text.Length > 0)
                    {
                        var n = from a in db.Acts
                                where a.ActTitle.Contains(txtSearch.Text)
                                select new
                        {
                            Tittle     = a.ActTitle,
                            ID         = a.ActID,
                            GroupTitle = "فعالیت"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                    else
                    {
                        var n = from a in db.Acts
                                select new
                        {
                            Tittle     = a.ActTitle,
                            ID         = a.ActID,
                            GroupTitle = "فعالیت"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                }



                else if (SearchType == "Stage")
                {
                    if (txtSearch.Text.Length > 0)
                    {
                        var n = from a in db.Stages
                                where a.StageTitle.Contains(txtSearch.Text)
                                select new
                        {
                            Tittle     = a.StageTitle,
                            ID         = a.StageID,
                            GroupTitle = "مرحله"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                    else
                    {
                        var n = from a in db.Stages
                                select new
                        {
                            Tittle     = a.StageTitle,
                            ID         = a.StageID,
                            GroupTitle = "مرحله"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                }



                else if (SearchType == "Risk")
                {
                    if (txtSearch.Text.Length > 0)
                    {
                        var n = from a in db.Risks
                                where a.RiskTitle.Contains(txtSearch.Text)
                                select new
                        {
                            Tittle     = a.RiskTitle,
                            ID         = a.RiskID,
                            GroupTitle = "ریسک"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                    else
                    {
                        var n = from a in db.Risks
                                select new
                        {
                            Tittle     = a.RiskTitle,
                            ID         = a.RiskID,
                            GroupTitle = "ریسک"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                }
                else if (SearchType == "Control")
                {
                    if (txtSearch.Text.Length > 0)
                    {
                        var n = from a in db.ControlingWorks
                                where a.ControlTitle.Contains(txtSearch.Text)
                                select new
                        {
                            Tittle     = a.ControlTitle,
                            ID         = a.ControlID,
                            GroupTitle = "اقدامات کنترلی"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                    else
                    {
                        var n = from a in db.ControlingWorks
                                select new
                        {
                            Tittle     = a.ControlTitle,
                            ID         = a.ControlID,
                            GroupTitle = "اقدامات کنترلی"
                        };
                        grdAdvanceSearch.DataSource = n;
                        grdAdvanceSearch.DataBind();
                    }
                }
            }
        }
Exemple #15
0
        public void LoadRiskgrd(int StageID)
        {
            using (RiskManagementEntities db = new RiskManagementEntities())
            {
                var n = from og in db.Risks
                        where og.StageID == StageID && og.IsAcceptedByAdmin == true
                        select og;
                grdRisks.DataSource = n;
                grdRisks.DataBind();

                foreach (GridViewRow r in grdRisks.Rows)
                {
                    HiddenField  hfRiskId = (HiddenField)r.FindControl("hfRisk");
                    int          riskId   = Convert.ToInt32(hfRiskId.Value);
                    DropDownList ddlProb  = (DropDownList)r.FindControl("ddlProb");
                    if (ddlProb != null)
                    {
                        LoadProbDDL(ddlProb);
                    }
                    DropDownList ddlInt = (DropDownList)r.FindControl("ddlInt");
                    if (ddlInt != null)
                    {
                        LoadIntDDL(ddlInt);
                    }

                    int UserID   = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                    var userRisk = (from ru in db.UserRisks
                                    where ru.UserID_Company == UserID && ru.RiskID == riskId
                                    select ru).FirstOrDefault();
                    Label lblProb = (Label)r.FindControl("lblBProb");
                    Label lblInt  = (Label)r.FindControl("lblBInt");
                    Label lblRisk = (Label)r.FindControl("lblBRisk");
                    if (userRisk != null)
                    {
                        var riskProbability = db.RiskProbabilities.Where(current => current.RiskProbabilityID == userRisk.RiskProbabilityID).FirstOrDefault();
                        if (riskProbability != null)
                        {
                            lblProb.Text = riskProbability.RiskProbabilityTitle;
                        }

                        var riskIntensity = db.RiskIntensities.Where(current => current.RiskIntensityID == userRisk.RiskIntensityID).FirstOrDefault();
                        if (riskIntensity != null)
                        {
                            lblInt.Text = riskIntensity.RiskIntensityTitle;
                        }

                        var evaluation = (from re in db.RiskEvaluations
                                          where re.RiskIntensityID == userRisk.RiskIntensityID &&
                                          re.RiskProbabilityID == userRisk.RiskProbabilityID
                                          select re).FirstOrDefault();
                        if (evaluation != null)
                        {
                            if (evaluation.RiskEvaluationNumber >= 1 &&
                                evaluation.RiskEvaluationNumber <= 3)
                            {
                                lblRisk.Text = evaluation.RiskEvaluationNumber.ToString() + "-" +
                                               "قابل قبول بدون نیاز به بازنگری";
                            }
                            else if (evaluation.RiskEvaluationNumber >= 4 &&
                                     evaluation.RiskEvaluationNumber <= 11)
                            {
                                lblRisk.Text = evaluation.RiskEvaluationNumber.ToString() + "-" +
                                               "قابل قبول با نیاز به بازنگری";
                            }
                            else if (evaluation.RiskEvaluationNumber >= 12 &&
                                     evaluation.RiskEvaluationNumber <= 15)
                            {
                                lblRisk.Text = evaluation.RiskEvaluationNumber.ToString() + "-" +
                                               "نامطلوب ، نیاز به تصمیم گیری";
                            }
                            else if (evaluation.RiskEvaluationNumber >= 16 &&
                                     evaluation.RiskEvaluationNumber <= 20)
                            {
                                lblRisk.Text = evaluation.RiskEvaluationNumber.ToString() + "-" +
                                               "غیر قابل قبول";
                            }
                        }
                    }
                    else
                    {
                        var riskProbability = db.RiskProbabilities.Where(current => current.RiskProbabilityLevel == 1).FirstOrDefault();
                        if (riskProbability != null)
                        {
                            lblProb.Text = riskProbability.RiskProbabilityTitle;
                        }

                        var riskIntensity = db.RiskIntensities.Where(current => current.RiskIntensityLevel == 1).FirstOrDefault();
                        if (riskIntensity != null)
                        {
                            lblInt.Text = riskIntensity.RiskIntensityTitle;
                        }
                    }
                }
                if (n.FirstOrDefault() != null)
                {
                    btnEvalRisk.Visible = true;
                    //btnExportToExcel.Visible = true;
                }
            }
        }
Exemple #16
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            string script = "alert('خطا')";

            try
            {
                //string QS = Request.QueryString["Id"].ToString();
                int UserID = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                using (RiskManagementEntities db = new RiskManagementEntities())
                {
                    foreach (GridViewRow r in grdRisks.Rows)
                    {
                        HiddenField  hfRisk            = (HiddenField)(r.FindControl("hfRisk"));
                        int          RiskID            = Convert.ToInt32(hfRisk.Value);
                        DropDownList ddlProb           = (DropDownList)r.FindControl("ddlProb");
                        DropDownList ddlInt            = (DropDownList)r.FindControl("ddlInt");
                        int          RiskIntensityID   = Convert.ToInt32(ddlInt.SelectedValue);
                        int          RiskProbabilityID = Convert.ToInt32(ddlProb.SelectedValue);

                        var n = (from ru in db.UserRisks
                                 where ru.RiskID == RiskID
                                 select ru).FirstOrDefault();


                        if (n == null)
                        {
                            UserRisks u = new UserRisks()
                            {
                                UserID_Company            = UserID,
                                RiskID                    = RiskID,
                                RiskIntensityID_AfterCO   = RiskIntensityID,
                                RiskProbabilityID_AfterCO = RiskProbabilityID,
                                IsCheckByAdmin            = false,
                                IsCheckBySup              = false,
                                CreationDate              = DateTime.Now,
                                StatusId                  = 1,
                            };
                            db.UserRisks.AddObject(u);
                        }
                        else
                        {
                            //if (n.StatusId == 1)
                            //{
                            n.RiskIntensityID_AfterCO   = RiskIntensityID;
                            n.RiskProbabilityID_AfterCO = RiskProbabilityID;
                            n.LastModifationDate        = DateTime.Now;
                            //}
                            //else
                            //{
                            //    script =
                            //        "alert('ریسک های این مرحله پیش از این توسط ناظر بررسی شده است و امکان تغییر وجود ندارد');";

                            //    break;
                            //}
                        }


                        script = "alert('ثبت اطلاعات با موفقیت انجام شد');";
                    }

                    db.SaveChanges();
                }
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Test5", script, true);
            }
            catch (Exception exception)
            {
                script = "alert('در فرآیند ثبت اطلاعات خطایی رخ داده است. لطفا مجددا اطلاعات را وارد نمایید.');";

                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Test", script, true);
            }
        }