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

📄 sms_setsup.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_SetSup : Form
    {
        BaseClass.DataConn Dconn = new FORU_SMS_.BaseClass.DataConn();
        BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass();
        BaseClass.SupData Sdata = new FORU_SMS_.BaseClass.SupData();
        DataSet ds;
        public SMS_SetSup()
        {
            InitializeComponent();
        }

        private void SMS_SetSup_Load(object sender, EventArgs e)
        {
            dgvPInfo.Controls.Add(hScrollBar1);
            ds = Dclass.GetDataSet("SELECT SupID AS 编号, SupName AS 供应商名称,ContactName AS 联系人,SupPhone AS 联系电话,SupFax AS 传真 FROM SMS_Sup", "SMS_Sup");
            dgvPInfo.DataSource = ds.Tables[0].DefaultView;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.txtPName.Text.Trim() == "")
            {
                MessageBox.Show("供应商名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPName.Focus();
            }
            else if (this.txtPLeader.Text.Trim() == "")
            {
                MessageBox.Show("联系人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPLeader.Focus();
            }
            else if (this.txtPPhone.Text.Trim()=="")
            {
                MessageBox.Show("联系电话不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPPhone.Focus();
            }
            else
            {
                try
                {
                    Sdata._SupName = this.txtPName.Text.Trim();
                    Sdata._ContactName = this.txtPLeader.Text.Trim();
                    Sdata._SupPhone = this.txtPPhone.Text.Trim();
                    Sdata._SupFax = this.txtPFax.Text.Trim();
                    Sdata._SupRemark = this.txtPRemark.Text.Trim();
                    Sdata.addSup();
                    SMS_SetSup_Load(sender, e);
                    this.txtPName.Text = "";
                    this.txtPLeader.Text = "";
                    this.txtPPhone.Text = "";
                    this.txtPFax.Text = "";
                    this.txtPRemark.Text = "";
                    MessageBox.Show("提交成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }

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

        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (this.txtPName.Text.Trim() == "")
            {
                MessageBox.Show("供应商名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPName.Focus();
            }
            else if (this.txtPLeader.Text.Trim() == "")
            {
                MessageBox.Show("联系人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPLeader.Focus();
            }
            else if (this.txtPPhone.Text.Trim() == "")
            {
                MessageBox.Show("联系电话不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPPhone.Focus();
            }
            else
            {
                try
                {
                    Sdata._SupID = int.Parse(this.SupID.Text.Trim());
                    Sdata._SupName = this.txtPName.Text.Trim();
                    Sdata._ContactName = this.txtPLeader.Text.Trim();
                    Sdata._SupPhone = this.txtPPhone.Text.Trim();
                    Sdata._SupFax = this.txtPFax.Text.Trim();
                    Sdata._SupRemark = this.txtPRemark.Text.Trim();
                    Sdata.editSup();
                    SMS_SetSup_Load(sender, e);
                    this.SupID.Text = "";
                    this.txtPName.Text = "";
                    this.txtPLeader.Text = "";
                    this.txtPPhone.Text = "";
                    this.txtPFax.Text = "";
                    this.txtPRemark.Text = "";
                    MessageBox.Show("修改成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }

        private void dgvPInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dgvPInfo.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (this.dgvPInfo.SelectedRows[0].Cells[0].Value.ToString().Trim() == "")
            {
                MessageBox.Show("请选择一个操作项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    SqlDataReader sqlRead = Dclass.GetRead("select SupID,SupName,ContactName,SupPhone,SupFax,SupRemark from SMS_Sup where SupID=" + this.dgvPInfo.SelectedRows[0].Cells[0].Value.ToString().Trim() + "");
                    if (sqlRead.Read())
                    {
                        this.SupID.Text = sqlRead["SupID"].ToString().Trim();
                        this.txtPName.Text = sqlRead["SupName"].ToString().Trim();
                        this.txtPLeader.Text = sqlRead["ContactName"].ToString().Trim();
                        this.txtPPhone.Text = sqlRead["SupPhone"].ToString().Trim();
                        this.txtPFax.Text = sqlRead["SupFax"].ToString().Trim();
                        this.txtPRemark.Text = sqlRead["SupRemark"].ToString().Trim();
                    }
                    sqlRead.Close();
                }
                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 + -