Пример #1
0
        public void SavePrices()
        {
            if (!_IsAllowedChangePrice)
            {
                return;
            }
            if (!IsValidGrid())
            {
                return;
            }

            try
            {
                Application.DoEvents();
                Cursor = Cursors.WaitCursor;

                OptionsGrid.GridView.CloseEditor();
                bsGridControl.EndEdit();

                DS_Product.VW_ProductDataTable table = Zek.Data.DataSetHelper.PackAlternationTypedDataTable <DS_Product.VW_ProductDataTable>(ds.VW_Product);
                Zek.Data.DataSetHelper.RemoveColumns(table, true, table.ProductIDColumn,
                                                     table.NewListPriceColumn,
                                                     table.NewDealerPriceColumn,
                                                     table.NewDiscountPctColumn,
                                                     table.ActionColumn);


                using (var tmpds = new DataSet("root"))
                {
                    tmpds.Tables.Add(table);
                    var id = ProductionManager.AddOrEditProducts(BaseGlobalVariable.UserID, BaseGlobalVariable.ServerDateTime, DatabaseAction.Import, Zek.Data.DataSetHelper.InnerBytesData(tmpds));
                    if (id > 0)
                    {
                        ds.VW_Product.AcceptChanges();
                        XtraMessageBox.Show(this, "ცვლილებები შენახულია.", "ინფორმაცია", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        throw new Exception("id <= 0");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.Show(ex, "ცვლილებები არ შენახულა", MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }