예제 #1
0
        private void AssignNode(string currentCode, string itemCode, string cat, int sort)
        {
            var parentNode = (from amen in context.AMENITY where amen.CODE == currentCode select new { amen.PARENT_CODE, amen.SORT_ORDER }).FirstOrDefault();
            int sorts      = (int)parentNode.SORT_ORDER;

            if ((from amenRec in context.AMENASSGN where amenRec.CODE == parentNode.PARENT_CODE && amenRec.SVC_CODE == itemCode && amenRec.SVC_TYPE == sVC_TYPEComboBoxEdit.Text && amenRec.SVC_CAT == cat select amenRec).Count() == 0)
            {
                //int? sort = Convert.ToInt32(treeList1.FocusedNode.RootNode.GetDisplayText(colSORT_ORDER));
                // string newParent = (from amen in context.AMENITY where amen.CODE == parentNode select new { amen.PARENT_CODE }).First().ToString();
                //(string amenCode, string item, string category, int? sortOrder)
                //AddNode(currentCode, itemCode, cat, sort);
                AssignNode(parentNode.PARENT_CODE, itemCode, cat, sorts);
            }

            AMENASSGN rec = new FlexModel.AMENASSGN();

            rec.CODE       = currentCode;
            rec.SVC_CODE   = itemCode;
            rec.SVC_TYPE   = sVC_TYPEComboBoxEdit.Text;
            rec.SVC_CAT    = cat;
            rec.SVC_ROOM   = string.Empty;
            rec.SORT_ORDER = sort;
            rec.ITEM2      = string.Empty;
            rec.ITEM1      = string.Empty;
            if ((from amenRec in context.AMENASSGN where amenRec.CODE == rec.CODE && amenRec.SVC_CODE == rec.SVC_CODE && amenRec.SVC_TYPE == rec.SVC_TYPE && amenRec.SVC_CAT == rec.SVC_CAT && amenRec.SVC_ROOM == rec.SVC_ROOM select amenRec).Count() == 0)
            {
                context.AMENASSGN.AddObject(rec);
                modifiedRecs.Add(rec.CODE);
                modifiedSvcCode = rec.SVC_CODE;
            }
            else
            {
                // MessageBox.Show("You are attempting to add a an amenity that has already been added.");
                // return;
            }
            context.SaveChanges();


            // int? order = Convert.ToInt32(treeList1.FocusedNode.GetDisplayText(colSORT_ORDER));

            //return true;
            //return AssignNode(currentCode, itemCode, cat, sort);
        }
예제 #2
0
        private void AddNode(string amenCode, string item, string category, int?sortOrder)
        {
            AMENASSGN rec = new FlexModel.AMENASSGN();

            rec.CODE       = amenCode;
            rec.SVC_CODE   = item;
            rec.SVC_TYPE   = sVC_TYPEComboBoxEdit.Text;
            rec.SVC_CAT    = category;
            rec.SVC_ROOM   = string.Empty;
            rec.SORT_ORDER = sortOrder;
            rec.ITEM2      = string.Empty;
            rec.ITEM1      = string.Empty;
            if ((from amenRec in context.AMENASSGN where amenRec.CODE == rec.CODE && amenRec.SVC_CODE == rec.SVC_CODE && amenRec.SVC_TYPE == rec.SVC_TYPE && amenRec.SVC_CAT == rec.SVC_CAT && amenRec.SVC_ROOM == rec.SVC_ROOM select amenRec).Count() == 0)
            {
                context.AMENASSGN.AddObject(rec);
            }
            else
            {
                MessageBox.Show("You are attempting to add a an amenity that has already been added.");
                return;
            }
            context.SaveChanges();
        }