基本信息
源码名称:童装店管理系统
源码大小:5.15M
文件格式:.rar
开发语言:C#
更新时间:2016-05-28
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 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}");

        //    }
        //}      
    }
}