Example #1
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            In_inv_act_items itms = new In_inv_act_items();

            itms.ShowDialog();

            if (DataTransfer.action)
            {
                if (DataTransfer.id == -1)
                {
                    ds.Tables[0].Rows.Add(DataTransfer.Item_value, DataTransfer.quantity, DataTransfer.price, DataTransfer.price * DataTransfer.quantity, DataTransfer.is_new_item, DBNull.Value, DataTransfer.str_mark_num);
                }
                else
                {
                    ds.Tables[0].Rows.Add(DataTransfer.Item_value, DataTransfer.quantity, DataTransfer.price, DataTransfer.price * DataTransfer.quantity, DataTransfer.is_new_item, DataTransfer.id, DataTransfer.str_mark_num);
                }

                num_calc_sum.Value = calc_sum();
            }

            DataTransfer.action       = false;
            DataTransfer.is_new_item  = false;
            DataTransfer.id           = -1;
            DataTransfer.Item_value   = null;
            DataTransfer.price        = 0;
            DataTransfer.quantity     = 0;
            DataTransfer.str_mark_num = -1;
        }
Example #2
0
        private void btn_edit_Click(object sender, EventArgs e)
        {
            if (grid_items_in_inv.CurrentRow != null)
            {
                DataTransfer.str_num       = grid_items_in_inv.CurrentRow.Index;
                DataTransfer.action_change = true;
                DataTransfer.Item_value    = (string)grid_items_in_inv.CurrentRow.Cells[0].Value;
                DataTransfer.quantity      = (int)grid_items_in_inv.CurrentRow.Cells[1].Value;
                DataTransfer.price         = (decimal)grid_items_in_inv.CurrentRow.Cells[2].Value;
                DataTransfer.is_new_item   = (bool)grid_items_in_inv.CurrentRow.Cells[4].Value;
                if (grid_items_in_inv.CurrentRow.Cells[5].Value != DBNull.Value)
                {
                    DataTransfer.id = (int)grid_items_in_inv.CurrentRow.Cells[5].Value;
                }
                DataTransfer.str_mark_num = (int)grid_items_in_inv.CurrentRow.Cells[6].Value;

                In_inv_act_items itms = new In_inv_act_items();
                itms.ShowDialog();

                if (DataTransfer.action)
                {
                    ds.Tables[0].Rows[DataTransfer.str_num][0] = DataTransfer.Item_value;
                    ds.Tables[0].Rows[DataTransfer.str_num][1] = DataTransfer.quantity;
                    ds.Tables[0].Rows[DataTransfer.str_num][2] = DataTransfer.price;
                    ds.Tables[0].Rows[DataTransfer.str_num][3] = DataTransfer.price * DataTransfer.quantity;
                    ds.Tables[0].Rows[DataTransfer.str_num][4] = DataTransfer.is_new_item;
                    if (DataTransfer.id != -1)
                    {
                        ds.Tables[0].Rows[DataTransfer.str_num][5] = DataTransfer.id;
                    }
                    else if (ds.Tables[0].Rows[DataTransfer.str_num][5] != DBNull.Value)
                    {
                        ds.Tables[0].Rows[DataTransfer.str_num][5] = DBNull.Value;
                    }
                    ds.Tables[0].Rows[DataTransfer.str_num][6] = DataTransfer.str_mark_num;

                    num_calc_sum.Value = calc_sum();
                }

                DataTransfer.str_num       = -1;
                DataTransfer.action        = false;
                DataTransfer.action_change = false;
                DataTransfer.is_new_item   = false;
                DataTransfer.id            = -1;
                DataTransfer.Item_value    = null;
                DataTransfer.price         = 0;
                DataTransfer.quantity      = 0;
                DataTransfer.str_mark_num  = -1;
            }
            else
            {
                MessageBox.Show("Не выбран товар", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }