Example #1
0
        //public static List<MilestoneDataModel> GetEntityDetails(MilestoneDataModel data, int auditId)
        //{
        //    var sql = "EXEC dbo.MilestoneSearch " +
        //              " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, auditId) +
        //              ", " + ToSQLParameter(data, MilestoneDataModel.DataColumns.MilestoneId);

        //    var result = new List<MilestoneDataModel>();

        //    using (var reader = new DBDataReader("Get Details", sql, DataStoreKey))
        //    {
        //        var dbReader = reader.DBReader;

        //        while (dbReader.Read())
        //        {
        //            var dataItem = new MilestoneDataModel();

        //            dataItem.MilestoneId	= (int)dbReader[MilestoneDataModel.DataColumns.MilestoneId];
        //            dataItem.ProjectId		= (int)dbReader[MilestoneDataModel.DataColumns.ProjectId];
        //            dataItem.Project		= (string)dbReader[MilestoneDataModel.DataColumns.Project];

        //            SetStandardInfo(dataItem, dbReader);

        //            SetBaseInfo(dataItem, dbReader);

        //            result.Add(dataItem);
        //        }
        //    }

        //    return result;
        //}

        #endregion GetDetails

        #region CreateOrUpdate

        private static string CreateOrUpdate(MilestoneDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

            switch (action)
            {
            case "Create":
                sql += "dbo.MilestoneInsert  " + "\r\n" +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.MilestoneUpdate  " + "\r\n" +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, MilestoneDataModel.DataColumns.MilestoneId) +
                  ", " + ToSQLParameter(data, MilestoneDataModel.DataColumns.ProjectId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);

            return(sql);
        }
Example #2
0
        public override int?Save(string action)
        {
            var data = new MilestoneDataModel();

            data.MilestoneId = SystemKeyId;
            data.ProjectId   = ProjectId;
            data.Name        = Name;
            data.Description = Description;
            data.SortOrder   = SortOrder;

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

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

            // not correct ... when doing insert, we didn't get/change the value of MilestoneID ?
            return(data.MilestoneId);
        }
Example #3
0
        protected override void ShowData(int milestoneId)
        {
            base.ShowData(milestoneId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var data = new MilestoneDataModel();

            data.MilestoneId = milestoneId;

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

            // should only have single match
            if (items.Count == 1)
            {
                var item = items[0];

                SetData(item);

                lblProjectId.Text = item.Project.ToString();

                oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);

                oHistoryList.Setup((int)SystemEntity.Milestone, milestoneId, "Milestone");
            }
        }
Example #4
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new MilestoneDataModel();

            if (values.ContainsKey(MilestoneDataModel.DataColumns.MilestoneId))
            {
                data.MilestoneId = int.Parse(values[MilestoneDataModel.DataColumns.MilestoneId].ToString());
            }

            if (values.ContainsKey(StandardDataModel.StandardDataColumns.Name))
            {
                data.Name = values[StandardDataModel.StandardDataColumns.Name].ToString();
            }

            if (values.ContainsKey(StandardDataModel.StandardDataColumns.Description))
            {
                data.Description = values[StandardDataModel.StandardDataColumns.Description].ToString();
            }

            if (values.ContainsKey(StandardDataModel.StandardDataColumns.SortOrder))
            {
                data.SortOrder = int.Parse(values[StandardDataModel.StandardDataColumns.SortOrder].ToString());
            }

            if (values.ContainsKey(MilestoneDataModel.DataColumns.ProjectId))
            {
                data.ProjectId = int.Parse(values[MilestoneDataModel.DataColumns.ProjectId].ToString());
            }

            MilestoneDataManager.Update(data, SessionVariables.RequestProfile);

            base.Update(values);
        }
Example #5
0
        public static int Create(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Create");

            var milestoneId = DBDML.RunScalarSQL("Milestone.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(milestoneId));
        }
Example #6
0
        protected override void Clear()
        {
            base.Clear();

            var data = new MilestoneDataModel();

            SetData(data);
        }
Example #7
0
        public static DataTable Search(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            var table = list.ToDataTable();

            return(table);
        }
Example #8
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var milestonedata = new MilestoneDataModel();

            milestonedata.MilestoneId = entityKey;
            var results = MilestoneDataManager.Search(milestonedata, SessionVariables.RequestProfile);

            return(results);
        }
Example #9
0
        private DataTable GetData()
        {
            // TODO: on all export pages
            var data = new MilestoneDataModel();

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

            return(dt);
        }
Example #10
0
        private static DataSet GetChildren(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.MilestoneChildrenGet " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, MilestoneDataModel.DataColumns.MilestoneId);

            var oDT = new DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Example #11
0
        public static bool DoesExist(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new MilestoneDataModel();

            doesExistRequest.Name = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Example #12
0
        public static string ToSQLParameter(MilestoneDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case MilestoneDataModel.DataColumns.MilestoneId:
                if (data.MilestoneId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, MilestoneDataModel.DataColumns.MilestoneId, data.MilestoneId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, MilestoneDataModel.DataColumns.MilestoneId);
                }
                break;

            case MilestoneDataModel.DataColumns.ProjectId:
                if (data.ProjectId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, MilestoneDataModel.DataColumns.ProjectId, data.ProjectId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, MilestoneDataModel.DataColumns.ProjectId);
                }
                break;

            case MilestoneDataModel.DataColumns.Project:
                if (data.Project != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, MilestoneDataModel.DataColumns.Project, data.Project);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, MilestoneDataModel.DataColumns.Project);
                }
                break;

            default:
                returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Example #13
0
        public static void Delete(MilestoneDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.MilestoneDelete ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                ,
                MilestoneId = dataQuery.MilestoneId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Example #14
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var      notDeletableIds = new List <int>();
                string[] deleteIndexList = DeleteIds.Split(',');
                //foreach (string index in deleteIndexList)
                //{
                //    var data = new Framework.Components.EventMonitoring.Milestone.Data();
                //    data.MilestoneId = int.Parse(index);
                //    if (!Framework.Components.EventMonitoring.Milestone.IsDeletable(data, SessionVariables.RequestProfile.AuditId))
                //    {
                //        notDeletableIds.Add(Convert.ToInt32(data.MilestoneId));
                //    }
                //}
                if (notDeletableIds.Count == 0)
                {
                    foreach (string index in deleteIndexList)
                    {
                        var data = new MilestoneDataModel();
                        data.MilestoneId = int.Parse(index);
                        MilestoneDataManager.Delete(data, SessionVariables.RequestProfile);
                    }

                    DeleteAndRedirect();
                }
                else
                {
                    var msg = String.Empty;
                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "MilestoneId: " + id + " has detail records";
                    }
                    Response.Write(msg);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Example #15
0
        public static bool IsDeletable(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var isDeletable = true;
            var ds          = GetChildren(data, requestProfile);

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.Rows.Count > 0)
                    {
                        isDeletable = false;
                        break;
                    }
                }
            }
            return(isDeletable);
        }
Example #16
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new MilestoneDataModel();

            UpdatedData = MilestoneDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.MilestoneId =
                    Convert.ToInt32(SelectedData.Rows[i][MilestoneDataModel.DataColumns.MilestoneId].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());

                data.ProjectId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(MilestoneDataModel.DataColumns.ProjectId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(MilestoneDataModel.DataColumns.ProjectId).ToString())
                                        : int.Parse(SelectedData.Rows[i][MilestoneDataModel.DataColumns.ProjectId].ToString());

                MilestoneDataManager.Update(data, SessionVariables.RequestProfile);
                data             = new MilestoneDataModel();
                data.MilestoneId = Convert.ToInt32(SelectedData.Rows[i][MilestoneDataModel.DataColumns.MilestoneId].ToString());
                var dt = MilestoneDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Example #17
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows  = new DataTable();
                var milestonedata = new MilestoneDataModel();

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

                    foreach (var entityKey in lstEntityKeys)
                    {
                        milestonedata.MilestoneId = entityKey;
                        var result = MilestoneDataManager.GetDetails(milestonedata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    milestonedata.MilestoneId = SetId;
                    var result = MilestoneDataManager.GetDetails(milestonedata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(null);
        }
Example #18
0
        public static List <MilestoneDataModel> GetEntityDetails(MilestoneDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.MilestoneSearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , ReturnAuditInfo = returnAuditInfo
                , MilestoneId     = dataQuery.MilestoneId
                , Name            = dataQuery.Name
                , ProjectId       = dataQuery.ProjectId
            };

            List <MilestoneDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <MilestoneDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Example #19
0
        public void SetData(MilestoneDataModel data)
        {
            SystemKeyId = data.MilestoneId;

            base.SetData(data);
        }
Example #20
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                var superKey      = "";
                var newId         = SystemEntityTypeDataManager.GetNextSequence("Milestone", (int)SystemEntity.Milestone, SessionVariables.RequestProfile);
                var Milestonedata = new MilestoneDataModel();
                var systemdevdata = new SystemDevNumbersDataModel();
                systemdevdata.ApplicationUserId = SessionVariables.RequestProfile.AuditId;
                var dtnumbers = 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)SystemEntity.Milestone;
                    var dt = SuperKeyDetailDataManager.Search(data, SessionVariables.RequestProfile);

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

                            var Milestonedt = MilestoneDataManager.GetDetails(Milestonedata, SessionVariables.RequestProfile);

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

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

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

                    var Milestonedt = MilestoneDataManager.GetDetails(Milestonedata, SessionVariables.RequestProfile);

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

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

                        UpdatedFKDepenedencies(key, newId);
                        MilestoneDataManager.Delete(Milestonedata, SessionVariables.RequestProfile);
                        MilestoneDataManager.Create(newMilestonedata, 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;
                    MilestoneDataManager.Renumber(seed, increment, SessionVariables.RequestProfile);
                }
                base.OnInit(e);

                Response.Redirect("Default.aspx?Added=true", false);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Example #21
0
        public void LoadData(int milestoneId, bool showId)
        {
            Clear();

            var data = new MilestoneDataModel();

            //var projectData = TaskTimeTracker.Components.BusinessLayer.Project.GetList(SessionVariables.RequestProfile.AuditId);
            //var data = new MilestoneDataModel();

            data.MilestoneId = milestoneId;
            var items = MilestoneDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

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

            var item = items[0];

            SetData(item);

            if (!showId)
            {
                SystemKeyId = item.MilestoneId;
                ProjectId   = item.ProjectId;

                oHistoryList.Setup(PrimaryEntity, milestoneId, PrimaryEntityKey);
            }
            else
            {
                CoreSystemKey.Text = String.Empty;
            }

            /*if (items.Rows.Count == 1)
             * {
             *      var row = oMilestoneTable.Rows[0];
             *
             *      if (!showId)
             *      {
             *              txtMilestoneId.Text = Convert.ToString(row[TaskTimeTracker.MilestoneDataModel.DataColumns.MilestoneId]);
             *
             *              // only show Audit History in case of Update page, not for Clone.
             *              oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.Milestone, milestoneId, "Milestone");
             *              dynAuditHistory.Visible = PerferenceUtility.GetUserPreferenceByKeyAsBoolean(ApplicationCommon.HistoryGridVisibilityKey, "Milestone");
             *
             *      }
             *
             *      else
             *      {
             *              txtMilestoneId.Text = String.Empty;
             *      }
             *      txtDescription.InnerText        = Convert.ToString(row[TaskTimeTracker.MilestoneDataModel.DataColumns.Description]);
             *      txtName.Text                    = Convert.ToString(row[TaskTimeTracker.MilestoneDataModel.DataColumns.Name]);
             *      txtSortOrder.Text               = Convert.ToString(row[TaskTimeTracker.MilestoneDataModel.DataColumns.SortOrder]);
             *      drpProjectList.SelectedValue    = Convert.ToString(row[TaskTimeTracker.MilestoneDataModel.DataColumns.ProjectId]);
             *      txtProjectId.Text               = Convert.ToString(row[TaskTimeTracker.MilestoneDataModel.DataColumns.ProjectId]);
             *
             *      oUpdateInfo.LoadText(oMilestoneTable.Rows[0]);
             * }
             * else
             * {
             *      txtMilestoneId.Text = String.Empty;
             *      txtDescription.InnerText = String.Empty;
             *      txtName.Text = String.Empty;
             *      txtSortOrder.Text = String.Empty;
             * }*/
        }
Example #22
0
        public void SetData(MilestoneDataModel item)
        {
            SystemKeyId = item.MilestoneId;

            base.SetData(item);
        }
Example #23
0
        public static void Update(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Update");

            DBDML.RunSQL("Milestone.Update", sql, DataStoreKey);
        }
Example #24
0
        public static MilestoneDataModel GetDetails(MilestoneDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile);

            return(list.FirstOrDefault());
        }