Ejemplo n.º 1
0
        void grid_SelectionChanged(object sender, EventArgs e)
        {
            BaseDat dat = GetCard();

            //Console.WriteLine(dat);
            OnValueChanged(new DatEventArgs(dat));
        }
Ejemplo n.º 2
0
        void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            switch (grid.Columns[e.ColumnIndex].Name)
            {
            case "Icon":
                if (e.Value is int)
                {
                    if (BaseDat.O2Int32(e.Value) <= 0)
                    {
                        e.Value = global::BOF.Properties.Resources.Folder;
                    }
                    else
                    {
                        e.Value = global::BOF.Properties.Resources.textdoc;
                    }
                }
                break;

            case "Code":
                if (e.Value is int && BaseDat.O2Int32(e.Value) == 0)
                {
                    e.Value = "..";
                }
                break;

            case "FP":
                CD dat = cardSet[e.RowIndex] as CD;
                if (dat.ID < 0)
                {
                    e.Value = PathCard2Tree(dat);
                }
                break;
            }
        }
Ejemplo n.º 3
0
        public void WriteDat()
        {
            string text = BaseDat.ToString(_Value, Format);

            WriteText(text, 0, 0);
            txtMain.ForeColor = Color.Black;
        }
Ejemplo n.º 4
0
 public void FireDatValueChanged(BaseDat dat)
 {
     if (DatValueChanged != null)
     {
         DatValueChanged(this, new DatEventArgs(dat));
     }
 }
Ejemplo n.º 5
0
        public void Fill()
        {
            BaseDat old_val = Value;

            Nodes.Clear();
            List <BaseDat> lst = new List <BaseDat>();

            if (setTree != null)
            {
                List <ITreeNDat> tree_lst = ((ISet)setTree).ConvertType <ITreeNDat>();
                tree_lst.Sort(BaseSet.FPComparison);
                lst.AddRange(tree_lst.ConvertAll <BaseDat>(delegate(ITreeNDat tree) { return(tree as BaseDat); }));
            }

            if (setCard != null)
            {
                List <ICardNDat> card_lst = ((ISet)setCard).ConvertType <ICardNDat>();
                card_lst.Sort(BaseSet.FPComparison);
                lst.AddRange(card_lst.ConvertAll <BaseDat>(delegate(ICardNDat card) { return(card as BaseDat); }));
            }

            if (setTree != null)
            {
                FillTree(Nodes, lst, IncludeList, null);
            }
            else
            {
                Fill(Nodes, lst, IncludeList, null);
            }

            Value = old_val;
            //SetState();
        }
Ejemplo n.º 6
0
        public int Save(BaseDat olddat)
        {
            try
            {
                HDWrapper <HD> old = (HDWrapper <HD>)olddat;
                this.DataAccessor.TransactionBegin();
                int ret = 0;
                if (!old.Header.EqualDat(this.Header))
                {
                    ret = Header.Save();
                }

                foreach (Type key in _details.Keys)
                {
                    Details[key].SaveSet(old.Details[key].DetSet);
                }
                this.DataAccessor.TransactionCommit();
                return(ret);
            }
            catch
            {
                this.DataAccessor.TransactionRollback();
                throw;
            }
        }
Ejemplo n.º 7
0
 public void Init(BaseDat dat)
 {
     if (_EntityControl != null)
     {
         _EntityControl.Value = dat;
     }
 }
Ejemplo n.º 8
0
 protected virtual void Edit(BaseDat dat)
 {
     if (_EntityForm == null)
     {
         if (EntitySelected != null)
         {
             EntitySelected(this, new DatEventArgs(dat));
         }
     }
     else
     {
         try
         {
             if (dat != null)
             {
                 _EntityForm.OldValue = dat;
                 _EntityForm.BindControls(EntityForm);
                 //_EntityForm.ShowDialog();
                 if (_EntityForm.ShowDialog() == DialogResult.OK)
                 {
                     ReloadList();
                 }
             }
         }
         catch (Exception exp)
         {
             new ExceptionForm("Внимание", "Не удалось сохранить элемент.\nДля более подробной информации раскройте детали сообщения об ошибке.", exp, MessageBoxIcon.Error).ShowDialog();
         }
     }
 }
        public void ReloadSearch(string search)
        {
            currentParentFP = treeRoot;
            treeSet.FilterApply(delegate(TD dat)
            {
                return(BaseDat.ToString(dat).Contains(search));
            });

            cardSet.LoadFilter.Reset();
            if (currentParentFP != null)
            {
                cardSet.LoadFilter.AddWhere(new FilterTree(currentParentFP, true));
            }
            List <FilterUnitBase> lf = new List <FilterUnitBase>();

            if (PathCard.IsPathCard(search))
            {
                lf.Add(new FilterCard(new PathCard(search)));
            }
            else if (PathTree.IsPathTree(search))
            {
                lf.Add(new FilterTree(search, true));
            }
            lf.Add(new FilterString("Name", '%' + search + '%', true));
            cardSet.LoadFilter.AddWhere(new FilterOR(lf.ToArray()));
            cardSet.Load();

            AddTreeSet(treeSet, cardSet);
            treeSet.FilterReset();
            Refresh();
        }
Ejemplo n.º 10
0
 protected override void OnValueChanged(object sender, EventArgs e)
 {
     if (ddControl != null && Editor != null)
     {
         ddControl.WriteText(BaseDat.ToString(Editor.Value));
     }
     //Console.WriteLine("OnValueChanged");
 }
Ejemplo n.º 11
0
        protected override void OnRowSelected(object sender, EventArgs <int> e)
        {
            BaseDat dat = ddController.GetValue();

            Editor.Value = dat;
            CloseDropDown();
            //Console.WriteLine("OnRowSelected");
        }
Ejemplo n.º 12
0
 protected override void OnValueChanged(object sender, EventArgs e)
 {
     if (ddControl != null && Editor != null)
     {
         ddControl.WriteText(BaseDat.ToString(Editor.Value));
     }
     base.OnValueChanged(sender, e);
 }
Ejemplo n.º 13
0
        void ddController_DatValueSelected(object sender, DatEventArgs e)
        {
            BaseDat dat = e.DatEntity;

            Editor.Value = dat;
            CloseDropDown();
            //Console.WriteLine("ddController_DatValueSelected");
        }
Ejemplo n.º 14
0
        void EntityChanged_Handler(object sender, ValueEventArgs e)
        {
            BaseDat dat = _Grid.Value as BaseDat;

            if (EntityChanged != null)
            {
                EntityChanged(this, new DatEventArgs(dat));
            }
        }
Ejemplo n.º 15
0
 protected virtual void Delete(BaseDat dat)
 {
     if (EntityDeleted != null)
     {
         EntityDeleted(this, new DatEventArgs(dat));
     }
     else
     {
         try
         {
             DataGridViewSelectedRowCollection rows = Grid.SelectedRows;
             if (rows.Count > 1)
             {
                 if (MessageBox.Show(string.Format("Вы действительно хотите удалить {0} строк?", rows.Count), "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                 {
                     foreach (DataGridViewRow row in rows)
                     {
                         BaseDat dt = row.DataBoundItem as BaseDat;
                         if (dt != null)
                         {
                             IDat idat = dt as IDat;
                             if (idat != null && idat.ID > 0)
                             {
                                 dt.Delete();
                             }
                         }
                     }
                     ReloadList();
                 }
             }
             else if (rows.Count == 1)
             {
                 //BaseDat dat = rows[0].DataBoundItem as BaseDat;
                 if (dat != null)
                 {
                     if (dat is IDat && ((IDat)dat).ID > 0)
                     {
                         if (MessageBox.Show(string.Format("Вы действительно хотите удалить \r\n{0}?", dat), "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                         {
                             dat.Delete();
                             ReloadList();
                         }
                     }
                     else
                     {
                         MessageBox.Show(string.Format("Ветки дерева нужно удалять из дерева."), "Удаление", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     }
                 }
             }
         }
         catch (Exception exp)
         {
             new ExceptionForm("Внимание", "Не удалось удалить элемент.\nДля более подробной информации раскройте детали сообщения об ошибке.", exp, MessageBoxIcon.Error).ShowDialog();
         }
     }
 }
Ejemplo n.º 16
0
        private static List <BaseDat> GetChildren(List <BaseDat> lst, BaseDat dat)
        {
            PathTree       path = (dat is ITreeDat) ? ((ITreeDat)dat).FP : null;
            List <BaseDat> ret  = lst.FindAll(delegate(BaseDat dt)
            {
                return(((dt is ITreeDat) && (((ITreeDat)dt).FP.Parent == path)) ||
                       ((dt is ICardDat) && (((ICardDat)dt).FP.Parent == path)));
            });

            return(ret);
        }
Ejemplo n.º 17
0
 public void AddDat(BaseDat dat)
 {
     if (dat is CD)
     {
         Add((CD)dat);
     }
     else if (dat is ITreeDat)
     {
         Add((ITreeDat)dat);
     }
 }
Ejemplo n.º 18
0
        void EntityChanged_Handler(object sender, ValueEventArgs e)
        {
            BaseDat dat = _Grid.Value as BaseDat;

            ButtonPreview.Enabled = (EntityPreviewed != null && dat != null);
            ButtonPrint.Enabled   = (EntityPrinted != null && dat != null);
            if (EntityChanged != null)
            {
                EntityChanged(this, new DatEventArgs(dat));
            }
        }
Ejemplo n.º 19
0
        public override void CopyTo(BaseDat dat)
        {
            HDWrapper <HD> to = (HDWrapper <HD>)dat;

            this.Header.CopyTo(to.Header);

            to.Details = new Dictionary <Type, IDetailsWrapper>();
            foreach (Type key in _details.Keys)
            {
                to.Details.Add(key, (IDetailsWrapper)_details[key].Clone());
            }
        }
Ejemplo n.º 20
0
 public bool FireValueDropDown(BaseDat dat)
 {
     if (_ValueDropDownHandler != null)
     {
         _ValueDropDownHandler(this, new EventArgs <BaseDat>(dat));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 21
0
 public override bool EqualDat(BaseDat dat)
 {
     if (dat != null)
     {
         HDWrapper <HD> x = (HDWrapper <HD>)dat;
         return(CompareDat(Header, x.Header));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 22
0
 public bool FireValueOpenDialog(BaseDat dat)
 {
     if (_ValueOpenDialogHandler != null)
     {
         _ValueOpenDialogHandler(this, new EventArgs <BaseDat>(dat));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 23
0
 protected override void Delete(BaseDat dat)
 {
     try
     {
         //BaseDat dat = (BaseDat)Grid.Value;
         DS set = ((DS)Grid.DataSource);
         set.Remove(dat);
         Grid.SetDataSource(set);
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Common.ExMessage(Ex), "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public virtual void SelectValue(BaseDat Value) // Добавил Медведев.
        {
            int     index = SelectedIndex;
            BaseSet s     = DataSource as BaseSet;

            if (Value == null || DataSource == null)
            {
                return;
            }

            index = s.IndexOf(Value);
            if (index >= 0)
            {
                SelectedIndex = index;
            }
        }
Ejemplo n.º 25
0
        public static IDAOFilter CreateIDictDatFilter <T>(IDataAccess accessor, ArrayList args) where T : BaseDat <T>//, new()
        {
            IDAOFilter filter = accessor.NewFilter();

            if (args.Count == 1)
            {
                if (args[0] is string)
                {
                    filter.AddWhere(new FilterString(BaseDat <T> .GetFieldName("SCode"), (string)args[0]));
                    return(filter);
                }
                else if (args[0] is int)
                {
                    return(CreateIDatFilter <T>(accessor, args));
                }
            }
            throw new ArgumentException("ќшибка формировани¤ IDictDatFilter по заданным аргументам", args2string(args));
        }
Ejemplo n.º 26
0
 void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (Grid.Columns[e.ColumnIndex].Name == "Icon")
     {
         if ((e.Value is int) && (BaseDat.O2Int32(e.Value) < 0))
         {
             e.Value = global::BOF.Properties.Resources.Folder;
         }
         else if ((e.Value is int) && (BaseDat.O2Int32(e.Value) == 0))
         {
             e.Value = global::BOF.Properties.Resources.Folder;
         }
         else
         {
             e.Value = global::BOF.Properties.Resources.document;
         }
     }
 }
Ejemplo n.º 27
0
        protected virtual void Delete()
        {
            BaseDat dat = (BaseDat)_Grid.Value;

            try
            {
                if (dat != null)
                {
                    if (MessageBox.Show(string.Format("Вы действительно хотите удалить \r\n{0}?", dat), "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        _header.DetSet.Remove(dat);
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Common.ExMessage(Ex), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 28
0
        public static IDAOFilter CreateICardDatFilter <T>(IDataAccess accessor, ArrayList args) where T : BaseDat <T>//, new()
        {
            IDAOFilter filter = accessor.NewFilter();

            if (args.Count == 1)
            {
                if (args[0] is int)
                {
                    return(CreateIDatFilter <T>(accessor, args));
                }
                else if (args[0] is PathCard)
                {
                    filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), ((PathCard)args[0]).Parent.ToString()), new FilterID(BaseDat <T> .GetFieldName("Code"), ((PathCard)args[0]).Code)));
                    return(filter);
                }
                else if (args[0] is string)
                {
                    string argVal = args[0].ToString();
                    if (PathCard.IsPathCard(argVal))
                    {
                        filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), new PathCard(argVal).Parent.ToString()), new FilterID(BaseDat <T> .GetFieldName("Code"), new PathCard(argVal).Code)));
                        return(filter);
                    }
                }
            }
            else if (args.Count == 2)
            {
                //if (args[0] is PathTree && args[1] is int)
                if (PathTree.IsPathTree(args[0].ToString()) && args[1] is int)
                {
                    filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), ((PathTree)args[0]).ToString()), new FilterID(BaseDat <T> .GetFieldName("Code"), (int)args[0])));
                    return(filter);
                }
                else if (args[0] is string && args[1] is int)
                {
                    filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), (string)args[0]), new FilterID(BaseDat <T> .GetFieldName("Code"), (int)args[0])));
                    return(filter);
                }
            }
            throw new ArgumentException("ќшибка формировани¤ ICardDatFilter по заданным аргументам", args2string(args));
        }
Ejemplo n.º 29
0
 void txtMain_TextChanged(object sender, EventArgs e)
 {
     //            Console.WriteLine("Editor Text=" + Text);
     if (BaseDat.ToString(Value, Format) != Text)
     {
         txtMain.ForeColor = Color.Brown;
         if (_Value != null)
         {
             _Value = null;
             FireValueChanged();
         }
     }
     else
     {
         txtMain.ForeColor = Color.Black;
     }
     if (TextChanged != null)
     {
         TextChanged(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 30
0
 protected override void Edit(BaseDat dat)
 {
     try
     {
         base.Edit(dat);
         //EntityForm.CanSave = false;
         //EntityForm.OldValue = dat;
         //EntityForm.BindControls(EntityForm);
         //if (EntityForm.ShowDialog() == DialogResult.OK)
         //{
         //    DS set = ((DS)Grid.DataSource);
         //    int index = set.IndexOf(dat);
         //    set[index] = EntityForm.OldValue;
         //    Grid.SetDataSource(set);
         //}
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Common.ExMessage(Ex), "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }