最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)銷售管理系統(tǒng)

 更新時(shí)間:2021年06月24日 11:44:11   作者:Mr&HelloWorld  
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)銷售管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

C#制作簡(jiǎn)易的的銷售管理系統(tǒng),供大家參考,具體內(nèi)容如下

1.整體需求

1).具有簡(jiǎn)易的登錄界面
2).能對(duì)商品信息進(jìn)行快速查看、查詢、添加、編輯、保存等功能。

2.設(shè)計(jì)的窗體界面

1).登錄界面
2).商品信息的操作界面

3.所需的知識(shí)

 1).C#基礎(chǔ)語(yǔ)法
 2).ADO.NET數(shù)據(jù)庫(kù)

不太清楚的可以去看我主頁(yè)的文章,都是關(guān)于C#基礎(chǔ)的知識(shí)。

4.具體步驟及代碼

1).創(chuàng)建項(xiàng)目

首先打開(kāi)vs2017,選擇“創(chuàng)建項(xiàng)目” ,選擇“Windows窗體應(yīng)用”。詳細(xì)的操作 可以看我之前寫(xiě)的一些簡(jiǎn)單項(xiàng)目。

2).添加控件

登錄界面和商品信息界面如下:

可以試著根據(jù)圖片顯示的去添加控件,詳情見(jiàn)主頁(yè)的C#Windows窗體應(yīng)用設(shè)計(jì)系列。商品信息界面最上面是一個(gè)tool strip 控件。后面會(huì)把源碼發(fā)出來(lái),邊參考源碼編寫(xiě)可以對(duì)C#的設(shè)計(jì)更加清楚。

3).添加代碼

需要添加的代碼如下,添加代碼的方法見(jiàn)主頁(yè)的文章介紹。

登錄界面:

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

namespace EMS
{
    public partial class frmLogin : Form
    {
        BaseClass.BaseInfo baseinfo = new EMS.BaseClass.BaseInfo();
        BaseClass.cPopedom popedom = new EMS.BaseClass.cPopedom();
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty)
            {
                MessageBox.Show("用戶名稱不能為空!", "錯(cuò)誤提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DataSet ds = null;
            popedom.SysUser = txtUserName.Text;
            popedom.Password = txtUserPwd.Text;
            ds=baseinfo.Login(popedom);
            if (ds.Tables[0].Rows.Count > 0)
            {
                EMS.BaseInfo.frmStock frm_Stock = new EMS.BaseInfo.frmStock();
                frm_Stock.Show();                
            }
            else
            {
                MessageBox.Show("用戶名稱或密碼不正確!","錯(cuò)誤提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }

        private void txtUserName_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13) //判斷是否按下Enter鍵
                txtUserPwd.Focus();//將鼠標(biāo)焦點(diǎn)移動(dòng)到“密碼”文本框
        }

        private void txtUserPwd_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)//判斷是否按下Enter鍵
                btnLogin.Focus();//將鼠標(biāo)焦點(diǎn)移動(dòng)到“登錄”按鈕
        }

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

      
    }
}

商品主界面的代碼:

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

namespace EMS.BaseInfo
{
    public partial class frmStock : Form
    {
        BaseClass.BaseInfo baseinfo = new EMS.BaseClass.BaseInfo();//創(chuàng)建BaseInfo類的對(duì)象
        BaseClass.cStockInfo stockinfo = new EMS.BaseClass.cStockInfo();//創(chuàng)建cStockInfo類的對(duì)象
        int G_Int_addOrUpdate = 0;//定義添加/修改操作標(biāo)識(shí)
        public frmStock()
        {
            InitializeComponent();
        }

        private void tlBtnAdd_Click(object sender, EventArgs e)
        {
            this.editEnabled();//設(shè)置各個(gè)控件的可用狀態(tài)
            this.clearText();//清空文本框
            G_Int_addOrUpdate = 0;//等于0為添加數(shù)據(jù)
            DataSet ds = null;//創(chuàng)建數(shù)據(jù)集對(duì)象
            string P_Str_newTradeCode = "";//設(shè)置庫(kù)存商品編號(hào)為空
            int P_Int_newTradeCode = 0;//初始化商品編號(hào)中的數(shù)字碼
            ds = baseinfo.GetAllStock("tb_stock");//獲取庫(kù)存商品信息
            if (ds.Tables[0].Rows.Count == 0)//判斷數(shù)據(jù)集中是否有值
            {
                txtTradeCode.Text = "T1001";//設(shè)置默認(rèn)商品編號(hào)
            }
            else
            {
                P_Str_newTradeCode = Convert.ToString(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["tradecode"]);//獲取已經(jīng)存在的最大編號(hào)
                P_Int_newTradeCode = Convert.ToInt32(P_Str_newTradeCode.Substring(1, 4)) + 1;//獲取一個(gè)最新的數(shù)字碼
                P_Str_newTradeCode = "T" + P_Int_newTradeCode.ToString();//獲取最新商品編號(hào)
                txtTradeCode.Text = P_Str_newTradeCode;//將商品編號(hào)顯示在文本框中
            }
        }
        //設(shè)置各按鈕的可用狀態(tài)
        private void editEnabled()
        {
            groupBox1.Enabled = true;
            tlBtnAdd.Enabled = false;
            tlBtnEdit.Enabled = false;
            tlBtnDelete.Enabled = false;
            tlBtnSave.Enabled = true;
            tlBtnCancel.Enabled = true;
        }
        //設(shè)置各按鈕的可用狀態(tài)
        private void cancelEnabled()
        {
            groupBox1.Enabled = false;
            tlBtnAdd.Enabled = true;
            tlBtnEdit.Enabled = true;
            tlBtnDelete.Enabled = true;
            tlBtnSave.Enabled = false;
            tlBtnCancel.Enabled = false;
        }
        //清空文本框
        private void clearText()
        {
            txtTradeCode.Text= string.Empty;
            txtFullName.Text = string.Empty;
            txtType.Text = string.Empty;
            txtStandard.Text = string.Empty;
            txtUnit.Text = string.Empty;
            txtProduce.Text = string.Empty;
        }
        //設(shè)置DataGridView列標(biāo)題
        private void SetdgvStockListHeadText() 
        {
            dgvStockList.Columns[0].HeaderText = "商品編號(hào)";
            dgvStockList.Columns[1].HeaderText = "商品名稱";
            dgvStockList.Columns[2].HeaderText = "商品型號(hào)";
            dgvStockList.Columns[3].HeaderText = "商品規(guī)格";
            dgvStockList.Columns[4].HeaderText = "商品單位";
            dgvStockList.Columns[5].HeaderText = "商品產(chǎn)地";
            dgvStockList.Columns[6].HeaderText = "庫(kù)存數(shù)量";
            dgvStockList.Columns[7].Visible = false;
            dgvStockList.Columns[8].HeaderText = "商品價(jià)格(加權(quán)平均價(jià)格)";
            dgvStockList.Columns[9].Visible = false;
            dgvStockList.Columns[10].HeaderText = "盤點(diǎn)數(shù)量";
            dgvStockList.Columns[11].Visible = false;
            dgvStockList.Columns[12].Visible = false;
        }

        private void frmStock_Load(object sender, EventArgs e)
        {
            txtTradeCode.ReadOnly = true;//設(shè)置商品編號(hào)文本框只讀
            this.cancelEnabled();//設(shè)置各按鈕的可用狀態(tài)
            //顯示所有庫(kù)存商品信息
            dgvStockList.DataSource = baseinfo.GetAllStock("tb_stock").Tables[0].DefaultView;
            this.SetdgvStockListHeadText();//設(shè)置DataGridView控件的列標(biāo)題
        }

        private void tlBtnSave_Click(object sender, EventArgs e)
        {
            //判斷是添加還是修改數(shù)據(jù)
            if (G_Int_addOrUpdate == 0)
            {
                try
                {
                    //添加數(shù)據(jù)
                    stockinfo.TradeCode = txtTradeCode.Text;
                    stockinfo.FullName = txtFullName.Text;
                    stockinfo.TradeType = txtType.Text;
                    stockinfo.Standard = txtStandard.Text;
                    stockinfo.Unit = txtUnit.Text;
                    stockinfo.Produce = txtProduce.Text;
                    //執(zhí)行添加操作
                    int id = baseinfo.AddStock(stockinfo);
                    MessageBox.Show("新增--庫(kù)存商品數(shù)據(jù)--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,"錯(cuò)誤提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                //修改數(shù)據(jù)
                stockinfo.TradeCode = txtTradeCode.Text;
                stockinfo.FullName = txtFullName.Text;
                stockinfo.TradeType = txtType.Text;
                stockinfo.Standard = txtStandard.Text;
                stockinfo.Unit = txtUnit.Text;
                stockinfo.Produce = txtProduce.Text;
                //執(zhí)行修改操作
                int id = baseinfo.UpdateStock(stockinfo);
                MessageBox.Show("修改--庫(kù)存商品數(shù)據(jù)--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            dgvStockList.DataSource = baseinfo.GetAllStock("tb_stock").Tables[0].DefaultView;//顯示最新的庫(kù)存商品信息
            this.SetdgvStockListHeadText();//設(shè)置DataGridView控件列標(biāo)題
            this.cancelEnabled();//設(shè)置各個(gè)按鈕的可用狀態(tài)
        }

        private void tlBtnEdit_Click(object sender, EventArgs e)
        {
            this.editEnabled();//設(shè)置各個(gè)按鈕的可用狀態(tài)
            G_Int_addOrUpdate = 1;//等于1為修改數(shù)據(jù)
        }

        private void tlBtnFind_Click(object sender, EventArgs e)
        {
            if (tlCmbStockType.Text == string.Empty)//判斷查詢類別是否為空
            {
                MessageBox.Show("查詢類別不能為空!", "錯(cuò)誤提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tlCmbStockType.Focus();//使查詢類別下拉列表獲得鼠標(biāo)焦點(diǎn)
                return;
            }
            else
            {
                if (tlTxtFindStock.Text.Trim() == string.Empty)//判斷查詢關(guān)鍵字是否為空
                {
                    //顯示所有庫(kù)存商品信息
                    dgvStockList.DataSource = baseinfo.GetAllStock("tb_stock").Tables[0].DefaultView;
                    this.SetdgvStockListHeadText();//設(shè)置DataGridView控件的列標(biāo)題
                    return;
                }
            }
            DataSet ds = null;//創(chuàng)建DataSet對(duì)象
            if (tlCmbStockType.Text == "商品產(chǎn)地") //按商品產(chǎn)地查詢
            {
                stockinfo.Produce = tlTxtFindStock.Text;//記錄商品產(chǎn)地
                ds = baseinfo.FindStockByProduce(stockinfo, "tb_Stock");//根據(jù)商品產(chǎn)地查詢商品信息
                dgvStockList.DataSource = ds.Tables[0].DefaultView;//顯示查詢到的信息
            }
            else//按商品名稱查詢
            {
                stockinfo.FullName = tlTxtFindStock.Text;//記錄商品名稱
                ds = baseinfo.FindStockByFullName(stockinfo, "tb_stock");//根據(jù)商品名稱查詢商品信息
                dgvStockList.DataSource = ds.Tables[0].DefaultView;//顯示查詢到的信息
            }
            this.SetdgvStockListHeadText();//設(shè)置DataGridView控件列標(biāo)題
        }

        private void tlBtnDelete_Click(object sender, EventArgs e)
        {
            if (txtTradeCode.Text.Trim() == string.Empty)//判斷是否選擇了商品編號(hào)
            {
                MessageBox.Show("刪除--庫(kù)存商品數(shù)據(jù)--失??!", "錯(cuò)誤提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            stockinfo.TradeCode = txtTradeCode.Text;//記錄商品編號(hào)
            int id = baseinfo.DeleteStock(stockinfo);//執(zhí)行刪除操作
            MessageBox.Show("刪除--庫(kù)存商品數(shù)據(jù)--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            dgvStockList.DataSource = baseinfo.GetAllStock("tb_stock").Tables[0].DefaultView;//顯示最新的庫(kù)存商品信息
            this.SetdgvStockListHeadText();//設(shè)置DataGridView控件列標(biāo)題
            this.clearText();//清空文本框
        }

        private void tlBtnCancel_Click(object sender, EventArgs e)
        {
            this.cancelEnabled();//設(shè)置各個(gè)按鈕的可用狀態(tài)
        }

        private void dgvStockList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            txtTradeCode.Text = this.dgvStockList[0, dgvStockList.CurrentCell.RowIndex].Value.ToString();//顯示商品編號(hào)
            txtFullName.Text = this.dgvStockList[1, dgvStockList.CurrentCell.RowIndex].Value.ToString();//顯示商品全稱
            txtType.Text = this.dgvStockList[2, dgvStockList.CurrentCell.RowIndex].Value.ToString();//顯示商品型號(hào)
            txtStandard.Text = this.dgvStockList[3, dgvStockList.CurrentCell.RowIndex].Value.ToString();//顯示商品規(guī)格
            txtUnit.Text = this.dgvStockList[4, dgvStockList.CurrentCell.RowIndex].Value.ToString();//顯示商品單位
            txtProduce.Text = this.dgvStockList[5, dgvStockList.CurrentCell.RowIndex].Value.ToString();//顯示商品產(chǎn)地
        }

        private void tlBtnExit_Click(object sender, EventArgs e)
        {
            this.Close();//關(guān)閉當(dāng)前窗體
        }

        private void dgvStockList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}

Main.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace EMS
{
    static class Program
    {
        /// <summary>
        /// 應(yīng)用程序的主入口點(diǎn)。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmLogin());
        }
    }
}

需要添加的圖片素材在源碼文件夾的icon和image文件夾里面,覺(jué)得不好看的可以自行查找。
注意,添加代碼時(shí)要與自己的添加的控件一一對(duì)應(yīng)起來(lái)。

4).建立數(shù)據(jù)庫(kù)

數(shù)據(jù)庫(kù)具體的添加方法在我主頁(yè)的文章《一起來(lái)學(xué)C#之?dāng)?shù)據(jù)庫(kù)》中講過(guò),在菜單欄中的“項(xiàng)目”-》》“添加新項(xiàng)目”-》》“基于服務(wù)的數(shù)據(jù)庫(kù)”,具體操作可以看我前面的文章。本次給出的源碼有數(shù)據(jù)庫(kù),可以自行修改添加。

5).調(diào)試運(yùn)行

根據(jù)自己所寫(xiě)的去運(yùn)行,再對(duì)照提供的源碼修改錯(cuò)誤,運(yùn)行界面如下。

登錄界面:

登錄賬戶名:mr 密碼:mrsoft,可以根據(jù)源碼自行修改。

信息界面:

寫(xiě)好運(yùn)行后就可以看到該界面。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#操作SQLite數(shù)據(jù)庫(kù)方法小結(jié)

    C#操作SQLite數(shù)據(jù)庫(kù)方法小結(jié)

    這篇文章介紹了C#操作SQLite數(shù)據(jù)庫(kù)的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • C#實(shí)現(xiàn)接收QQ郵件的示例代碼

    C#實(shí)現(xiàn)接收QQ郵件的示例代碼

    這篇文章主要為大家詳細(xì)介紹了C#如何使用pop協(xié)議來(lái)實(shí)現(xiàn)一下接收QQ郵件的功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2022-08-08
  • C#實(shí)現(xiàn)百度網(wǎng)站收錄和排名查詢功能思路及實(shí)例

    C#實(shí)現(xiàn)百度網(wǎng)站收錄和排名查詢功能思路及實(shí)例

    這篇文章主要介紹了C#實(shí)現(xiàn)百度網(wǎng)站收錄和排名查詢功能思路及實(shí)例,本文思路同樣適用必應(yīng)、搜狗、搜搜、360等搜索引擎,需要的朋友可以參考下
    2015-01-01
  • C#實(shí)現(xiàn)銀行家算法

    C#實(shí)現(xiàn)銀行家算法

    這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)銀行家算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • C#嵌套類的訪問(wèn)方法

    C#嵌套類的訪問(wèn)方法

    這篇文章主要介紹了C#嵌套類的訪問(wèn)方法,本文給出了嵌套類代碼和訪問(wèn)方法代碼,不會(huì)的同學(xué)照搬對(duì)照中的方法即可,需要的朋友可以參考下
    2015-04-04
  • Visual Studio 未能加載各種Package包的解決方案

    Visual Studio 未能加載各種Package包的解決方案

    打開(kāi)Visual Studio 的時(shí)候,總提示未能加載相應(yīng)的Package包,有時(shí)候還無(wú)法打開(kāi)項(xiàng)目,各種錯(cuò)誤提示,怎么解決呢?下面小編給大家?guī)?lái)了Visual Studio 未能加載各種Package包的解決方案,一起看看吧
    2016-10-10
  • C#簡(jiǎn)單實(shí)現(xiàn)表達(dá)式目錄樹(shù)(Expression)

    C#簡(jiǎn)單實(shí)現(xiàn)表達(dá)式目錄樹(shù)(Expression)

    表達(dá)式目錄樹(shù)以數(shù)據(jù)形式表示語(yǔ)言級(jí)別代碼。數(shù)據(jù)存儲(chǔ)在樹(shù)形結(jié)構(gòu)中。表達(dá)式目錄樹(shù)中的每個(gè)節(jié)點(diǎn)都表示一個(gè)表達(dá)式。這篇文章給大家介紹C#簡(jiǎn)單實(shí)現(xiàn)表達(dá)式目錄樹(shù)(Expression),需要的朋友參考下吧
    2017-11-11
  • C#保存listbox中數(shù)據(jù)到文本文件的方法

    C#保存listbox中數(shù)據(jù)到文本文件的方法

    這篇文章主要介紹了C#保存listbox中數(shù)據(jù)到文本文件的方法,涉及C#操作listbox數(shù)據(jù)的相關(guān)技巧,需要的朋友可以參考下
    2015-04-04
  • C#調(diào)用dos窗口獲取相關(guān)信息的方法

    C#調(diào)用dos窗口獲取相關(guān)信息的方法

    這篇文章主要介紹了C#調(diào)用dos窗口獲取相關(guān)信息的方法,涉及C#調(diào)用dos窗口及進(jìn)程操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-08-08
  • C#執(zhí)行存儲(chǔ)過(guò)程并將結(jié)果填充到GridView的方法

    C#執(zhí)行存儲(chǔ)過(guò)程并將結(jié)果填充到GridView的方法

    這篇文章主要介紹了C#執(zhí)行存儲(chǔ)過(guò)程并將結(jié)果填充到GridView的方法,結(jié)合實(shí)例形式分析了C#存儲(chǔ)過(guò)程操作及GridView控件相關(guān)操作技巧,需要的朋友可以參考下
    2017-02-02

最新評(píng)論

商洛市| 略阳县| 博客| 祁阳县| 宜兴市| 博湖县| 临洮县| 康马县| 揭东县| 岐山县| 南丰县| 囊谦县| 湘阴县| 崇仁县| 昭苏县| 丰原市| 北流市| 唐山市| 于都县| 乌鲁木齐市| 正镶白旗| 合阳县| 永城市| 合作市| 平邑县| 桑植县| 普安县| 沈阳市| 林甸县| 徐汇区| 吉安县| 杭州市| 通州区| 华池县| 万山特区| 贵定县| 大邑县| 茌平县| 横峰县| 天津市| 城口县|