Esempio n. 1
0
        private void Sell(int Code)
        {
            DataTable tableToFill;

            tableToFill = new DataTable("tableToFill");

            MySqlDataAdapter adapter;

            adapter = new MySqlDataAdapter(qSelectWareByCode, connection);
            adapter.SelectCommand.Parameters.AddWithValue("?pcode", Code.ToString());
            adapter.Fill(tableToFill);

            // TODO: fillschema() only if no schema
            if (dataSet1.Tables["chetab"].Columns.Count == 0)
            {
                adapter.FillSchema(dataSet1.Tables["chetab"], SchemaType.Source);
            }
            tableToFill.PrimaryKey = new DataColumn[] { tableToFill.Columns["id"] };

            int n = tableToFill.Rows.Count;

            active_q_id = -1;

            #region Determine exact ware active_q_id
            if (n == 0)
            {
                PrintLog("[Oops] The ware is not found by the code: count(*) == 0");
                return;
            }

            if (n > 1)
            {
                FormSearch fs = new FormSearch(connection);
                if (fs.ShowDialog() != DialogResult.OK)
                {
                    PrintLog("[Abort] Search canceled (fs.ShowDialog != OK)");
                    return;
                }
                active_q_id = fs.SelectedId;
                fs.Dispose();
            }
            else
            {
                active_q_id = (int)tableToFill.Rows[0].ItemArray[0];
            }
            #endregion

            DataRow wareRow = tableToFill.Rows.Find(active_q_id);
            dataSet1.Tables["chetab"].ImportRow(wareRow);
            dgv1.DataMember = "chetab";

            // Focus on kol-vo
            dgv1.CurrentCell = dgv1["countDataGridViewTextBoxColumn", dgv1.Rows.Count - 1];
            dgv1.BeginEdit(true);
        }
Esempio n. 2
0
        private void поискToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormSearch fs = new FormSearch(connection);

            if (fs.ShowDialog() != DialogResult.OK)
            {
                PrintLog("[Abort] Search canceled (fs.ShowDialog != OK)");
                return;
            }
            active_q_id = fs.SelectedId;
            fs.Dispose();

            // тут надо продать найденное

            textBoxCode.SelectAll();
        }