public static ProductNote AddOrEditNoteForProduct(int productID, string text)
        {
            var currentUserID = LS.CurrentUser.ID;
            var productNote   = new ProductNote();

            productNote = LS.CurrentEntityContext.ProductNotes.FirstOrDefault(x => x.UserID == currentUserID && x.ProductID == productID);

            if (productNote == null)
            {
                productNote = new ProductNote()
                {
                    CreateDate = DateTime.Now,
                    ProductID  = productID,
                    Text       = text,
                    UserID     = currentUserID,
                };

                LS.CurrentEntityContext.ProductNotes.Add(productNote);
            }
            else
            {
                productNote.Text = text;
            }
            LS.CurrentEntityContext.SaveChanges();
            return(productNote);
        }
Exemplo n.º 2
0
        protected void GridView_ProductNotes_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int noteId = Convert.ToInt32(GridView_ProductNotes.DataKeys[e.RowIndex].Values[0]);

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                ProductNote note = dc.ProductNotes.Where(n => n.Id == noteId).Single();
                dc.ProductNotes.DeleteOnSubmit(note);
                dc.SubmitChanges();
            }
            BindGrid();
        }
Exemplo n.º 3
0
        protected void GridView_ProductNotes_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = GridView_ProductNotes.Rows[e.RowIndex];

            int noteId = Convert.ToInt32(GridView_ProductNotes.DataKeys[e.RowIndex].Values[0]);

            string note_str = (row.FindControl("Text_note") as TextBox).Text;
            string date_str = (row.FindControl("Text_effectiveDate") as TextBox).Text;

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                ProductNote note = dc.ProductNotes.Where(n => n.Id == noteId).Single();
                note.Note          = note_str;
                note.EffectiveDate = DateTime.Parse(date_str);

                dc.SubmitChanges();
            }
            GridView_ProductNotes.EditIndex = -1;
            BindGrid();
        }
Exemplo n.º 4
0
        protected void Insert(object sender, EventArgs e)
        {
            if (Text_note.Text == "")
            {
                return;
            }

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                ProductNote note = new ProductNote()
                {
                    Note          = Text_note.Text,
                    EffectiveDate = DateTime.Parse(Text_effectiveDate.Text)
                };

                dc.ProductNotes.InsertOnSubmit(note);
                dc.SubmitChanges();
            }

            BindGrid();
        }