예제 #1
0
        public void Delete(string value)
        {
            var dataQuery = new LanguageDataModel();

            dataQuery.LanguageId = int.Parse(value);
            LanguageDataManager.Delete(dataQuery, SessionVariables.RequestProfile);
        }
예제 #2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var notDeletableIds = new List <int>();
                var deleteIndexList = DeleteIds.Split(',');

                foreach (var index in deleteIndexList)
                {
                    var data = new LanguageDataModel();
                    data.LanguageId = int.Parse(index);

                    if (!LanguageDataManager.IsDeletable(data, SessionVariables.RequestProfile))
                    {
                        notDeletableIds.Add((int)(data.LanguageId));
                    }
                }

                if (notDeletableIds.Count == 0)
                {
                    foreach (var index in deleteIndexList)
                    {
                        var data = new LanguageDataModel();
                        data.LanguageId = int.Parse(index);

                        LanguageDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }
                else
                {
                    var msg = String.Empty;

                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "LanguageId: " + id + " has detail records";
                    }

                    foreach (string index in deleteIndexList)
                    {
                        var data = new LanguageDataModel();
                        data.LanguageId = int.Parse(index);

                        LanguageDataManager.DeleteChildren(data, SessionVariables.RequestProfile);
                        LanguageDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }