Ejemplo n.º 1
0
        private ICUDHandler GetController(int type, CustomNode node)
        {
            switch (type)
            {
            case CustomNode.DEAL: return(new DealsHandler(node));

            case CustomNode.PRODUCT: return(new ProductsHandler(node));

            case CustomNode.SERVICE: return(new ServicesHandler(node));

            default: throw new ArgumentException("Sth wrong happend with node type");
            }
        }
Ejemplo n.º 2
0
        public void Remove(object sender, EventArgs e)
        {
            MenuItem   item = sender as MenuItem;
            CustomMenu menu = item.Parent as CustomMenu;
            CustomNode node = menu.SourceNode as CustomNode;

            if (node == null)
            {
                throw new ArgumentException("Controller.Remove() - sender is not a CustomNode");
            }

            ICUDHandler handler = GetController(node.Type, node);

            handler.Remove();
        }
Ejemplo n.º 3
0
        public void Add()
        {
            QueriesTableAdapter queries = new QueriesTableAdapter();
            int highCopies = Convert.ToInt32(queries.GetNumberOfCopiesInProductSaleById(Node.Id));

            ServiceForm form = new ServiceForm(highCopies);

            form.ShowDialog();

            int     service;
            int     copies;
            decimal cost;

            if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                service = form.Service;
                copies  = form.Copies;
                cost    = form.Cost;
            }
            else
            {
                return;
            }

            int id = InsertIntoServSales(Node.Id, service, copies, cost);

            servShowAdapter.FillById(servShow, id);
            UpdateParentDeal(true);

            if (servShow.Rows.Count != 1)
            {
                throw new Exception();
            }

            var        row     = servShow.Rows[0];
            CustomNode newNode =
                new CustomNode(text: Convert.ToString(row[2]), type: CustomNode.SERVICE, id: Convert.ToInt32(row[1]),
                               pId: Convert.ToInt32(row[0]));

            newNode.ContextMenu =
                new CustomMenu(new Controller().GetServiceMenuItems(), newNode);

            Node.Nodes.Add(newNode);
        }
Ejemplo n.º 4
0
        public void Add()
        {
            ProductForm form = new ProductForm();

            form.ShowDialog();

            int     product;
            int     copies;
            decimal cost;

            if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                product = form.Product;
                copies  = form.Copies;
                cost    = form.Cost;
            }
            else
            {
                return;
            }

            int id = InsertIntoProdSales(Node.Id, product, copies, cost);

            prodShowAdapter.FillByPSaleId(prodShow, id);
            UpdateParentDeal(true);

            if (prodShow.Rows.Count != 1)
            {
                throw new Exception();
            }

            var        row     = prodShow.Rows[0];
            CustomNode newNode =
                new CustomNode(text: Convert.ToString(row[2]), type: CustomNode.PRODUCT, id: Convert.ToInt32(row[1]),
                               pId: Convert.ToInt32(row[0]));

            newNode.ContextMenu =
                new CustomMenu(new Controller().GetProductsMenuItems(), newNode);


            Node.Nodes.Add(newNode);
        }
Ejemplo n.º 5
0
        private void LoadNodes()
        {
            SDTreeViewDataSet.ShowDealsDataTable deals =
                new SDTreeViewDataSet.ShowDealsDataTable();
            SDTreeViewDataSet.ShowProdSalesDataTable prods =
                new SDTreeViewDataSet.ShowProdSalesDataTable();
            SDTreeViewDataSet.ShowServSalesDataTable servs =
                new SDTreeViewDataSet.ShowServSalesDataTable();

            dealsAdapter.Fill(deals);

            foreach (var deal in deals)
            {
                CustomNode dealNode =
                    new CustomNode(Convert.ToString(deal[1]), CustomNode.DEAL, Convert.ToInt32(deal[0]));
                dealNode.ContextMenu = new CustomMenu(_controller.GetDealsMenuItems(), dealNode);

                treeView.Nodes.Add(dealNode);

                prodsAdapter.FillBy(prods, dealNode.Id);
                foreach (var prod in prods)
                {
                    CustomNode prodNode
                        = new CustomNode(Convert.ToString(prod[2]), CustomNode.PRODUCT, Convert.ToInt32(prod[1]), Convert.ToInt32(prod[0]));
                    prodNode.ContextMenu = new CustomMenu(_controller.GetProductsMenuItems(), prodNode);

                    dealNode.Nodes.Add(prodNode);

                    servsAdapter.FillBy(servs, prodNode.Id);
                    foreach (var serv in servs)
                    {
                        CustomNode servNode =
                            new CustomNode(Convert.ToString(serv[2]), CustomNode.SERVICE, Convert.ToInt32(serv[1]), Convert.ToInt32(serv[0]));
                        servNode.ContextMenu = new CustomMenu(_controller.GetServiceMenuItems(), servNode);

                        prodNode.Nodes.Add(servNode);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void Add()
        {
            DealForm form = new DealForm();

            form.ShowDialog();

            int      client;
            DateTime date;

            if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                client = form.Client;
                date   = form.DateSign;
            }
            else
            {
                return;
            }

            int id = InsertIntoDeals(client, date, 0);

            dealsShowAdapter.FillBy(dealsShow, id);

            if (dealsShow.Rows.Count != 1)
            {
                throw new Exception("Sth gone wrong with inserting new deal");
            }

            var        row     = dealsShow.Rows[0];
            CustomNode newNode =
                new CustomNode(text: Convert.ToString(row[1]), type: CustomNode.DEAL, id: Convert.ToInt32(row[0]));

            newNode.ContextMenu =
                new CustomMenu(new Controller().GetDealsMenuItems(), newNode);

            View.Nodes.Add(newNode);
        }
Ejemplo n.º 7
0
 public ServicesHandler(CustomNode node) : this()
 {
     Node = node;
 }
Ejemplo n.º 8
0
 public ProductsHandler(CustomNode node) : this()
 {
     Node = node;
 }
Ejemplo n.º 9
0
 public DealsHandler(CustomNode node) : this()
 {
     Node = node;
 }