Пример #1
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         string[] deleteIndexList = DeleteIds.Split(',');
         foreach (string index in deleteIndexList)
         {
             var data = new LayerDataModel();
             data.LayerId = int.Parse(index);
             LayerDataManager.Delete(data, SessionVariables.RequestProfile);
             DeleteAndRedirect();
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Пример #2
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                var superKey      = "";
                var newId         = Framework.Components.Core.SystemEntityTypeDataManager.GetNextSequence("Layer", (int)Framework.Components.DataAccess.SystemEntity.Layer, SessionVariables.RequestProfile);
                var Layerdata     = new LayerDataModel();
                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.Layer;
                    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]);
                            Layerdata.LayerId = key;

                            var Layerdt = LayerDataManager.GetDetails(Layerdata, SessionVariables.RequestProfile);

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

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

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

                    var Layerdt = LayerDataManager.GetDetails(Layerdata, SessionVariables.RequestProfile);

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

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

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

                Response.Redirect("Default.aspx?Added=true", false);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }