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

📄 sms_setstore.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_SetStore : Form
    {
        BaseClass.DataConn Dconn = new FORU_SMS_.BaseClass.DataConn();
        BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass();
        BaseClass.StoreData Sdata = new FORU_SMS_.BaseClass.StoreData();

        DataSet ds;
        public SMS_SetStore()
        {
            InitializeComponent();
        }

        private void SMS_SetStore_Load(object sender, EventArgs e)
        {
            dgvSInfo.Controls.Add(hScrollBar1);
            ds = Dclass.GetDataSet("select StoreID AS 仓库编号, StoreName AS 仓库名称,ForName AS 负责人,StorePhone AS 仓库电话,StoreDepart AS 所属单位,StoreAddre AS 所在地址,StoreRemark AS 备注,StoreTime AS 建立日期 from SMS_Store", "SMS_Store");
            dgvSInfo.DataSource = ds.Tables[0];
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.txtSName.Text.Trim() == "")
            {
                MessageBox.Show("负责人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSName.Focus();
            }
            else if (this.txtSLeader.Text.Trim() == "")
            {
                MessageBox.Show("仓库名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSLeader.Focus();
            }
            else if (this.txtSPhone.Text.Trim() == "")
            {
                MessageBox.Show("仓库电话不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSPhone.Focus();
            }
            else if (this.txtSDepart.Text.Trim() == "")
            {
                MessageBox.Show("所属部门不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSDepart.Focus();
            }
            else if (this.textSadd.Text.Trim() == "")
            {
                MessageBox.Show("仓库地址不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.textSadd.Focus();
            }
            else
            {
                Sdata._StoreName = this.txtSName.Text.Trim();
                Sdata._ForName = this.txtSLeader.Text.Trim();
                Sdata._StorePhone = this.txtSPhone.Text.Trim();
                Sdata._StoreDepart = this.txtSDepart.Text.Trim();
                Sdata._StoreAddre = this.textSadd.Text.Trim();
                Sdata._StoreRemark = this.txtSRemark.Text.Trim();
                Sdata.addStore();
                SMS_SetStore_Load(sender, e);
                MessageBox.Show("提交成功!");
                this.txtSName.Text = "";
                this.txtSLeader.Text = "";
                this.txtSPhone.Text = "";
                this.txtSDepart.Text = "";
                this.textSadd.Text = "";
                this.txtSRemark.Text = "";
                this.txtSName.Focus();
            }
        }

        private void dgvSInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            btnEdit_Click(sender, e);
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgvSInfo.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (this.dgvSInfo.SelectedRows[0].Cells[0].Value.ToString().Trim() == "")
            {
                MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    SqlDataReader sqlRead = Dclass.GetRead("select StoreID,StoreName,ForName,StorePhone,StoreDepart,StoreAddre,StoreRemark from SMS_Store where StoreID=" + this.dgvSInfo.SelectedRows[0].Cells[0].Value.ToString().Trim() + "");
                    if (sqlRead.Read())
                    {
                        this.txtStoreID.Text = sqlRead["StoreID"].ToString().Trim();
                        this.txtSName.Text = sqlRead["StoreName"].ToString().Trim();
                        this.txtSLeader.Text = sqlRead["ForName"].ToString().Trim();
                        this.txtSPhone.Text = sqlRead["StorePhone"].ToString().Trim();
                        this.txtSDepart.Text = sqlRead["StoreDepart"].ToString().Trim();
                        this.textSadd.Text = sqlRead["StoreAddre"].ToString().Trim();
                        this.txtSRemark.Text = sqlRead["StoreRemark"].ToString().Trim();
                    }
                    sqlRead.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.txtStoreID.Text.Trim() == "")
            {
                MessageBox.Show("参数丢失!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.Close();
            }
            else if (this.txtSName.Text.Trim() == "")
            {
                MessageBox.Show("负责人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSName.Focus();
            }
            else if (this.txtSLeader.Text.Trim() == "")
            {
                MessageBox.Show("仓库名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSLeader.Focus();
            }
            else if (this.txtSPhone.Text.Trim() == "")
            {
                MessageBox.Show("仓库电话不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSPhone.Focus();
            }
            else if (this.txtSDepart.Text.Trim() == "")
            {
                MessageBox.Show("所属部门不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSDepart.Focus();
            }
            else if (this.textSadd.Text.Trim() == "")
            {
                MessageBox.Show("仓库地址不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.textSadd.Focus();
            }
            else
            {
                Sdata._StoreID = int.Parse(this.txtStoreID.Text.Trim());
                Sdata._StoreName = this.txtSName.Text.Trim();
                Sdata._ForName = this.txtSLeader.Text.Trim();
                Sdata._StorePhone = this.txtSPhone.Text.Trim();
                Sdata._StoreDepart = this.txtSDepart.Text.Trim();
                Sdata._StoreAddre = this.textSadd.Text.Trim();
                Sdata._StoreRemark = this.txtSRemark.Text.Trim();
                Sdata.editStore();
                SMS_SetStore_Load(sender, e);
                MessageBox.Show("修改成功!");
                this.txtStoreID.Text = "";
                this.txtSName.Text = "";
                this.txtSLeader.Text = "";
                this.txtSPhone.Text = "";
                this.txtSDepart.Text = "";
                this.textSadd.Text = "";
                this.txtSRemark.Text = "";
                this.txtSName.Focus();
            }
        }

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

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

⌨️ 快捷键说明

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