⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sms_borrow.cs

📁 库存管理系统,对企业仓库的产品进行管理,使用C#语句 .net 平台开发
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FORU_SMS_
{
    public partial class SMS_Borrow : Form
    {
        BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass();
        BaseClass.DataConn Dconn = new FORU_SMS_.BaseClass.DataConn();
        BaseClass.GoodsBor Gbor = new FORU_SMS_.BaseClass.GoodsBor();
        SqlDataReader sqlRead;
        DataSet ds;
        public SMS_Borrow()
        {
            InitializeComponent();
        }

        private void SMS_Borrow_Load(object sender, EventArgs e)
        {
            dgvBGManage.Controls.Add(hScrollBar1);
            Dclass.BindComboBox("select StoreName from SMS_Store", "SMS_Store", "StoreName", cboxSName);
            Dclass.BindComboBox("select GoodsName from SMS_Goods", "SMS_Goods", "GoodsName", cboxGName);
            ds = Dclass.GetDataSet("select GoodsID AS 产品编号,GoodsName AS 产品名称,SupName AS 仓库名称,SpecName AS 货物规格,GoodsNum AS 出库数量,"
            + "BorName AS 借货人,GoodsPeople AS 经手人,BorDeparment AS 借货单位,GoodsRemarks AS 备注 from SMS_Borrow", "SMS_Borrow");
            dgvBGManage.DataSource = ds.Tables["SMS_Borrow"];
        }

        private void cboxGName_SelectedIndexChanged(object sender, EventArgs e)
        {
            sqlRead = Dclass.GetRead("select GoodsID,SpecName from SMS_Goods where GoodsName='" + this.cboxGName.Text.Trim() + "'");
            if (sqlRead.Read())
            {
                this.GoodsID.Text = sqlRead["GoodsID"].ToString().Trim();
                this.cboxGSpec.Text = sqlRead["SpecName"].ToString().Trim();
            }
            sqlRead.Close();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.txtBGNum.Text == "")
            {
                MessageBox.Show("产品数量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.cboxGName.Focus();
            }
            else if (this.txtBGPeople.Text == "")
            {
                MessageBox.Show("借货人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtBGPeople.Focus();
            }
            else if (this.txtHPeople.Text == "")
            {
                MessageBox.Show("经手人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtHPeople.Focus();
            }
            else if (this.txtBGNum.Text == "")
            {
                MessageBox.Show("借出数量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtBGNum.Focus();
            }
            else if (Convert.ToInt32(this.txtBGNum.Text.Trim()) == 0)
            {
                MessageBox.Show("借出数量不能为0!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtBGNum.Focus();
            }
            else
            {
                sqlRead = Dclass.GetRead("select GoodsID,GoodsName,SpecName,GoodsNum from SMS_Goods where GoodsName='" + this.cboxGName.Text.Trim() + "'");
                if (sqlRead.Read())
                {
                    if (Convert.ToInt32(sqlRead["GoodsNum"].ToString().Trim()) < 1)
                    {
                        MessageBox.Show("库存不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (Convert.ToInt32(this.txtBGNum.Text) > Convert.ToInt32(sqlRead["GoodsNum"].ToString().Trim()))
                    {
                        MessageBox.Show("没有足够的货物!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.txtBGNum.Text = "";
                        this.txtBGNum.Focus();
                    }
                    else
                    {
                        Gbor._GoodsID = this.GoodsID.Text.Trim();
                        Gbor._GoodsName = this.cboxGName.Text.Trim();
                        Gbor._SpecName = this.cboxGSpec.Text.Trim();
                        Gbor._SupName = this.cboxSName.Text.Trim();
                        Gbor._GoodsNum = int.Parse(this.txtBGNum.Text.Trim());
                        Gbor._BorDeparment = this.txtBGDepart.Text.Trim();
                        Gbor._GoodsPeople = this.txtHPeople.Text.Trim();
                        Gbor._BorName = this.txtBGPeople.Text.Trim();
                        Gbor._GoodsRemarks = this.txtBGRemark.Text.Trim();
                        Gbor.barGoods();
                        MessageBox.Show("提交成功!");
                        dgvBGManage.Refresh();
                        ds = Dclass.GetDataSet("select GoodsID AS 产品编号,GoodsName AS 产品名称,SupName AS 仓库名称,SpecName AS 货物规格,GoodsNum AS 出库数量,"
            + "BorName AS 借货人,GoodsPeople AS 经手人,BorDeparment AS 借货单位,GoodsRemarks AS 备注 from SMS_Borrow", "SMS_Borrow");
                        dgvBGManage.DataSource = ds.Tables["SMS_Borrow"];
                        //cboxGName.Items.Clear();
                        Dclass.BindComboBox("select GoodsName from SMS_Goods", "SMS_Goods", "GoodsName", cboxGName);
                        this.cboxGSpec.Text = "";
                        this.txtBGNum.Text = "";
                    }
                }
            }
        }


        private void btnDel_Click(object sender, EventArgs e)
        {
            if (dgvBGManage.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    Dclass.ExecuteSql("delete from SMS_Borrow where GoodsID='" + this.dgvBGManage.SelectedRows[0].Cells[0].Value.ToString() + "'");
                    MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SMS_Borrow_Load(sender, e);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }


        private void btnRGManage_Click(object sender, EventArgs e)
        {
            if (dgvBGManage.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                SMS_ReturnGoods Rgoods = new SMS_ReturnGoods(this.dgvBGManage.SelectedRows[0].Cells[0].Value.ToString());
                Rgoods.Show();
            }
        }


        private void txtBGNum_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar <= 57 && e.KeyChar >= 48 || e.KeyChar == 46 || e.KeyChar == 8)
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }


        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -