Beispiel #1
0
        private void btProductReport_Click(object sender, EventArgs e)
        {
            MDataSet.OrdersRow _ordsRow = this.gridViewOrdersAll.GetDataRow(this.gridViewOrdersAll.FocusedRowHandle) as MDataSet.OrdersRow;

            if (_ordsRow != null)
            {
                (this.ParentForm as MainForm).ProductReport(_ordsRow.ProductRef);
            }
        }
Beispiel #2
0
        private void btAddOrders_Click(object sender, EventArgs e)
        {
            int Ref;

            this.ordersBindingSource.EndEdit();

            MDataSet.OrdersRow ordrow = (this.ordersBindingSource.Current as DataRowView).Row as MDataSet.OrdersRow;

            if (ordrow != null)
            {
                Ref = ordrow.TradePupletRef;
            }
            else
            {
                Ref = 1;
            }



            this.btSave_Click(sender, e);



            this.grid.EmbeddedNavigator.Buttons.Append.DoClick();



            MDataSet.OrdersRow row = (this.ordersBindingSource.Current as DataRowView).Row as MDataSet.OrdersRow;

            row.TradePupletRef = Ref;
            row.Reserved       = 0;

            FormDialog formDialog = new FormDialog();

            formDialog.Text         = "Добавить новый заказ ";
            formDialog.AcceptButton = null;

            OrderAdd orderAdd = new OrderAdd(row, this.ParentForm as MainForm);

            formDialog.panel.Controls.Add(orderAdd);

            if (formDialog.ShowDialog(this) == DialogResult.OK)
            {
                this.grid.EmbeddedNavigator.Buttons.EndEdit.DoClick();

                this.ordersBindingSource.EndEdit();

                this.btSave_Click(sender, e);
            }
            else
            {
                this.ordersBindingSource.CancelEdit();
                this.mDataSet.Orders.RejectChanges();
            }

            this.grid.Refresh();
        }
Beispiel #3
0
        private void gridViewOrders_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                MDataSet.OrdersRow _ordsRow = this.gridViewOrders.GetDataRow(this.gridViewOrders.FocusedRowHandle) as MDataSet.OrdersRow;



                if (_ordsRow == null)
                {
                    return;
                }

                if (_ordsRow.Reserved > 0)
                {
                    MessageBox.Show("Этот товар уже для вас зарезервирован: " + _ordsRow.Reserved.ToString());

                    return;
                }

                if (_ordsRow.QuantityNow > 0)
                {
                    MessageBox.Show("Этот товар вам уже отгружен! ");

                    return;
                }


                if (_ordsRow.isClose)
                {
                    MessageBox.Show("Заявка была закрыта : " + _ordsRow.AuthorLastModif);

                    return;
                }


                DialogQuantityOrder _DialogQuantityOrder = new DialogQuantityOrder(_ordsRow.ProductRow, _ordsRow);

                if (_DialogQuantityOrder.ShowDialog(this) == DialogResult.OK)
                {
                    this.SaveOrdersRow(_ordsRow);
                }
                else
                {
                    _ordsRow.RejectChanges();
                }
            }
            catch (Exception err)

            {
                MessageBox.Show(err.Message);

                MainForm.Log("gridViewOrders_DoubleClick" + err.Message);
            }
        }
Beispiel #4
0
        private void gridViewOrdersAll_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                MDataSet.OrdersRow _ordsRow = (sender as GridView).GetDataRow(e.RowHandle) as MDataSet.OrdersRow;

                if (_ordsRow == null)
                {
                    return;
                }


                if (((_ordsRow.QuantityNow > 0) | (_ordsRow.Reserved > 0)) & !(_ordsRow.QuantityNow == _ordsRow.Quantity))
                {
                    e.Appearance.Font      = e.Cache.GetFont(e.Appearance.Font, FontStyle.Italic);
                    e.Appearance.BackColor = Color.LightGreen;
                }
                else
                {
                    if ((_ordsRow.QuantityNow == _ordsRow.Quantity) | (_ordsRow.isClose))
                    {
                        e.Appearance.Font      = e.Cache.GetFont(e.Appearance.Font, FontStyle.Italic);
                        e.Appearance.ForeColor = Color.Gray;
                    }
                }


                if (((_ordsRow.Quantity > _ordsRow.QuantityNow)) & _ordsRow.isClose)
                {
                    e.Appearance.Font      = e.Cache.GetFont(e.Appearance.Font, FontStyle.Strikeout);
                    e.Appearance.BackColor = Color.LightGray;
                }

                if (_ordsRow.RowState != DataRowState.Unchanged)
                {
                    e.Appearance.BackColor = Color.LightCoral;
                }
            }
            catch
            {
                MessageBox.Show("Ошибка прорисовки!");
            }
        }
Beispiel #5
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            MDataSet.ProductRow _prod = this.gridViewProd.GetDataRow(this.gridViewProd.FocusedRowHandle) as MDataSet.ProductRow;

            if (_prod != null)
            {
                try
                {
                    MDataSet.OrdersRow _ord = (this.ordersBindingSource.AddNew() as DataRowView).Row as MDataSet.OrdersRow;

                    DialogQuantityOrder _DialogQuantityOrder = new DialogQuantityOrder(_prod, _ord);

                    if (_DialogQuantityOrder.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            this.ordersBindingSource.EndEdit();

                            this.ordersBindingSource.ResetBindings(false);

                            MainForm.Log(" this.ordersBindingSource.EndEdit успешно");
                        }
                        catch (Exception err)
                        {
                            MessageBox.Show(err.Message);

                            MainForm.Log(err.Message);
                        }
                    }
                    else
                    {
                        this.ordersBindingSource.CancelEdit();
                    }
                }
                catch (Exception err)

                {
                    MessageBox.Show(err.Message);

                    MainForm.Log("btAdd_Click" + err.Message);
                }
            }
        }
Beispiel #6
0
        private bool SaveOrdersRow(MDataSet.OrdersRow row)
        {
            try
            {
                this.ordersTableAdapter.Update(row);
            }

            catch (Exception err)
            {
                MessageBox.Show("Не удалось сохранить данные!");
                MessageBox.Show(err.Message);
                return(false);
            }
            finally
            {
            }

            return(true);
        }
Beispiel #7
0
        private void ordersBindingSource_PositionChanged(object sender, EventArgs e)
        {
            try
            {
                if (productBindingSource.Current == null)
                {
                    return;
                }

                MDataSet.ProductRow _product = (productBindingSource.Current as DataRowView).Row as MDataSet.ProductRow;


                if (ordersBindingSource.Current == null)
                {
                    return;
                }


                MDataSet.OrdersRow _orders = (ordersBindingSource.Current as DataRowView).Row as MDataSet.OrdersRow;

                if (_orders.ProductRow == null)
                {
                    return;
                }

                if ((_orders == null) | (_product == null))
                {
                    return;
                }

                if (_product.ID != _orders.ProductRef)
                {
                    this.productBindingSource.Position = this.productBindingSource.Find("Id", _orders.ProductRef);
                }
                MainForm.Log(" rdersBindingSource_PositionChanged успешно");
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                MainForm.Log(err.Message);
            }
        }
Beispiel #8
0
        private void gridViewOrders_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                MDataSet.OrdersRow _ordsRow = this.gridViewOrders.GetDataRow(e.RowHandle) as MDataSet.OrdersRow;

                if (_ordsRow == null)
                {
                    return;
                }
                ;


                if ((_ordsRow.QuantityNow > 0) | (_ordsRow.Reserved > 0))
                {
                    e.Appearance.Font      = e.Cache.GetFont(e.Appearance.Font, FontStyle.Italic);
                    e.Appearance.BackColor = Color.LightGreen;
                }
                else
                {
                    if (_ordsRow.isClose)
                    {
                        e.Appearance.Font      = e.Cache.GetFont(e.Appearance.Font, FontStyle.Italic);
                        e.Appearance.ForeColor = Color.Gray;
                    }
                }

                if (((_ordsRow.Quantity > _ordsRow.QuantityNow)) & _ordsRow.isClose)
                {
                    e.Appearance.Font      = e.Cache.GetFont(e.Appearance.Font, FontStyle.Strikeout);
                    e.Appearance.BackColor = Color.LightGray;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);

                MainForm.Log("gridViewOrders_CustomDrawCell" + err.Message);

                return;
            }
        }
Beispiel #9
0
        public OrderAdd(MDataSet.OrdersRow source, MainForm mainForm)
        {
            InitializeComponent();
            _mainForm     = mainForm;
            this.mDataSet = source.Table.DataSet as MDataSet;

            this.ordersBindingSource.DataSource = source;

            this.errorProvider1.DataSource = this.ordersBindingSource.DataSource;

            this.tradePutletBindingSource.DataSource = new DataView(this.mDataSet.TradePutlet, "ID>0", null, DataViewRowState.CurrentRows);

            this.tradePutletBindingSource.ResetBindings(false);

            _product = _mainForm.fullDataSet.Product;

            this.productBindingSource.DataSource = _mainForm.fullDataSet.Product;

            this.productBindingSource.ResetBindings(false);
        }
Beispiel #10
0
        public DialogQuantityOrder(MDataSet.ProductRow source, MDataSet.OrdersRow newRow)
        {
            InitializeComponent();

            newRow.ProductRef = source.ID;

            this.productBindingSource.DataSource = source;

            if (source.GetRemainsRows().Length != 0)
            {
                foreach (MDataSet.RemainsRow row in source.GetRemainsRows())
                {
                    _QauntityRemains += row.QuantityRemains;
                }
            }

            this.ordersBindingSource.DataSource = newRow;

            this.labelRem.DataBindings.Add(new Binding("Text", this, "QauntityRemains"));
        }
Beispiel #11
0
        private void btDelete_Click(object sender, EventArgs e)
        {
            MDataSet.OrdersRow _ordsRow = this.gridViewOrders.GetDataRow(this.gridViewOrders.FocusedRowHandle) as MDataSet.OrdersRow;

            if (_ordsRow == null)
            {
                return;
            }


            if (_ordsRow.Reserved > 0)
            {
                MessageBox.Show("Этот товар уже для вас зарезервирован: " + _ordsRow.Reserved.ToString());

                return;
            }

            if (_ordsRow.QuantityNow > 0)
            {
                MessageBox.Show("Этот товар вам уже отгружен");

                return;
            }


            if (_ordsRow.isClose)
            {
                MessageBox.Show("Заявка была закрыта : " + _ordsRow.AuthorLastModif);

                return;
            }

            if (MessageBox.Show("Удалить : " + _ordsRow.ProductRow.Name + " ?") == DialogResult.OK)
            {
                _ordsRow.Delete();

                this.SaveOrdersRow(_ordsRow);
            }
        }