Пример #1
0
        private void btnEditCss_Click(object sender, EventArgs e)
        {
            // MessageBox.Show("Not implemented");
            CssCode courrent = lbCssCodes.SelectedItem as CssCode;

            formCreateNewCss formCss = new formCreateNewCss(courrent.Function, courrent.Code);

            if (formCss.ShowDialog() == DialogResult.OK)
            {
                CssCode modified = formCss.GetCssCode();
                try
                {
                    using (DBEntities context = new DBEntities())
                    {
                        List <CssCode> cssCodes = context.CssCodes.ToList();
                        foreach (CssCode c in cssCodes)
                        {
                            if (c.Id == courrent.Id)
                            {
                                c.Function = modified.Function;
                                c.Code     = modified.Code;

                                context.SaveChanges();
                                this.refreshCssCodes();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("btnEditCss_click\n\n" + ex.ToString());
                }
            }
        }
Пример #2
0
        private void btnAddCssCode_Click(object sender, EventArgs e)
        {
            Project p = lbProjects.SelectedItem as Project;

            if (p == null)
            {
                MessageBox.Show("Select project first, than you can add .css");
                return;
            }

            int projectId = p.Id;

            formCreateNewCss newCssCodeForm = new formCreateNewCss();

            if (newCssCodeForm.ShowDialog() == DialogResult.OK)
            {
                CssCode code = newCssCodeForm.GetCssCode();
                code.ProjectId = projectId;

                using (DBEntities context = new DBEntities())
                {
                    context.CssCodes.Add(code);
                    context.SaveChanges();
                }

                this.refreshCssCodes();
            }
        }