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