Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace FormsVokuev
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         DataSet ds;
  17.         SqlDataAdapter adapter;
  18.         private string connectionString = @"Data Source=DESKTOP-3F2B3B3\SQLEXPRESS;Initial Catalog=DfLessonDb;Integrated Security=True";
  19.        
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.  
  26.         private void Form1_Load(object sender, EventArgs e)
  27.         {
  28.             // TODO: данная строка кода позволяет загрузить данные в таблицу "dfLessonDbDataSet.SupplyOfMaterials". При необходимости она может быть перемещена или удалена.
  29.             this.supplyOfMaterialsTableAdapter.Fill(this.dfLessonDbDataSet.SupplyOfMaterials);
  30.             // TODO: данная строка кода позволяет загрузить данные в таблицу "dfLessonDbDataSet.AvailabilityStock". При необходимости она может быть перемещена или удалена.
  31.             this.availabilityStockTableAdapter.Fill(this.dfLessonDbDataSet.AvailabilityStock);
  32.             // TODO: данная строка кода позволяет загрузить данные в таблицу "dfLessonDbDataSet.Stock". При необходимости она может быть перемещена или удалена.
  33.             this.stockTableAdapter.Fill(this.dfLessonDbDataSet.Stock);
  34.  
  35.  
  36.         }
  37.  
  38.  
  39.        
  40.  
  41.         private void availabilityStockGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
  42.         {
  43.             bindingNavigator1.BindingSource = availabilityStockBindingSource;
  44.             lblTable.Text = "Наличие материала";
  45.             this.availabilityStockGridView.DataSource = availabilityStockBindingSource;
  46.             this.supplyOfMaterialsGridView.DataSource = fkSupplyOfMaterialsWarehousesavailabilityBindingSource;
  47.         }
  48.  
  49.         private void supplyOfMaterialsGridView_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
  50.         {
  51.             bindingNavigator1.BindingSource = supplyOfMaterialsBindingSource;
  52.             lblTable.Text = "Учет материала";
  53.             this.supplyOfMaterialsGridView.DataSource = supplyOfMaterialsBindingSource;
  54.         }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.      
  66.  
  67.  
  68.      
  69.  
  70.  
  71.         private void availabilityStockGridView_CurrentCellChanged_1(object sender, EventArgs e)
  72.         {
  73.             if (availabilityStockGridView.CurrentCell != null)
  74.             {
  75.                 int nRow = availabilityStockGridView.CurrentCell.RowIndex;
  76.        
  77.             }
  78.         }
  79.  
  80.         private void btnSave_Click(object sender, EventArgs e)
  81.         {
  82.             this.availabilityStockTableAdapter.Update(this.dfLessonDbDataSet.AvailabilityStock);
  83.             this.availabilityStockTableAdapter.Fill(this.dfLessonDbDataSet.AvailabilityStock);
  84.             this.availabilityStockGridView_CurrentCellChanged_1(availabilityStockGridView, e);
  85.         }
  86.  
  87.         private void btnRefresh_Click(object sender, EventArgs e)
  88.         {
  89.             this.availabilityStockTableAdapter.Fill(dfLessonDbDataSet.AvailabilityStock);
  90.             this.availabilityStockGridView_CurrentCellChanged_1(availabilityStockGridView, e);
  91.            
  92.         }
  93.  
  94.         private void StockGridView_CellClick(object sender, DataGridViewCellEventArgs e)
  95.         {
  96.             bindingNavigator1.BindingSource = stockBindingSource;
  97.             this.availabilityStockGridView.DataSource = fkwhavailabilityBindingSource;
  98.             lblTable.Text = "Склады";
  99.         }
  100.        
  101.         private void btnproc_Click(object sender, EventArgs e)
  102.         {
  103.             int a = Convert.ToInt32(textBox1.Text);
  104.             using (SqlConnection connection = new SqlConnection(connectionString))
  105.             {
  106.                 string sql = string.Format(@"declare @answer int
  107. exec count_material {0}, @answer output
  108. select @answer", a);
  109.  
  110.                 connection.Open();
  111.                 adapter = new SqlDataAdapter(sql, connection);
  112.                 ds = new DataSet();
  113.                 adapter.Fill(ds);
  114.                 //dataGridView1.DataSource = ds.Tables[0];
  115.                 label1.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString();
  116.             }
  117.  
  118.         }
  119.  
  120.         private void button1_Click(object sender, EventArgs e)
  121.         {
  122.             Form2 fr2 = new Form2();
  123.             fr2.Show();
  124.             Hide();
  125.         }
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement