this.складTableAdapter.Fill(this.складDataSet.Склад);
}
private void toolStripTextBox1_Enter(object sender, EventArgs e)
{
if (toolStripTextBox1.Text == "Поиск...")
{
toolStripTextBox1.Text = null;
}
}
private void toolStripTextBox1_TextChanged(object sender, EventArgs e)
{
try
{
if (toolStripComboBox1.Text.Length > 0 && toolStripTextBox1.Text.Length > 0)
{
if (toolStripComboBox1.Text != "Ценовой промежуток" && toolStripComboBox1.Text != "Временной промежуток")
{
toolStripTextBox1.Enabled = true;
toolStripLabelExc.Visible = false;
складBindingSource.Filter = "[" + toolStripComboBox1.Text + "]" + "like '" + toolStripTextBox1.Text + "*'";
}
else if (toolStripComboBox1.Text == "Ценовой промежуток")
{
toolStripTextBox1.Enabled = true;
toolStripLabelExc.Visible = false;
складBindingSource.Filter = "[" + "Цена" + "]" + toolStripComboBox2.Text + toolStripTextBox1.Text;
}
else if (toolStripComboBox1.Text == "Временной промежуток")
{
toolStripTextBox1.Enabled = false;
toolStripLabelExc.Visible = false;
}
}
else
{
складBindingSource.RemoveFilter();
}
}
catch (Exception exc)
{
toolStripLabelExc.Visible = true;
toolStripLabelExc.ForeColor = Color.Red;
toolStripLabelExc.Text = exc.Message;
}
}
private void toolStripComboBox2_TextChanged(object sender, EventArgs e)
{
if (toolStripTextBox1.Text.Length > 0)
{
складBindingSource.Filter = "[" + "Цена" + "]" + toolStripComboBox2.Text + toolStripTextBox1.Text;
}
}
private void toolStripComboBox1_TextChanged(object sender, EventArgs e)
{
toolStripTextBox1.Text = null;
if (toolStripComboBox1.Text == "Ценовой промежуток")
{
dateTimePicker1.Visible = false;
dateTimePicker2.Visible = false;
toolStripComboBox2.Visible = true;
label1.Visible = false;
label2.Visible = false;
}
else if (toolStripComboBox1.Text == "Временной промежуток")
{
toolStripComboBox2.Visible = false;
dateTimePicker1.Visible = true;
dateTimePicker2.Visible = true;
label1.Visible = true;
label2.Visible = true;
}
else
{
toolStripComboBox2.Visible = false;
dateTimePicker1.Visible = false;
dateTimePicker2.Visible = false;
label1.Visible = false;
label2.Visible = false;
}
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
складBindingSource.Filter = "[" + "Дата производства" + "]" + " >= '" + dateTimePicker1.Value + "' AND " + "[" + "Дата производства" + "]" + "<= '" + dateTimePicker2.Value + "'";
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
складBindingSource.Filter = "[" + "Дата производства" + "]" + " >= '" + dateTimePicker1.Value + "' AND " + "[" + "Дата производства" + "]" + "<= '" + dateTimePicker2.Value + "'";
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Текстовые документы|*.txt";
String filename = null;
if (sfd.ShowDialog() == DialogResult.OK)
{
filename = sfd.FileName;
}
try
{
StreamWriter sw = new StreamWriter(filename);
foreach (DataRow dr in складDataSet.Tables["Склад"].Rows)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 9; i++)
{
sb.Append(dr[i]);
sb.Append(" ");
}
sb.Append("\r\n");
sw.Write(sb);
}
sw.Close();
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
private void складDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
toolStripLabelExc.Visible = true;
toolStripLabelExc.ForeColor = Color.Red;
toolStripLabelExc.Text = e.Exception.Message;
}
private void складDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
toolStripLabelExc.Visible = false;
}
}
}