Пример #1
0
        internal static String Save(DB.ITM_InventorySupplier entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityInventoryContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityInventoryContext.ITM_InventorySupplier.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Пример #2
0
        private void grvSuppliers_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (colPrimarySupplier == e.Column)
            {
                DB.ITM_InventorySupplier currentRow = (DB.ITM_InventorySupplier)grvSuppliers.GetFocusedRow();
                if (currentRow == null)
                {
                    return;
                }

                //If you clikced on the current Primary Supplier
                if (!currentRow.PrimarySupplier.Value && itmInventorySupplier.Where(n => n.PrimarySupplier == true).Count() == 1)
                {
                    currentRow.PrimarySupplier = true;
                }
                else
                {
                    itmInventorySupplier.ForEach(n => n.PrimarySupplier = false);
                    currentRow.PrimarySupplier = Convert.ToBoolean(e.Value);
                }

                grdSuppliers.RefreshDataSource();
            }
        }