Beispiel #1
0
 protected void lnkDelete_Click(object sender, EventArgs e)
 {
     if (dgvDisplayNames.Rows.Count > 0)
     {
         foreach (GridViewRow dr in dgvDisplayNames.Rows)
         {
             var chkSelected = (CheckBox)dr.FindControl("chkSelected");
             if (chkSelected != null)
             {
                 if (chkSelected.Checked)
                 {
                     var data = new FieldConfigurationDisplayNameDataModel();
                     data.FieldConfigurationDisplayNameId = Convert.ToInt32(dgvDisplayNames.DataKeys[dr.DataItemIndex].Value);
                     FieldConfigurationDisplayNameDataManager.Delete(data, SessionVariables.RequestProfile);
                 }
             }
         }
     }
     bindGrid();
 }
Beispiel #2
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 FieldConfigurationDataModel();
                    data.FieldConfigurationId = int.Parse(index);
                    if (!FieldConfigurationDataManager.IsDeletable(data, SessionVariables.RequestProfile))
                    {
                        notDeletableIds.Add(Convert.ToInt32(data.FieldConfigurationId));
                    }
                }
                if (notDeletableIds.Count == 0)
                {
                    foreach (string index in deleteIndexList)
                    {
                        var data = new FieldConfigurationDataModel();
                        data.FieldConfigurationId = int.Parse(index);
                        FieldConfigurationDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                    Framework.Components.Audit.AuditHistoryDataManager.DeleteDataBySystemEntity(DeleteIds, (int)Framework.Components.DataAccess.SystemEntity.FieldConfiguration, SessionVariables.RequestProfile);

                    Response.Redirect(Page.GetRouteUrl("FieldConfigurationEntityRoute", new { Action = "Default", SetId = true }), false);
                }
                else
                {
                    var msg = String.Empty;
                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "FieldConfigurationId: " + id + " has detail records";
                        var data = new FieldConfigurationDisplayNameDataModel();
                        data.FieldConfigurationId = id;
                        var dt = FieldConfigurationDisplayNameDataManager.Search(data, SessionVariables.RequestProfile, SessionVariables.ApplicationMode);
                        foreach (DataRow dr in dt.Rows)
                        {
                            var fcdnid = int.Parse(dr[FieldConfigurationDisplayNameDataModel.DataColumns.FieldConfigurationDisplayNameId].ToString());
                            data.FieldConfigurationDisplayNameId = fcdnid;
                            FieldConfigurationDisplayNameDataManager.Delete(data, SessionVariables.RequestProfile);
                        }
                        var fcdata = new FieldConfigurationDataModel();
                        fcdata.FieldConfigurationId = id;
                        FieldConfigurationDataManager.Delete(fcdata, SessionVariables.RequestProfile);

                        Framework.Components.Audit.AuditHistoryDataManager.DeleteDataBySystemEntity(id.ToString(), (int)Framework.Components.DataAccess.SystemEntity.FieldConfiguration, SessionVariables.RequestProfile);

                        Response.Redirect(Page.GetRouteUrl("FieldConfigurationEntityRoute", new { Action = "Default", SetId = true }), false);
                    }
                    Response.Write(msg);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }