当前位置:网站首页>4、 Improvement of warehousing management function

4、 Improvement of warehousing management function

2022-06-13 01:41:00 Beyond proverb

One 、 Database creation

stay fiber_yy Create... Under database yy_textile surface  Insert picture description here
 Insert picture description here
Just add a few pieces of data
 Insert picture description here

Two 、 Page perfection

I won't show you on the login page , The previous blog posts also introduced

warehousing Warehousing page
 Insert picture description here
main_page The function of the page is improved
 Insert picture description here

3、 ... and 、 Code implementation

warehousing page

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
namespace fiber_yy
{
    
    public partial class warehousing : Form
    {
    
        public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";
        
        public warehousing()
        {
    
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
    

            OpenFileDialog ofdlgTest = new OpenFileDialog();
            //ofdlgTest.Filter = "*.jpg|*.png"; // File filtering   Filter files that can be opened 
            ofdlgTest.Filter = "";
            ofdlgTest.Multiselect = false;    // Set that multiple files cannot be selected 

            // The file open dialog box is displayed 
            DialogResult result = ofdlgTest.ShowDialog();

            // When selecting the open button , Display the file name in the text box 
            if (result == DialogResult.OK)                   // Determine whether to open the file 
            {
    
                this.textBox11.Text = ofdlgTest.FileName;

                pictureBox1.Image = Image.FromFile(ofdlgTest.FileName);
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
    
            try
            {
    
                string path = textBox11.Text;

                FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); // Add the picture of the specified path to FileStream Class 
                BinaryReader br = new BinaryReader(fs);// adopt FileStream Object instantiation BinaryReader object 

                byte[] imgBytesIn = br.ReadBytes(Convert.ToInt32(fs.Length));// Convert pictures to binary data 
                                                                             //Save(imgBytesIn);// call ( A way to write by yourself )
                SqlConnection conn = new SqlConnection(constr);
                conn.Open();

                string name = textBox1.Text;
                int number = int.Parse(textBox2.Text);
                float warp_density = float.Parse(textBox3.Text);
                float weft_density = float.Parse(textBox4.Text);
                float warp_linear_density = float.Parse(textBox5.Text);
                float weft_linear_density = float.Parse(textBox6.Text);
                string material = textBox7.Text;
                float square_meter_weight = float.Parse(textBox8.Text);
                float width_of_cloth = float.Parse(textBox9.Text);
                float horse_length = float.Parse(textBox10.Text);

                string organization = textBox12.Text;
                int stock = int.Parse(textBox13.Text);



                SqlCommand cmd = new SqlCommand("insert into yy_textile (name,number,warp_density,weft_density,warp_linear_density,weft_linear_density,material,square_meter_weight,width_of_cloth,horse_length,picture,organization,stock) " +
                    "values(@name,@number,@warp_density,@weft_density,@warp_linear_density,@weft_linear_density,@material,@square_meter_weight,@width_of_cloth,@horse_length,@picture,@organization,@stock);", conn); //SQL sentence 


                cmd.Parameters.Add("@name", SqlDbType.VarChar);
                cmd.Parameters["@name"].Value = name;

                cmd.Parameters.Add("@number", SqlDbType.Int);
                cmd.Parameters["@number"].Value = number;

                cmd.Parameters.Add("@warp_density", SqlDbType.Float);
                cmd.Parameters["@warp_density"].Value = warp_density;

                cmd.Parameters.Add("@weft_density", SqlDbType.Float);
                cmd.Parameters["@weft_density"].Value = weft_density;

                cmd.Parameters.Add("@warp_linear_density", SqlDbType.Float);
                cmd.Parameters["@warp_linear_density"].Value = warp_linear_density;

                cmd.Parameters.Add("@weft_linear_density", SqlDbType.Float);
                cmd.Parameters["@weft_linear_density"].Value = weft_linear_density;

                cmd.Parameters.Add("@material", SqlDbType.VarChar);
                cmd.Parameters["@material"].Value = material;

                cmd.Parameters.Add("@square_meter_weight", SqlDbType.Float);
                cmd.Parameters["@square_meter_weight"].Value = square_meter_weight;

                cmd.Parameters.Add("@width_of_cloth", SqlDbType.Float);
                cmd.Parameters["@width_of_cloth"].Value = width_of_cloth;

                cmd.Parameters.Add("@horse_length", SqlDbType.Float);
                cmd.Parameters["@horse_length"].Value = horse_length;

                cmd.Parameters.Add("@picture", SqlDbType.Image);
                cmd.Parameters["@picture"].Value = imgBytesIn;

                cmd.Parameters.Add("@organization", SqlDbType.VarChar);
                cmd.Parameters["@organization"].Value = organization;

                cmd.Parameters.Add("@stock", SqlDbType.Int);
                cmd.Parameters["@stock"].Value = stock;



                cmd.ExecuteNonQuery();

                conn.Close();
                MessageBox.Show(" Image upload succeeded ");
            }
            catch 
            {
    
                MessageBox.Show(" Please check the input information ");
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
    
            new main_page().Show();
            this.Hide();
        }
    }
}

main_page page

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace fiber_yy
{
    
    public partial class main_page : Form
    {
    
        public main_page()
        {
    
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
    
            MessageBox.Show(" Quit successfully ");
            this.Close();
            new Form1().Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
    
            this.Close();
            new warehousing().Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
    
            this.Close();
            new shipment().Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
    
            this.Close();
            new query().Show();
        }
    }
}


Four 、 Effect demonstration

The program runs
 Insert picture description here
I won't demonstrate if I register , Please refer to the previous blog posts
from yy_user Find an account and password in the table , Direct user login
 Insert picture description here
 Insert picture description here
Login successful
 Insert picture description here
Entry system
 Insert picture description here

First demonstrate Warehousing management function
 Insert picture description here
 Insert picture description here

 Insert picture description here
Put in storage
 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[Beyond proverb]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130135332319.html