Exemplo n.º 1
0
        protected void tvTrainTypeChangeCallBack_Callback(object sender, CallBackEventArgs e)
        {
            TrainTypeBLL objTrainType = new TrainTypeBLL();
            TrainType    traintype    = objTrainType.GetTrainTypeInfo(int.Parse(e.Parameters[0]));
            int          cout         = traintype.ParentID == 0 ? tvTrainType.Nodes.Count : tvTrainType.FindNodeById(traintype.ParentID.ToString()).Nodes.Count;

            if (e.Parameters[1] == "MoveUp")
            {
                if (traintype.OrderIndex <= cout && traintype.OrderIndex >= 2)
                {
                    traintype.OrderIndex--;
                    objTrainType.UpdateTrainType(traintype);

                    traintype = objTrainType.GetTrainTypeInfo(int.Parse(tvTrainType.FindNodeById(e.Parameters[0]).PreviousSibling.ID));
                    traintype.OrderIndex++;
                    objTrainType.UpdateTrainType(traintype);
                }
            }
            if (e.Parameters[1] == "MoveDown")
            {
                if (traintype.OrderIndex <= cout - 1 && traintype.OrderIndex >= 1)
                {
                    traintype.OrderIndex++;
                    objTrainType.UpdateTrainType(traintype);

                    traintype = objTrainType.GetTrainTypeInfo(int.Parse(tvTrainType.FindNodeById(e.Parameters[0]).NextSibling.ID));
                    traintype.OrderIndex--;
                    objTrainType.UpdateTrainType(traintype);
                }
            }

            if (e.Parameters[1] == "Insert")
            {
                IList <RailExam.Model.TrainType> objList = objTrainType.GetTrainTypeByWhereClause("1=1", "Train_Type_ID desc");
                hfMaxID.Value = objList[0].TrainTypeID.ToString();
                hfMaxID.RenderControl(e.Output);
            }
            else if (e.Parameters[1] == "Delete")
            {
                hfMaxID.Value = e.Parameters[2];
                hfMaxID.RenderControl(e.Output);
            }

            tvTrainType.Nodes.Clear();
            BindTrainTypeTree();

            tvTrainType.RenderControl(e.Output);
        }
Exemplo n.º 2
0
        //private ArrayList GetTypeList()
        //{
        //    ArrayList objList = new ArrayList();
        //    string str = Request.QueryString.Get("id");
        //    string[] strType = str.Split(',');

        //    for(int i=0; i< strType.Length; i++)
        //    {
        //        objList.Add(strType[i].ToString());
        //    }

        //    return objList;
        //}

        private void BindTrainTypeTree()
        {
            //ArrayList objList = GetTypeList();

            TrainTypeBLL      trainTypeBLL = new TrainTypeBLL();
            IList <TrainType> trainTypes   = new List <TrainType>();

            if (!string.IsNullOrEmpty(Request.QueryString.Get("type")))
            {
                trainTypes = trainTypeBLL.GetTrainTypeByWhereClause("id_path || '/' like '/363/%'", "LEVEL_NUM, ORDER_INDEX ASC");
            }
            else
            {
                trainTypes = trainTypeBLL.GetTrainTypes();
            }

            string strID = Request.QueryString["id"];

            string[] strIDS = { };
            if (!string.IsNullOrEmpty(strID))
            {
                strIDS = strID.Split(',');
            }

            if (trainTypes.Count > 0)
            {
                TreeViewNode tvn = null;

                foreach (TrainType trainType in trainTypes)
                {
                    tvn         = new TreeViewNode();
                    tvn.ID      = trainType.TrainTypeID.ToString();
                    tvn.Value   = trainType.TrainTypeID.ToString();
                    tvn.Text    = trainType.TypeName;
                    tvn.ToolTip = trainType.TypeName;

                    IList <TrainType> trainTypes1 = trainTypeBLL.GetTrainTypeByParentId(trainType.TrainTypeID);

                    if (trainTypes1.Count == 0)
                    {
                        tvn.ShowCheckBox = true;
                    }

                    foreach (string strOrgID in strIDS)
                    {
                        if (strOrgID == trainType.TrainTypeID.ToString() && tvn.ShowCheckBox)
                        {
                            tvn.Checked = true;
                        }
                    }

                    //if(objList.IndexOf(tvn.ID) != -1)
                    //{
                    //    tvn.Checked = true;
                    //}

                    if (trainType.ParentID == 0)
                    {
                        tvTrainType.Nodes.Add(tvn);
                    }
                    else
                    {
                        try
                        {
                            tvTrainType.FindNodeById(trainType.ParentID.ToString()).Nodes.Add(tvn);
                        }
                        catch
                        {
                            tvTrainType.Nodes.Clear();
                            SessionSet.PageMessage = "数据错误!";
                            return;
                        }
                    }
                }
            }

            tvTrainType.DataBind();
            //tvTrainType.ExpandAll();
        }