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()); } } }
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(); } }
private void importCssCodesFromBackup(string path) { try { String input = System.IO.File.ReadAllText(path + @"/cssCodes.txt"); String[] parts = Regex.Split(input, "EOL\n"); foreach (string part in parts) { if (part.Length > 0) { string[] actualData = Regex.Split(part, "____"); CssCode css = new CssCode(); css.Id = Int32.Parse(actualData[0]); css.ProjectId = Int32.Parse(actualData[1]); css.Function = actualData[2]; css.Code = actualData[3]; using (DBEntities context = new DBEntities()) { context.CssCodes.Add(css); context.SaveChanges(); } } } } catch (Exception ex) { MessageBox.Show("importCssCodesFromBackup\n\n" + ex.ToString()); } }
private void addForm() { cssCode = new CssCode(); //cssCode.SetCode(rbCode.Text); //cssCode.SetDescription(tbFunction.Text); cssCode.Function = tbFunction.Text.Trim(); cssCode.Code = rbCode.Text; DialogResult = DialogResult.OK; }
private void lbCssCodes_SelectedIndexChanged(object sender, EventArgs e) { CssCode c = lbCssCodes.SelectedItem as CssCode; if (c != null) { rtbCssCodeDetails.Text = c.Code; btnEditCss.Enabled = true; } else { rtbCssCodeDetails.Clear(); btnEditCss.Enabled = false; } }