Beispiel #1
0
        public override int?Save(string action)
        {
            var data = new RiskDataModel();

            data.RiskId      = SystemKeyId;
            data.Name        = Name;
            data.Description = Description;
            data.SortOrder   = SortOrder;

            if (action == "Insert")
            {
                var dtRisk = RiskDataManager.DoesExist(data, SessionVariables.RequestProfile);

                if (dtRisk.Rows.Count == 0)
                {
                    RiskDataManager.Create(data, SessionVariables.RequestProfile);
                }
                else
                {
                    throw new Exception("Record with given ID already exists.");
                }
            }
            else
            {
                RiskDataManager.Update(data, SessionVariables.RequestProfile);
            }

            return(data.RiskId);
        }
Beispiel #2
0
        public void LoadData(int rewardId, bool showId)
        {
            Clear();

            var data = new RiskDataModel();

            data.RiskId = rewardId;

            var items = RiskDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            SetData(item);

            if (!showId)
            {
                SystemKeyId = item.RiskId;
                oHistoryList.Setup(PrimaryEntity, rewardId, PrimaryEntityKey);
            }
            else
            {
                CoreSystemKey.Text = String.Empty;
            }
        }
Beispiel #3
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();

            var data = new RiskDataModel();

            UpdatedData = RiskDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.RiskId =
                    Convert.ToInt32(SelectedData.Rows[i][RiskDataModel.DataColumns.RiskId].ToString());
                data.Name        = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Name].ToString();
                data.Description =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description))
                    ? CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description)
                    : SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Description].ToString();

                data.SortOrder =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder))
                    ? int.Parse(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder).ToString())
                    : int.Parse(SelectedData.Rows[i][StandardDataModel.StandardDataColumns.SortOrder].ToString());

                RiskDataManager.Update(data, SessionVariables.RequestProfile);
                data        = new RiskDataModel();
                data.RiskId = Convert.ToInt32(SelectedData.Rows[i][RiskDataModel.DataColumns.RiskId].ToString());
                var dt = RiskDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Beispiel #4
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var notDeletableIds = new List <int>();
                var deleteIndexList = DeleteIds.Split(',');

                foreach (var index in deleteIndexList)
                {
                    var data = new RiskDataModel();
                    data.RiskId = int.Parse(index);

                    if (!RiskDataManager.IsDeletable(data, SessionVariables.RequestProfile))
                    {
                        notDeletableIds.Add((int)(data.RiskId));
                    }
                }

                if (notDeletableIds.Count == 0)
                {
                    foreach (var index in deleteIndexList)
                    {
                        var data = new RiskDataModel();
                        data.RiskId = int.Parse(index);

                        RiskDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }
                else
                {
                    var msg = String.Empty;
                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "RiskId: " + id + " has detail records";
                    }

                    foreach (string index in deleteIndexList)
                    {
                        var data = new RiskDataModel();
                        data.RiskId = int.Parse(index);

                        //RiskDataManager.DeleteChildren(data, SessionVariables.RequestProfile);
                        RiskDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Beispiel #5
0
        private System.Data.DataTable GetData()
        {
            // TODO: on all export pages
            var data = new RiskDataModel();

            var dt = RiskDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Beispiel #6
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var riskdata = new RiskDataModel();

            riskdata.RiskId = entityKey;
            var results = RiskDataManager.Search(riskdata, SessionVariables.RequestProfile);

            return(results);
        }
Beispiel #7
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new RiskDataModel();

            // copies properties from values dictionary object to data object
            PropertyMapper.CopyProperties(data, values);

            RiskDataManager.Update(data, SessionVariables.RequestProfile);
            base.Update(values);
        }
Beispiel #8
0
        private void UpdateData(ArrayList values)
        {
            var data = new RiskDataModel();

            data.RiskId      = int.Parse(values[0].ToString());
            data.Name        = values[1].ToString();
            data.Description = values[2].ToString();
            data.SortOrder   = int.Parse(values[3].ToString());
            RiskDataManager.Update(data, SessionVariables.RequestProfile);
            ReBindEditableGrid();
        }
Beispiel #9
0
        private int GetNextValidId(int tempId)
        {
            var dt = RiskDataManager.GetList(SessionVariables.RequestProfile);

            foreach (DataRow dr in dt.Rows)
            {
                if (dr[RiskDataModel.DataColumns.RiskId].ToString().Equals(tempId.ToString()))
                {
                    tempId -= 1;
                    return(GetNextValidId(tempId));
                }
            }

            return(tempId);
        }
Beispiel #10
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         string[] deleteIndexList = DeleteIds.Split(',');
         foreach (string index in deleteIndexList)
         {
             var data = new RiskDataModel();
             data.RiskId = int.Parse(index);
             RiskDataManager.Delete(data, SessionVariables.RequestProfile);
             DeleteAndRedirect();
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Beispiel #11
0
        protected override void ShowData(int RiskId)
        {
            base.ShowData(RiskId);
            oDetailButtonPanel.SetId = SetId;
            Clear();

            var data = new RiskDataModel();

            data.RiskId = RiskId;

            var items = RiskDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count == 1)
            {
                var item = items[0];
                SetData(item);
                oHistoryList.Setup(PrimaryEntity, RiskId, "Risk");
            }
        }
Beispiel #12
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows = new DataTable();
                var riskdata     = new RiskDataModel();

                selectedrows = RiskDataManager.GetDetails(riskdata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        riskdata.RiskId = entityKey;
                        var result = RiskDataManager.GetDetails(riskdata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    riskdata.RiskId = SetId;
                    var result = RiskDataManager.GetDetails(riskdata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return(null);
        }
Beispiel #13
0
        public override void LoadDropDownListSources(string fieldName, DropDownList dropDownListControl)
        {
            base.LoadDropDownListSources(fieldName, dropDownListControl);

            if (fieldName.Equals("RiskId"))
            {
                var riskData = RiskDataManager.GetList(SessionVariables.RequestProfile);
                UIHelper.LoadDropDown(riskData, dropDownListControl,
                                      StandardDataModel.StandardDataColumns.Name,
                                      RiskDataModel.DataColumns.RiskId);
            }

            if (fieldName.Equals("RewardId"))
            {
                var rewardData = RewardDataManager.GetList(SessionVariables.RequestProfile);
                UIHelper.LoadDropDown(rewardData, dropDownListControl,
                                      StandardDataModel.StandardDataColumns.Name,
                                      RewardDataModel.DataColumns.RewardId);
            }

            if (fieldName.Equals("TaskId"))
            {
                var taskData = TaskDataManager.GetList(SessionVariables.RequestProfile);
                UIHelper.LoadDropDown(taskData, dropDownListControl,
                                      StandardDataModel.StandardDataColumns.Name,
                                      TaskDataModel.DataColumns.TaskId);
            }

            if (fieldName.Equals("PersonId"))
            {
                var applicationUserdata = ApplicationUserDataManager.GetList(SessionVariables.RequestProfile);
                UIHelper.LoadDropDown(applicationUserdata, dropDownListControl,
                                      ApplicationUserDataModel.DataColumns.FirstName,
                                      ApplicationUserDataModel.DataColumns.ApplicationUserId);
            }
        }
Beispiel #14
0
        protected override DataTable GetData()
        {
            var dt = RiskDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile);

            return(dt);
        }
Beispiel #15
0
        private void SetupDropdown()
        {
            var isTesting = SessionVariables.IsTesting;

            var rewardData = RewardDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(rewardData, drpRewardList, StandardDataModel.StandardDataColumns.Name,
                                  RewardDataModel.DataColumns.RewardId);


            var riskData = RiskDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(riskData, drpRiskList, StandardDataModel.StandardDataColumns.Name,
                                  RiskDataModel.DataColumns.RiskId);


            var taskData = TaskTimeTracker.Components.BusinessLayer.Task.TaskDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(taskData, drpTaskList, StandardDataModel.StandardDataColumns.Name,
                                  TaskDataModel.DataColumns.TaskId);


            var personData = Framework.Components.ApplicationUser.ApplicationUserDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(personData, drpPersonList, ApplicationUserDataModel.DataColumns.FirstName, ApplicationUserDataModel.DataColumns.ApplicationUserId);

            if (isTesting)
            {
                drpTaskList.AutoPostBack   = true;
                drpRewardList.AutoPostBack = true;
                drpPersonList.AutoPostBack = true;
                drpRiskList.AutoPostBack   = true;
                if (drpRiskList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtRiskId.Text.Trim()))
                    {
                        drpRiskList.SelectedValue = txtRiskId.Text;
                    }
                    else
                    {
                        txtRiskId.Text = drpRiskList.SelectedItem.Value;
                    }
                }
                if (drpRewardList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtRewardId.Text.Trim()))
                    {
                        drpRewardList.SelectedValue = txtRewardId.Text;
                    }
                    else
                    {
                        txtRewardId.Text = drpRewardList.SelectedItem.Value;
                    }
                }
                if (drpTaskList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtTaskId.Text.Trim()))
                    {
                        drpTaskList.SelectedValue = txtTaskId.Text;
                    }
                    else
                    {
                        txtTaskId.Text = drpTaskList.SelectedItem.Value;
                    }
                }
                if (drpPersonList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtPersonId.Text.Trim()))
                    {
                        drpPersonList.SelectedValue = txtPersonId.Text;
                    }
                    else
                    {
                        txtPersonId.Text = drpPersonList.SelectedItem.Value;
                    }
                }
                txtRiskId.Visible   = true;
                txtRewardId.Visible = true;
                txtTaskId.Visible   = true;
                txtPersonId.Visible = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(txtRiskId.Text.Trim()))
                {
                    drpRiskList.SelectedValue = txtRiskId.Text;
                }
                if (!string.IsNullOrEmpty(txtRewardId.Text.Trim()))
                {
                    drpRewardList.SelectedValue = txtRewardId.Text;
                }
                if (!string.IsNullOrEmpty(txtTaskId.Text.Trim()))
                {
                    drpTaskList.SelectedValue = txtTaskId.Text;
                }
                if (!string.IsNullOrEmpty(txtPersonId.Text.Trim()))
                {
                    drpPersonList.SelectedValue = txtPersonId.Text;
                }
            }
        }
Beispiel #16
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                var superKey      = "";
                var newId         = Framework.Components.Core.SystemEntityTypeDataManager.GetNextSequence("Risk", (int)Framework.Components.DataAccess.SystemEntity.Risk, SessionVariables.RequestProfile);
                var Riskdata      = new RiskDataModel();
                var systemdevdata = new SystemDevNumbersDataModel();
                systemdevdata.ApplicationUserId = SessionVariables.RequestProfile.AuditId;
                var dtnumbers = Framework.Components.Core.SystemDevNumbersDataManager.Search(systemdevdata, SessionVariables.RequestProfile);
                var rangefrom =
                    Convert.ToInt32(dtnumbers.Rows[0][SystemDevNumbersDataModel.DataColumns.RangeFrom].ToString());
                var rangeto =
                    Convert.ToInt32(dtnumbers.Rows[0][SystemDevNumbersDataModel.DataColumns.RangeTo].ToString());
                if (Request.QueryString["SuperKey"] != null)
                {
                    superKey = Request.QueryString["SuperKey"].ToString();
                    var data = new SuperKeyDetailDataModel();
                    data.SuperKeyId         = Convert.ToInt32(superKey);
                    data.SystemEntityTypeId = (int)Framework.Components.DataAccess.SystemEntity.Risk;
                    var dt = Framework.Components.Core.SuperKeyDetailDataManager.Search(data, SessionVariables.RequestProfile);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            var key = Convert.ToInt32(dr[SuperKeyDetailDataModel.DataColumns.EntityKey]);
                            Riskdata.RiskId = key;

                            var Riskdt = RiskDataManager.GetDetails(Riskdata, SessionVariables.RequestProfile);

                            if (Riskdt.Rows.Count == 1)
                            {
                                var row = Riskdt.Rows[0];

                                if (Request.QueryString["Mode"].ToString().Equals("Test"))
                                {
                                    Riskdata.RiskId = GetNextValidId(rangefrom);
                                }
                                Riskdata.Name        = Convert.ToString(row[StandardDataModel.StandardDataColumns.Name]);
                                Riskdata.Description = Convert.ToString(row[StandardDataModel.StandardDataColumns.Description]);
                                Riskdata.SortOrder   = Convert.ToInt32(row[StandardDataModel.StandardDataColumns.SortOrder]);

                                RiskDataManager.Create(Riskdata, SessionVariables.RequestProfile);
                            }
                        }
                    }
                }
                else if (Request.QueryString["SetId"] != null)
                {
                    var key = int.Parse(Request.QueryString["SetId"]);
                    Riskdata.RiskId = key;

                    var Riskdt = RiskDataManager.GetDetails(Riskdata, SessionVariables.RequestProfile);

                    if (Riskdt.Rows.Count == 1)
                    {
                        var row = Riskdt.Rows[0];

                        var newRiskdata = new RiskDataModel();
                        if (Request.QueryString["Mode"].ToString().Equals("Test"))
                        {
                            newRiskdata.RiskId = newId = (int)GetNextValidId(rangefrom);
                        }
                        newRiskdata.Name        = Convert.ToString(row[StandardDataModel.StandardDataColumns.Name]);
                        newRiskdata.Description = Convert.ToString(row[StandardDataModel.StandardDataColumns.Description]);
                        newRiskdata.SortOrder   = Convert.ToInt32(row[StandardDataModel.StandardDataColumns.SortOrder]);

                        UpdatedFKDepenedencies(key, newId);
                        RiskDataManager.Delete(Riskdata, SessionVariables.RequestProfile);
                        RiskDataManager.Create(newRiskdata, SessionVariables.RequestProfile);
                    }
                }
                else if (Request.QueryString["Mode"].ToString().Equals("Renumber"))
                {
                    var seed = int.Parse(Request.QueryString["Seed"].ToString());
                    //ApplicationVariables.Seed;
                    var increment = int.Parse(Request.QueryString["Increment"].ToString());
                    //ApplicationVariables.Increment;
                    RiskDataManager.Renumber(seed, increment, SessionVariables.RequestProfile);
                }
                base.OnInit(e);

                Response.Redirect("Default.aspx?Added=true", false);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Beispiel #17
0
 private void ReBindEditableGrid()
 {
     var data   = new RiskDataModel();
     var dtRisk = RiskDataManager.Search(data, SessionVariables.RequestProfile);
 }