找传奇、传世资源到传世资源站!

C#进销存管理系统(明日)实例源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

主要实现了支持多条件查询、批量填写进货单及销售单、与代理商和供应商往来账本明细,绝不存在假账、漏账、差账等情况、图表分析月销售状况、当外界环境(停电、网络病毒)干扰本系统时,系统可以自动保护原始数据的安全、强大的报表打印等功能。

from clipboard

C#进销存管理系统(明日)实例源码 C#语言基础-第2张
from clipboard
from clipboard
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace EMS.BuyStock
{
    public partial class frmBuyStock : Form
    {
        BaseClass.BaseInfo baseinfo = new EMS.BaseClass.BaseInfo();
        BaseClass.cBillInfo billinfo = new EMS.BaseClass.cBillInfo();
        BaseClass.cCurrentAccount currentAccount = new EMS.BaseClass.cCurrentAccount();
        BaseClass.cStockInfo stockinfo = new EMS.BaseClass.cStockInfo();
       
        public frmBuyStock()
        {
            InitializeComponent();
        }        private void frmBuyStock_Load(object sender, EventArgs e)
        {
            txtBillDate.Text = DateTime.Now.ToString("yyyy-MM-dd");            DataSet ds = null;
            string P_Str_newBillCode = "";
            int P_Int_newBillCode = 0;            ds = baseinfo.GetAllBill("tb_warehouse_main");
            if (ds.Tables[0].Rows.Count == 0)
            {
                txtBillCode.Text = DateTime.Now.ToString("yyyyMMdd") "JH" "1000001";
            }
            else
            {
                P_Str_newBillCode = Convert.ToString(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["billcode"]);
                P_Int_newBillCode = Convert.ToInt32(P_Str_newBillCode.Substring(10, 7)) 1;
                P_Str_newBillCode = DateTime.Now.ToString("yyyyMMdd") "JH" P_Int_newBillCode.ToString();
                txtBillCode.Text = P_Str_newBillCode;
            }
            txtHandle.Focus();
        }        private void btnSelectHandle_Click(object sender, EventArgs e)
        {
            EMS.SelectDataDialog.frmSelectHandle selecthandle;
            selecthandle=  new EMS.SelectDataDialog.frmSelectHandle();
            selecthandle.buyStock = this;          //将新创建的窗体对象设置为同一个窗体类的实例(对象)
            selecthandle.M_str_object = "BuyStock";  //用于识别 是那一个窗体调用的selecthandle窗口的
            selecthandle.ShowDialog();
        }        private void btnSave_Click(object sender, EventArgs e)
        {
            //往来单位和经手人不能为空!
            if (txtHandle.Text == string.Empty || txtUnits.Text == string.Empty)
            {
                MessageBox.Show("供货单位和经手人为必填项!", "错误提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            //列表中数据不能为空
            if (Convert.ToString(dgvStockList[3, 0].Value) == string.Empty || Convert.ToString(dgvStockList[4, 0].Value) == string.Empty || Convert.ToString(dgvStockList[5, 0].Value) == string.Empty)
            {
                MessageBox.Show("请核实列表中数据:‘数量’、‘单价’、‘金额’不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //应付金额不能为空
            if (txtFullPayment.Text.Trim() == "0")
            {
                MessageBox.Show("应付金额不能为‘0’!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }            //向进货表(主表)录入商品单据信息
            billinfo.BillCode = txtBillCode.Text;
            billinfo.Handle = txtHandle.Text;
            billinfo.Units = txtUnits.Text;
            billinfo.Summary = txtSummary.Text;
            billinfo.FullPayment =Convert.ToSingle(txtFullPayment.Text);
            billinfo.Payment = Convert.ToSingle(txtpayment.Text);
            //执行添加
            baseinfo.AddTableMainWarehouse(billinfo, "tb_warehouse_main");            //向进货(明细表)中录入商品单据信息
            for (int i = 0; i < dgvStockList.RowCount-1; i )
            {
                    billinfo.BillCode = txtBillCode.Text;
                    billinfo.TradeCode = dgvStockList[0, i].Value.ToString();
                    billinfo.FullName = dgvStockList[1, i].Value.ToString();
                    billinfo.TradeUnit = dgvStockList[2, i].Value.ToString();
                    billinfo.Qty = Convert.ToSingle(dgvStockList[3, i].Value.ToString());
                    billinfo.Price = Convert.ToSingle(dgvStockList[4, i].Value.ToString());
                    billinfo.TSum = Convert.ToSingle(dgvStockList[5, i].Value.ToString());
                    //执行多行录入数据(添加到明细表中)
                    baseinfo.AddTableDetailedWarehouse(billinfo, "tb_warehouse_detailed");
                //更改库存数量和加权平均价格
                    DataSet ds = null;
                stockinfo.TradeCode=dgvStockList[0, i].Value.ToString();
                ds=baseinfo.GetStockByTradeCode(stockinfo, "tb_Stock");                stockinfo.Qty =Convert.ToSingle(ds.Tables[0].Rows[0]["qty"]);
                stockinfo.Price =Convert.ToSingle(ds.Tables[0].Rows[0]["price"]);
                stockinfo.AveragePrice = Convert.ToSingle(ds.Tables[0].Rows[0]["averageprice"]);
                //处理--加权平均价格
                if (stockinfo.Price == 0)
                {
                    stockinfo.AveragePrice = billinfo.Price;   //第一次进货时,加权平均价格等于进货价格
                    stockinfo.Price = billinfo.Price;
                }
                else
                {
                    //加权平均价格=(加权平均价*库存总数量 本次进货价格*本次进货数量)/(库存总数量 本次进货数量)
                    stockinfo.AveragePrice = ((stockinfo.AveragePrice * stockinfo.Qty billinfo.Price * billinfo.Qty) / (stockinfo.Qty billinfo.Qty));
                }
                //更新--商品库存数量
                stockinfo.Qty = stockinfo.Qty billinfo.Qty;
                int d = baseinfo.UpdateStock_QtyAndAveragerprice(stockinfo);
               
            }
            //向往来单位明细表--录入数据--这样以来为分析
            currentAccount.BillCode = txtBillCode.Text;
            currentAccount.ReduceGathering =Convert.ToSingle(txtFullPayment.Text);
            currentAccount.FactReduceGathering =Convert.ToSingle(txtpayment.Text);
            currentAccount.Balance =Convert.ToSingle(txtBalance.Text);
            currentAccount.Units = txtUnits.Text;
            //执行添加
            int ca = baseinfo.AddCurrentAccount(currentAccount);
            MessageBox.Show("进货单--过账成功!","成功提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            this.Close();
        }
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace EMS.BuyStock
{
    public partial class frmBuyStock : Form
    {
        BaseClass.BaseInfo baseinfo = new EMS.BaseClass.BaseInfo();
        BaseClass.cBillInfo billinfo = new EMS.BaseClass.cBillInfo();
        BaseClass.cCurrentAccount currentAccount = new EMS.BaseClass.cCurrentAccount();
        BaseClass.cStockInfo stockinfo = new EMS.BaseClass.cStockInfo();
       
        public frmBuyStock()
        {
            InitializeComponent();
        }        private void frmBuyStock_Load(object sender, EventArgs e)
        {
            txtBillDate.Text = DateTime.Now.ToString("yyyy-MM-dd");            DataSet ds = null;
            string P_Str_newBillCode = "";
            int P_Int_newBillCode = 0;            ds = baseinfo.GetAllBill("tb_warehouse_main");
            if (ds.Tables[0].Rows.Count == 0)
            {
                txtBillCode.Text = DateTime.Now.ToString("yyyyMMdd") "JH" "1000001";
            }
            else
            {
                P_Str_newBillCode = Convert.ToString(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["billcode"]);
                P_Int_newBillCode = Convert.ToInt32(P_Str_newBillCode.Substring(10, 7)) 1;
                P_Str_newBillCode = DateTime.Now.ToString("yyyyMMdd") "JH" P_Int_newBillCode.ToString();
                txtBillCode.Text = P_Str_newBillCode;
            }
            txtHandle.Focus();
        }        private void btnSelectHandle_Click(object sender, EventArgs e)
        {
            EMS.SelectDataDialog.frmSelectHandle selecthandle;
            selecthandle=  new EMS.SelectDataDialog.frmSelectHandle();
            selecthandle.buyStock = this;          //将新创建的窗体对象设置为同一个窗体类的实例(对象)
            selecthandle.M_str_object = "BuyStock";  //用于识别 是那一个窗体调用的selecthandle窗口的
            selecthandle.ShowDialog();
        }        private void btnSave_Click(object sender, EventArgs e)
        {
            //往来单位和经手人不能为空!
            if (txtHandle.Text == string.Empty || txtUnits.Text == string.Empty)
            {
                MessageBox.Show("供货单位和经手人为必填项!", "错误提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            //列表中数据不能为空
            if (Convert.ToString(dgvStockList[3, 0].Value) == string.Empty || Convert.ToString(dgvStockList[4, 0].Value) == string.Empty || Convert.ToString(dgvStockList[5, 0].Value) == string.Empty)
            {
                MessageBox.Show("请核实列表中数据:‘数量’、‘单价’、‘金额’不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //应付金额不能为空
            if (txtFullPayment.Text.Trim() == "0")
            {
                MessageBox.Show("应付金额不能为‘0’!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }            //向进货表(主表)录入商品单据信息
            billinfo.BillCode = txtBillCode.Text;
            billinfo.Handle = txtHandle.Text;
            billinfo.Units = txtUnits.Text;
            billinfo.Summary = txtSummary.Text;
            billinfo.FullPayment =Convert.ToSingle(txtFullPayment.Text);
            billinfo.Payment = Convert.ToSingle(txtpayment.Text);
            //执行添加
            baseinfo.AddTableMainWarehouse(billinfo, "tb_warehouse_main");            //向进货(明细表)中录入商品单据信息
            for (int i = 0; i < dgvStockList.RowCount-1; i )
            {
                    billinfo.BillCode = txtBillCode.Text;
                    billinfo.TradeCode = dgvStockList[0, i].Value.ToString();
                    billinfo.FullName = dgvStockList[1, i].Value.ToString();
                    billinfo.TradeUnit = dgvStockList[2, i].Value.ToString();
                    billinfo.Qty = Convert.ToSingle(dgvStockList[3, i].Value.ToString());
                    billinfo.Price = Convert.ToSingle(dgvStockList[4, i].Value.ToString());
                    billinfo.TSum = Convert.ToSingle(dgvStockList[5, i].Value.ToString());
                    //执行多行录入数据(添加到明细表中)
                    baseinfo.AddTableDetailedWarehouse(billinfo, "tb_warehouse_detailed");
                //更改库存数量和加权平均价格
                    DataSet ds = null;
                stockinfo.TradeCode=dgvStockList[0, i].Value.ToString();
                ds=baseinfo.GetStockByTradeCode(stockinfo, "tb_Stock");                stockinfo.Qty =Convert.ToSingle(ds.Tables[0].Rows[0]["qty"]);
                stockinfo.Price =Convert.ToSingle(ds.Tables[0].Rows[0]["price"]);
                stockinfo.AveragePrice = Convert.ToSingle(ds.Tables[0].Rows[0]["averageprice"]);
                //处理--加权平均价格
                if (stockinfo.Price == 0)
                {
                    stockinfo.AveragePrice = billinfo.Price;   //第一次进货时,加权平均价格等于进货价格
                    stockinfo.Price = billinfo.Price;
                }
                else
                {
                    //加权平均价格=(加权平均价*库存总数量 本次进货价格*本次进货数量)/(库存总数量 本次进货数量)
                    stockinfo.AveragePrice = ((stockinfo.AveragePrice * stockinfo.Qty billinfo.Price * billinfo.Qty) / (stockinfo.Qty billinfo.Qty));
                }
                //更新--商品库存数量
                stockinfo.Qty = stockinfo.Qty billinfo.Qty;
                int d = baseinfo.UpdateStock_QtyAndAveragerprice(stockinfo);
               
            }
            //向往来单位明细表--录入数据--这样以来为分析
            currentAccount.BillCode = txtBillCode.Text;
            currentAccount.ReduceGathering =Convert.ToSingle(txtFullPayment.Text);
            currentAccount.FactReduceGathering =Convert.ToSingle(txtpayment.Text);
            currentAccount.Balance =Convert.ToSingle(txtBalance.Text);
            currentAccount.Units = txtUnits.Text;
            //执行添加
            int ca = baseinfo.AddCurrentAccount(currentAccount);
            MessageBox.Show("进货单--过账成功!","成功提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            this.Close();
        }

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复