public winContractorsMediaRowManipulator(RowManipulatorContainer container)
        {
            InitializeComponent();

            this.action          = container.action;
            this.cm              = (ContractorsMedia)container.itemSel;
            DataGridMergeVirtual = container.DataGridMergeVirtual;
            DataGridChanged      = container.DataGridChanged;
            this.btnSave         = container.btnSave;

            foreach (Leads l in Context.ctx.Leads)
            {
                this.cmbLeads.Items.Add(string.Format("({0}) {1}{2} {3}",
                                                      l.id,
                                                      Utils.Denull(l.name_last),
                                                      l.name_first,
                                                      Utils.Denull(l.patronymic)));
            }

            this.cmbLeads.SelectedIndex = 0;
            this.Title          = "media contractor";
            this.btnDone.Margin = new Thickness(0, 7, 0, 7);

            if (this.action == Actions.Addition)
            {
                this.Title           = this.Title.Insert(0, "Adding a new ");
                this.btnDone.Content = "Add";
                this.btnDone.Width   = 50;
            }
            else if (this.action == Actions.Modification)
            {
                if (this.cm == null)
                {
                    throw new NullReferenceException();
                }

                this.txtFirstName.Text  = this.cm.name_first;
                this.txtLastName.Text   = this.cm.name_last;
                this.txtPatronymic.Text = this.cm.patronymic;
                this.txtEmail.Text      = this.cm.email;
                this.txtPhone.Text      = this.cm.phone;
                this.txtPrice.Text      = this.cm.price + "";
                Utils.SetComboBoxItem(this.cmbLeads, (long)this.cm.lid);

                this.Title           = this.Title.Insert(0, "Modification of the ");
                this.btnDone.Content = "Modify";
                this.btnDone.Width   = 65;
            }

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.ResizeMode            = ResizeMode.CanMinimize;
            this.UseLayoutRounding     = true;
        }
Exemplo n.º 2
0
        void InfoMenuItem_Click(object sender, RoutedEventArgs _)
        {
            foreach (object item in this.dataGrid.SelectedItems)
            {
                Dictionary <string, object> names;

                if (this.entityInstanceName == EntityInstanceNames.Employee)
                {
                    Employees e = item as Employees;

                    names = new Dictionary <string, object>()
                    {
                        { "Id", e.id },
                        { "Full name", string.Format("{0} {1} {2}",
                                                     e.name_last,
                                                     e.name_first,
                                                     Utils.Denull(e.patronymic)) },
                        { "Email", e.email },
                        { "Phone", e.phone },
                        { "Department", e.Positions.department },
                        { "Position", e.Positions.position },
                        { "Date of registration", e._reg_date }
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.Lead)
                {
                    Leads l = item as Leads;

                    names = new Dictionary <string, object>()
                    {
                        { "Id", l.id },
                        { "Full name", string.Format("{0}{1} {2}",
                                                     Utils.Denull(l.name_last),
                                                     l.name_first,
                                                     Utils.Denull(l.patronymic)) },
                        { "Email", l.email },
                        { "Phone", l.phone },
                        { "Promotional time", l.prom_time },
                        { "Date of completion", l._appeal_date }
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.Group)
                {
                    Groups    g  = item as Groups;
                    Employees p  = Context.ctx.Employees.FirstOrDefault(i => i.id == g.pid);
                    Employees ad = Context.ctx.Employees.FirstOrDefault(i => i.id == g.adid);
                    Employees gs = Context.ctx.Employees.FirstOrDefault(i => i.id == g.gsid);
                    Employees c  = Context.ctx.Employees.FirstOrDefault(i => i.id == g.cid);
                    Leads     l  = Context.ctx.Leads.FirstOrDefault(i => i.id == g.lid);

                    names = new Dictionary <string, object>()
                    {
                        { "Id", g.id },
                        { "Producer", string.Format("({0}) {1} {2} {3}",
                                                    p.id,
                                                    p.name_last,
                                                    p.name_first,
                                                    Utils.Denull(p.patronymic)) },
                        { "Artist designer", string.Format("({0}) {1} {2} {3}",
                                                           ad.id,
                                                           ad.name_last,
                                                           ad.name_first,
                                                           Utils.Denull(ad.patronymic)) },
                        { "Graphics specialist", string.Format("({0}) {1} {2} {3}",
                                                               gs.id,
                                                               gs.name_last,
                                                               gs.name_first,
                                                               Utils.Denull(gs.patronymic)) },
                        { "Copywriter", string.Format("({0}) {1} {2} {3}",
                                                      c.id,
                                                      c.name_last,
                                                      c.name_first,
                                                      Utils.Denull(c.patronymic)) },
                        { "Lead", string.Format("({0}) {1}{2} {3}",
                                                l.id,
                                                Utils.Denull(l.name_last),
                                                l.name_first,
                                                Utils.Denull(l.patronymic)) },
                        { "Date of completion", g.Campaigns._comp_date }
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.Campaign)
                {
                    Campaigns c = item as Campaigns;

                    names = new Dictionary <string, object>()
                    {
                        { "Id", c.gid },
                        { "Completion date", c._comp_date },
                        { "Starting budget", c.budget_starting },
                        { "Contractors budget", c.budget_contractors }
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.OrdReq)
                {
                    OrdReqs   r = item as OrdReqs;
                    Employees p = Context.ctx.Employees.FirstOrDefault(i => i.id == r.pid);
                    Leads     l = Context.ctx.Leads.FirstOrDefault(i => i.id == r.lid);

                    names = new Dictionary <string, object>()
                    {
                        { "Id", r.id },
                        { "Product name", r.prod_name },
                        { "Product quantity", r.prod_quantity },
                        { "Period date", r._period_date },
                        { "Producer", string.Format("({0}) {1} {2} {3}",
                                                    p.id,
                                                    p.name_last,
                                                    p.name_first,
                                                    Utils.Denull(p.patronymic)) },
                        { "Lead", string.Format("({0}) {1}{2} {3}",
                                                l.id,
                                                Utils.Denull(l.name_last),
                                                l.name_first,
                                                Utils.Denull(l.patronymic)) },
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.ContractorMedia)
                {
                    ContractorsMedia cm = item as ContractorsMedia;
                    Leads            l  = Context.ctx.Leads.FirstOrDefault(i => i.id == cm.lid);

                    names = new Dictionary <string, object>()
                    {
                        { "Id", cm.id },
                        { "Full name", string.Format("{0}{1} {2}",
                                                     Utils.Denull(cm.name_last),
                                                     cm.name_first,
                                                     Utils.Denull(cm.patronymic)) },
                        { "Email", cm.email },
                        { "Phone", cm.phone },
                        { "Price", cm._price },
                        { "Lead", string.Format("({0}) {1}{2} {3}",
                                                l.id,
                                                Utils.Denull(l.name_last),
                                                l.name_first,
                                                Utils.Denull(l.patronymic)) }
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.ContractorProduction)
                {
                    ContractorsProduction cp = item as ContractorsProduction;
                    OrdReqs   r = Context.ctx.OrdReqs.FirstOrDefault(i => i.id == cp.ordid);
                    Employees p = Context.ctx.Employees.FirstOrDefault(i => i.id == r.pid);
                    Leads     l = Context.ctx.Leads.FirstOrDefault(i => i.id == r.lid);

                    names = new Dictionary <string, object>()
                    {
                        { "Id", cp.ordid },
                        { "Full name", string.Format("{0}{1} {2}",
                                                     Utils.Denull(p.name_last),
                                                     p.name_first,
                                                     Utils.Denull(p.patronymic)) },
                        { "Email", cp.email },
                        { "Phone", cp.phone },
                        { "Product name", r.prod_name },
                        { "Product quantity", r.prod_quantity },
                        { "Price", cp._price },
                        { "Period date", r._period_date },
                        { "Producer", string.Format("({0}) {1} {2} {3}",
                                                    p.id,
                                                    p.name_last,
                                                    p.name_first,
                                                    Utils.Denull(p.patronymic)) },
                        { "Lead", string.Format("({0}) {1}{2} {3}",
                                                l.id,
                                                Utils.Denull(l.name_last),
                                                l.name_first,
                                                Utils.Denull(l.patronymic)) }
                    };
                }
                else if (this.entityInstanceName == EntityInstanceNames.Stock)
                {
                    Stock     s = item as Stock;
                    OrdReqs   r = Context.ctx.OrdReqs.FirstOrDefault(i => i.id == s.ordid);
                    Employees p = Context.ctx.Employees.FirstOrDefault(i => i.id == r.pid);
                    Leads     l = Context.ctx.Leads.FirstOrDefault(i => i.id == r.lid);

                    names = new Dictionary <string, object>()
                    {
                        { "Id", s.ordid },
                        { "Product name", r.prod_name },
                        { "Product quantity", r.prod_quantity },
                        { "Period date", r._period_date },
                        { "Producer", string.Format("({0}) {1} {2} {3}",
                                                    p.id,
                                                    p.name_last,
                                                    p.name_first,
                                                    Utils.Denull(p.patronymic)) },
                        { "Lead", string.Format("({0}) {1}{2} {3}",
                                                l.id,
                                                Utils.Denull(l.name_last),
                                                l.name_first,
                                                Utils.Denull(l.patronymic)) },
                        { "Date of receiving", s._rec_date }
                    };
                }
                else
                {
                    return;
                }

                new winInfoTable(names, this.entityInstanceName).Show();
            }
        }