コード例 #1
0
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            DataTable dt = this.Gai_policeDBDataSet1.List_automobiles;

            dt.Clear();

            string i = this.Gai_policeDBDataSet1.List_automobiles.Columns[0].ColumnName.ToString();

            List_Automobile main = this.Owner as List_Automobile;

            if (main != null)
            {
                string resultRequest = "SELECT * FROM dbo.List_automobiles";
                resultRequest = comboBoxPlaceBuy.Text == "" ? resultRequest : stringRequestComBox(comboBoxPlaceBuy, resultRequest, dt.Columns[2].ColumnName.ToString());
                resultRequest = comboBoxMark.Text == "" ? resultRequest : stringRequestComBox(comboBoxMark, resultRequest, dt.Columns[4].ColumnName.ToString());
                resultRequest = comboBoxEmployee.Text == "" ? resultRequest : stringRequestComBox(comboBoxEmployee, resultRequest, dt.Columns[5].ColumnName.ToString());
                resultRequest = comboBoxOwner.Text == "" ? resultRequest : stringRequestComBox(comboBoxOwner, resultRequest, dt.Columns[0].ColumnName.ToString());
                resultRequest = textBoxNumber.Text == "" ? resultRequest : stringRequestTexBox(textBoxNumber, resultRequest, dt.Columns[3].ColumnName.ToString());
                resultRequest = stringRequestDateTime(dateTimePickerFrom, dateTimePickerTo, resultRequest, dt.Columns[1].ColumnName.ToString());


                adapterAuto = new SqlDataAdapter(resultRequest, connection);
                adapterAuto.Fill(this.Gai_policeDBDataSet1.List_automobiles);

                label8.Text = "Всего автомобилей: " + this.Gai_policeDBDataSet1.Tables["List_automobiles"].Rows.Count.ToString();
                clearComboxs();

                this.reportViewer1.RefreshReport();
            }
        }
コード例 #2
0
        private void AllReportAuto_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet.OwnerAuto". При необходимости она может быть перемещена или удалена.
            this.ownerAutoTableAdapter.Fill(this.Gai_policeDBDataSet.OwnerAuto);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet.Employee". При необходимости она может быть перемещена или удалена.
            this.employeeTableAdapter.Fill(this.Gai_policeDBDataSet.Employee);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet.PlaceBuyAuto". При необходимости она может быть перемещена или удалена.
            this.placeBuyAutoTableAdapter.Fill(this.Gai_policeDBDataSet.PlaceBuyAuto);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet1.List_automobiles". При необходимости она может быть перемещена или удалена.
            //this.List_automobilesTableAdapter.Fill(this.Gai_policeDBDataSet1.List_automobiles);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet.Automobile". При необходимости она может быть перемещена или удалена.
            this.AutomobileTableAdapter.Fill(this.Gai_policeDBDataSet.Automobile);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet.ModelAuto". При необходимости она может быть перемещена или удалена.
            this.ModelAutoTableAdapter.Fill(this.Gai_policeDBDataSet.ModelAuto);

            List_Automobile main = this.Owner as List_Automobile;

            if (main != null)
            {
                adapterAuto.Fill(this.Gai_policeDBDataSet1.List_automobiles);

                this.reportViewer1.RefreshReport();
            }

            initializationDataTimePicker();
            label8.Text = "Всего автомобилей: " + this.Gai_policeDBDataSet1.Tables["List_automobiles"].Rows.Count.ToString();
            clearComboxs();
            this.reportViewer1.RefreshReport();
        }
コード例 #3
0
        private void updatePosition()
        {
            List_Automobile main = this.Owner as List_Automobile;

            if (main != null) //Если открыта форма 2 (Сотрудники). То обновляем comboBox1
            {
                bs.Position = main.Model_ComBox.SelectedIndex;
                dgUpdate();
            }
        }
コード例 #4
0
ファイル: Owner.cs プロジェクト: kovrygakirill/DMV
        private void button7_Click(object sender, EventArgs e)
        {
            try {
                bool check = checkBirthday();
                if (!check)
                {
                    MessageBox.Show("Not included in the restriction 120 > Age > 18, Data not save", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    bs.CancelEdit();
                    records();
                    return;
                }

                SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                bs.EndEdit();
                adapter.Update(ds, "OwnerAuto");
                List_Automobile main = this.Owner as List_Automobile;
                if (main != null) //Если открыта форма 2 (Сотрудники). То обновляем comboBox1
                {
                    main.Owner_ComBox.DataSource    = null;
                    main.Owner_ComBox.DataSource    = ds.Tables["OwnerAuto"];
                    main.Owner_ComBox.DisplayMember = "Surname";
                    main.Owner_ComBox.ValueMember   = "Id";
                    main.Owner_ComBox.SelectedIndex = bs.Position;

                    main.dataGVComBoxColumns["Owner"].DataSource    = null;
                    main.dataGVComBoxColumns["Owner"].DataSource    = ds.Tables["OwnerAuto"];
                    main.dataGVComBoxColumns["Owner"].DisplayMember = "Surname";
                    main.dataGVComBoxColumns["Owner"].ValueMember   = "Id";
                }
                MessageBox.Show("Data save", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button5.Enabled = true;
            } catch (FormatException ex)
            {
                MessageBox.Show(ex.Message + " data not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                bs.CancelEdit();
                button5.Enabled = true;
            } catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message + " data not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //DataTable dt = this.dataGridView.DataSource as DataTable;
                //dt.RejectChanges();
                bs.CancelEdit();
            }
            records();
        }
コード例 #5
0
        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                bs.EndEdit();
                adapter.Update(ds, "ModelAuto");

                List_Automobile main = this.Owner as List_Automobile;
                if (main != null) //Если открыта форма 2 (Сотрудники). То обновляем comboBox1
                {
                    main.Model_ComBox.DataSource    = null;
                    main.Model_ComBox.DataSource    = ds.Tables["ModelAuto"];
                    main.Model_ComBox.DisplayMember = "Name_mark";
                    main.Model_ComBox.ValueMember   = "Id";
                    main.Model_ComBox.SelectedIndex = bs.Position;

                    main.dataGVComBoxColumns["Model"].DataSource    = null;
                    main.dataGVComBoxColumns["Model"].DataSource    = ds.Tables["ModelAuto"];
                    main.dataGVComBoxColumns["Model"].DisplayMember = "Name_mark";
                    main.dataGVComBoxColumns["Model"].ValueMember   = "Id";
                }
                MessageBox.Show("Data save", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button5.Enabled = true;
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message + " data not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                bs.CancelEdit();
                button5.Enabled = true;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message + " data not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //DataTable dt = this.dataGridView.DataSource as DataTable;
                //dt.RejectChanges();
                bs.CancelEdit();
            }
            records();
        }
コード例 #6
0
        private void certificateAuto_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "Gai_policeDBDataSet.Automobile". При необходимости она может быть перемещена или удалена.
            this.AutomobileTableAdapter.Fill(this.Gai_policeDBDataSet.Automobile);

            string          strFIO;
            List_Automobile main = this.Owner as List_Automobile;

            if (main != null)
            {
                var row     = main.dataGridV.CurrentRow.Index;
                var number  = main.dataGridV[3, row].Value.ToString();
                var ownerid = main.dataGridV[0, row].Value.ToString();
                var modelId = main.dataGridV[4, row].Value.ToString();

                SqlDataAdapter adapterOwner = new SqlDataAdapter("SELECT * FROM dbo.OwnerAuto WHERE id = " + ownerid, connection);
                SqlDataAdapter adapterModel = new SqlDataAdapter("SELECT * FROM dbo.ModelAuto WHERE id = " + modelId, connection);

                adapterOwner.Fill(this.Gai_policeDBDataSet, "OwnerAutoo");
                adapterModel.Fill(this.Gai_policeDBDataSet, "ModelAuto");

                DataRow ownerRow = this.Gai_policeDBDataSet.Tables["OwnerAutoo"].Rows[0];
                DataRow modelRow = this.Gai_policeDBDataSet.Tables["ModelAuto"].Rows[0];

                string ownerInfo = $"{ownerRow["name"]} {ownerRow["surname"]} {ownerRow["Patronymic"]}";
                string modelInfo = $"{modelRow["Name_mark"]} {modelRow["Model"]}";

                strFIO = $"Данная справка подверждает, что водитель: {ownerInfo}, имеет транспорт {modelInfo} с номером {number};";

                ReportParameter planData = new ReportParameter("OwnerData", strFIO);
                reportViewer1.LocalReport.SetParameters(new ReportParameter[] { planData });
            }

            this.reportViewer1.RefreshReport();
            this.reportViewer1.RefreshReport();
        }
コード例 #7
0
        private void button5_Click(object sender, EventArgs e)
        {
            List_Automobile form = new List_Automobile();

            form.ShowDialog();
        }