示例#1
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);
        }
示例#2
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);
            }
        }