在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例Windows系统编程 → 童装店管理系统

童装店管理系统

Windows系统编程

下载此实例
  • 开发语言:C#
  • 实例大小:5.15M
  • 下载次数:86
  • 浏览次数:688
  • 发布时间:2016-05-28
  • 实例类别:Windows系统编程
  • 发 布 人:ahang007
  • 文件格式:.rar
  • 所需积分:2
 相关标签: 系统 管理

实例介绍

【实例简介】

这是一款童装店管理系统,可以打印条码入库,出库

【实例截图】

【核心代码】

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 Bear
{
    public partial class Frm_Sale : Form
    {
        SqlHelper helper = new SqlHelper();
        private string buyno;
        public Frm_Sale()
        {
            InitializeComponent();
            dgv.Columns.Add("prono", "产品编号");
            dgv.Columns.Add("procode", "货号");
            dgv.Columns.Add("proname", "产品名称");
            
            dgv.Columns.Add("saleprice", "单价");
            dgv.Columns.Add("pronum", "数量");
            dgv.Columns.Add("totalprice", "合计");
            dgv.Columns[0].Width = 140;
            dgv.Columns[1].Width = 120;
            dgv.Columns[2].Width = 400;
            dgv.Columns[3].Width = 100;
            dgv.Columns[4].Width = 100;
            dgv.Columns[5].Width = 200;
            dgv.Columns[0].ReadOnly = true;
            dgv.Columns[1].ReadOnly = true;
            dgv.Columns[2].ReadOnly = true;
            dgv.Columns[5].ReadOnly = true;
            dgv.RowsDefaultCellStyle.BackColor = Color.Aqua;
            dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
            txt_searchcustomer.Focus();
           
        }
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
            }
            base.OnKeyPress(e);
        }
        private void Frm_Sale_Resize(object sender, EventArgs e)
        {
            
        }

        private void txt_tel_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar != 8 && !char.IsDigit(e.KeyChar)) && e.KeyChar != 13)
            {
                MessageBox.Show("只能输入数字", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Handled = true;
            }
        }

        private void txt_searchcustomer_KeyPress(object sender, KeyPressEventArgs e)
        {
            
                if (e.KeyChar == 13)
                {
                    string stringsql = "select cusname,custel,cusjifen,remark,cusdate,cusid from customer where  custel='" txt_searchcustomer.Text.Trim() "'";
                    SqlHelper helper = new SqlHelper();
                    DataTable dt = helper.GetDataTable(stringsql);

                    if (dt.Rows.Count == 1)
                    {
                        txt_searchcustomer.Text = dt.Rows[0][0].ToString();
                        txt_tel.Text = dt.Rows[0][1].ToString();
                        if ((dt.Rows[0][2].ToString()) == "")
                            lb_jf.Text = "0";
                        lb_jf.Text = dt.Rows[0][2].ToString();
                        txt_customerremark.Text = dt.Rows[0][3].ToString();
                        lb_no.Text = dt.Rows[0][5].ToString();
                        lb_date.Text = DateTime.Now.ToShortDateString();
                        dt.Dispose();
                    }
                    else
                    {
                        
                        Frm_CustomerSearch frmsearchcustomer = new Frm_CustomerSearch(txt_searchcustomer .Text .Trim ());
                        frmsearchcustomer.SelectLivItem = new Frm_CustomerSearch.SelectLivItemEventHandler(this.ShowCustomer);
                        
                        frmsearchcustomer.ShowDialog ();
                      frmsearchcustomer.Dispose();
                        frmsearchcustomer.Text = "查找顾客窗口";
                        
                    }

                    txt_keywords.Focus();
                }
                


                
            
        }
        public void ShowCustomer(object sender,DataEventArgs e)
        {
            lb_no.Text = e._cusid;
            txt_searchcustomer.Text = e._cusname;
            txt_tel.Text = e._custel;
            txt_customerremark.Text = e._remark;
            lb_jf.Text = e._cusjifen;
        }
        public bool IfHaveProduct(DataGridView dv, string prono)
        {
            bool have = false;
            if (dv.Rows.Count > 0)
            {

                for (int i = 0; i < dv.Rows.Count; i )
                {
                    if (prono == dv.Rows[i].Cells[0].Value.ToString())
                        have = true;
                }
            }
            else
            {
                have = false;
            }
            
            return have;
        }
        private void txt_keywords_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                string stringsql = "select product_no,product_code,product_name,sale_price,product_num,remark from store where product_no = '" txt_keywords.Text.Trim() "'";
                SqlHelper helper = new SqlHelper();
                DataTable dt = helper.GetDataTable(stringsql);

                if (dt.Rows.Count == 1)
                {
                    if (IfHaveProduct(dgv, txt_keywords.Text.Trim())==false )
                    {
                        dgv.Rows.Add(new string[]
                        {
                         dt.Rows[0][0].ToString(),
                        dt.Rows[0][1].ToString(),
                        dt.Rows[0][2].ToString(),
                        dt.Rows[0][3].ToString(),
                        "1",
                        dt.Rows[0][3].ToString()
                        });
                    }
                    else
                    {
                        MessageBox.Show("已经存在该产品,请不要重复扫描", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    Frm_ProductSearch1 frmproductsearch = new Frm_ProductSearch1(dgv,txt_keywords .Text .Trim ());
                    frmproductsearch.ShowDialog();
                    frmproductsearch.Dispose();
                }


                txt_keywords.Text = "";
                txt_keywords.Focus();
            }
        }

        private void Frm_Sale_Load(object sender, EventArgs e)
        {

            buyno = helper.GetNo("S", "select max(rowid) from salerecord");
            label7.Text = buyno;
            lb_date.Text = DateTime.Now.ToShortDateString();
            rbtn_normal.Checked = true;
        }

        private void dgv_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            
            lb_num.Text = (Convert.ToInt32(lb_num.Text) 1).ToString();
            lb_price.Text = (Convert.ToDecimal(lb_price.Text) Convert.ToDecimal (dgv.Rows [e.RowIndex].Cells[5].Value)).ToString();
            dgv.CurrentCell = dgv.Rows[e.RowIndex].Cells[3];
        }

        private void dgv_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4 || e.ColumnIndex == 3)
            {
                dgv.Rows[e.RowIndex].Cells[5].Value = (Convert.ToInt32(dgv.Rows[e.RowIndex].Cells[4].Value) * Convert.ToDecimal(dgv.Rows[e.RowIndex].Cells[3].Value)).ToString();
                
                lb_num.Text = (GetSumNum(dgv)).ToString();
                lb_price.Text = (GetSumPrice(dgv)).ToString();
                
            }
           
        }

        private void dgv_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                decimal   result = 0;
                if(!decimal.TryParse (e.FormattedValue .ToString (),out result ))
                {
                    dgv.Rows [e.RowIndex ].ErrorText ="内容必须为浮点型";
                    e.Cancel =true ;
                }
            }
            if (e.ColumnIndex == 4)
            {
                int  result = 0;
                if(!int.TryParse (e.FormattedValue .ToString (),out result ))
                {
                    dgv.Rows [e.RowIndex ].ErrorText ="内容必须为数字";
                    e.Cancel = true;
                }
            }
        }
        public void dgv_DoubleClick(object sender, EventArgs e)
        {
           
        }
        public void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            dgv.Rows.RemoveAt(e.RowIndex);
            lb_price.Text = GetSumPrice(dgv).ToString();
            lb_num.Text = GetSumNum(dgv).ToString();
        }

        private void dgv_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
            }
        }

    
        public int GetSumNum(DataGridView dv)
        {
            int num = 0;
            if (dv.RowCount > 0)
            {
                for (int i = 0; i < dv.RowCount; i )
                {
                    num = Convert.ToInt32 (dv.Rows[i].Cells[4].Value.ToString());
                }
            }
            return num;
        }
        public decimal GetSumPrice(DataGridView dv)
        {
            decimal price = 0;
            if (dv.RowCount > 0)
            {
                for (int i = 0; i < dv.RowCount; i )
                {
                    price   = Convert.ToDecimal (dv.Rows[i].Cells[5].Value.ToString());
                }
            }
            return price;
        }

        private void btn_pay_Click(object sender, EventArgs e)
        {
            //if (lb_no.Text == "") return;
            if (txt_searchcustomer.Text == "")
            {
                MessageBox.Show("必须有顾客姓名!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (dgv.Rows.Count <= 0) return;
            btn_pay.Enabled = false;
            Frm_Pay frmpay = new Frm_Pay(lb_price,dgv);
            frmpay.saleno = label7.Text;
            frmpay.customerid = lb_no.Text;
            frmpay.totalnum = lb_num.Text;
            frmpay.paying = lb_price.Text;
            frmpay.custel = txt_tel.Text.Trim();
            frmpay.cusname = txt_searchcustomer.Text.Trim();
            frmpay.cusremark = txt_customerremark.Text.Trim ();
            frmpay.jifen = lb_price.Text;
            frmpay.old_jifen = lb_jf.Text;
            frmpay.ShowDialog();
        }

        private void Frm_Sale_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                btn_pay_Click(sender, e);
            }
        }

        private void txt_customerremark_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                txt_keywords.Focus();
        }

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

        private void tbtn_new_Click(object sender, EventArgs e)
        {
            btn_pay.Enabled = true;
            buyno = helper.GetNo("S", "select max(rowid) from salerecord");
            label7.Text = buyno;
            lb_date.Text = DateTime.Now.ToShortDateString();
            rbtn_normal.Checked = true;
            EmptyControls(groupBox1.Controls);
            lb_no.Text = "";
            lb_jf.Text = "0";
            lb_price.Text = "0.00";
            lb_num.Text = "0";
            dgv.Rows.Clear();
            //dgv.DataSource = null;
            
        }
        public void EmptyControls(Control.ControlCollection cc)
        {
            foreach (Control c in cc)
            {
                if (c.GetType().Name == "TextBox")  //判断是否为TextBox控件
                    if (((TextBox)c).Visible == true)   //判断当前控件是否为显示状态
                        ((TextBox)c).Clear();
                if (c.GetType().Name == "ComboBox")  //判断是否为ComboBox控件
                    if (((ComboBox)c).Visible == true)   //判断当前控件是否为显示状态
                        ((ComboBox)c).Text = ""; 
            }
            
        }

       
        //protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        //{
        //    if (keyData == Keys.Enter)
        //    {
        //        var curcell = dgv.CurrentCell;
        //        //判断当前单元格不是最后一列

        //        if (curcell.ColumnIndex < dgv.ColumnCount - 1)
        //        {
        //            //设置当前单元格为后一个单元格

        //            dgv.CurrentCell = dgv[curcell.ColumnIndex 1, curcell.RowIndex];
        //            //进入编辑模式

        //            dgv.BeginEdit(true);
        //            return true;
        //        }
        //    }
        //    return base.ProcessCmdKey(ref msg, keyData);
        //}
        //protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e)
        //{
        //    base.OnKeyUp(e);
        //    if (e.KeyCode == System.Windows.Forms.Keys.Enter)
        //    {
        //        e.Handled = true;

        //        System.Windows.Forms.SendKeys.Send("{TAB}");

        //    }
        //}      
    }
}


标签: 系统 管理

实例下载地址

童装店管理系统

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警