当前位置:网站首页>6、 Implementation of warehouse out management function

6、 Implementation of warehouse out management function

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

One 、 The establishment of database

Still used here yy_textile surface
stay fiber_yy Create... Under database yy_textile surface
 Insert picture description here
 Insert picture description here
Initial database information
 Insert picture description here

Two 、 Page perfection

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

shipment Issue management page
 Insert picture description here
main_page The function of the page is improved
 Insert picture description here

3、 ... and 、 Code implementation

shipment Issue management 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 shipment : Form
    {
    
        private DataSet dsall;
        public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";
        private SqlDataAdapter mDataAdapter;

        public shipment()
        {
    
            InitializeComponent();
            try
            {
    

                SqlConnection conn = new SqlConnection(constr);
                conn = new SqlConnection(constr);
                mDataAdapter = new SqlDataAdapter("SELECT name AS ' Name of textile ',number AS ' Textile product No ',warp_density AS ' Density ' ,weft_density AS ' Weft density ',warp_linear_density AS ' Warp yarn density ',weft_linear_density AS ' Weft yarn density ',material AS ' Ingredients ',square_meter_weight AS ' Weight per square meter ',width_of_cloth AS ' width of cloth ',horse_length AS ' Horse length ',organization AS ' Organization used ',stock AS ' Inventory ' FROM yy_textile", conn);
                dsall = new DataSet();
                mDataAdapter.Fill(dsall, "hard");
                dataGridView1.DataSource = dsall.Tables["hard"];

            }
            catch
            {
    
                MessageBox.Show(" Read failed , Please check if the fabric is present ");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
    
            try
            {
    
                SqlConnection conn = new SqlConnection(constr);
                conn = new SqlConnection(constr);
                mDataAdapter = new SqlDataAdapter("SELECT name AS ' Name of textile ',number AS ' Textile product No ',warp_density AS ' Density ' ,weft_density AS ' Weft density ',warp_linear_density AS ' Warp yarn density ',weft_linear_density AS ' Weft yarn density ',material AS ' Ingredients ',square_meter_weight AS ' Weight per square meter ',width_of_cloth AS ' width of cloth ',horse_length AS ' Horse length ',organization AS ' Organization used ',stock AS ' Inventory ' FROM yy_textile", conn);
                dsall = new DataSet();
                mDataAdapter.Fill(dsall, "hard");
                dataGridView1.DataSource = dsall.Tables["hard"];
            }
            catch
            {
    
                MessageBox.Show(" Read failed ");
            }
        }

        private void button2_Click(object sender, EventArgs e)// View fabric information 
        {
    
            try
            {
    
                string number = textBox1.Text;
                byte[] MyData = new byte[0];
                string sql = "SELECT stock FROM yy_textile WHERE number='" + number + "'";

                SqlConnection conn = new SqlConnection(constr);
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                string account = cmd.ExecuteScalar().ToString();
                int a = int.Parse(account);
                //MessageBox.Show(a.ToString());
                if (a > 100)
                {
    
                    SqlConnection conn1 = new SqlConnection(constr);
                    conn1.Open();
                    SqlCommand cmd1 = new SqlCommand();
                    cmd1.Connection = conn1;
                    cmd1.CommandText = "select * from yy_textile where number='" + number + "'";

                    SqlDataReader sdr = cmd1.ExecuteReader();
                    sdr.Read();
                    object o = sdr["picture"];
                    MyData = (byte[])sdr["picture"];// Read the bit stream of the first picture 
                    MemoryStream memoryStream = null;
                    memoryStream = new MemoryStream(MyData);
                    pictureBox1.Image = Image.FromStream(memoryStream);// Assign pictures to pictureBox1 Control 
                    MessageBox.Show(" Read successful ");

                }
                else 
                {
    
                    MessageBox.Show(" Insufficient inventory 100 Please add in time !!!");
                }

            }
            catch
            {
    
                MessageBox.Show(" Read failed  over");
            }

            
        }
        private void button3_Click(object sender, EventArgs e)
        {
    
            try
            {
    
                string sql1;
                string number = this.textBox1.Text;
                int count = int.Parse(textBox2.Text);

                SqlConnection conn = new SqlConnection(constr);
                conn = new SqlConnection(constr);
                string sql = "SELECT number FROM yy_textile WHERE number='" + number + "'";
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                string amount = cmd.ExecuteScalar().ToString();
                int a = int.Parse(amount);
                

                sql1 = "update yy_textile set stock = stock - '" + count + "' where number='" + number + "'";
                mDataAdapter = new SqlDataAdapter(sql1, conn);
                dsall = new DataSet();
                mDataAdapter.Fill(dsall, "hard");
                dataGridView1.DataSource = dsall.Tables["hard"];
                MessageBox.Show(" Delivery succeeded !!!");
                

            }
            catch (Exception ex) {
     MessageBox.Show(ex.Message); }
            finally
            {
     }
        }

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

        
    }
}

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

demonstration Warehouse out management function
 Insert picture description here

 Insert picture description here
View fabric information
 Insert picture description here
Out of stock 20
 Insert picture description here
 Insert picture description here
retrieval once
 Insert picture description here

When inventory is below 100 Will remind you when , And at this time, you can no longer leave the warehouse , Additional fabric is needed
 Insert picture description here

原网站

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