示例#1
0
 public void addNøkkelord(ItemKeyword item)
 {
     if (ModelState.IsValid)
     {
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             db.ItemKeywords.Add(item);
             db.SaveChanges();
         }
     }
 }
示例#2
0
        // This is the Insert method to insert the entered ItemKeyword item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new Kampanjer.Models.ItemKeyword();

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.ItemKeywords.Add(item);
                    _db.SaveChanges();

                    Response.Redirect("Default");
                }
            }
        }
示例#3
0
        protected void PasteToGridView(object sender, EventArgs e)
        {
            // Create a NumberFormatInfo object and set some of its properties.
            NumberFormatInfo provider = new NumberFormatInfo();
            provider.NumberDecimalSeparator = ",";
            var item = new ItemKeyword();
            DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[2] {
                new DataColumn("VendorItemNo", typeof(string)),
                new DataColumn("ItemNo", typeof(string))});
            string copiedContent = Request.Form[txtCopied.UniqueID];

            int Keywordnr;
            Keywordnr = GetMaxKeywordID();

            foreach (string row in copiedContent.Split('\n'))
            {
                if (!string.IsNullOrEmpty(row))
                {
                    dt.Rows.Add();
                    int i = 0;
                    foreach (string cell in row.Split('\t'))
                    {
                        dt.Rows[dt.Rows.Count - 1][i] = cell;
                        i++;
                    }
                    item.VendorItemNo = dt.Rows[dt.Rows.Count - 1][0].ToString();
                    item.ItemNo  = dt.Rows[dt.Rows.Count - 1][1].ToString();
                    item.KeywordID = Keywordnr;
                    addNøkkelord(item);
                }
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
            txtCopied.Text = "";
        }