private void FormCreateSale_Load(object sender, EventArgs e)
        {
            dateTimePicker1.Value = DateTime.Now;
            tbSalesman.Text       = InfoShareDLL.GetStaffName();
            lbSaleNumber.Text     = "XSD" + DateTime.Now.Year
                                    + DateTime.Now.Month + DateTime.Now.Day
                                    + DateTime.Now.Hour + DateTime.Now.Minute
                                    + DateTime.Now.Second + DateTime.Now.Millisecond.ToString();
            sumPrice          = 0.0;
            tbTotalPrice.Text = sumPrice.ToString("f") + "元";
            DataBaseOperationDLL dl = new DataBaseOperationDLL();

            //将支付方式绑定到支付方式文本框
            list = dl.GetDataInformation("payment_table", "payment_name");//从数据库中获取支付方式
            foreach (string str in list)
            {
                cbPayment.Items.Add(str);
                Console.WriteLine(str);
            }
            //将单位绑定到单位文本框
            list = dl.GetDataInformation("quantifier_table", "quantifier_name");//从数据库中获取单位名称
            foreach (string str in list)
            {
                cbQuantifier.Items.Add(str);
            }
        }
        public void FormProductSearch_Load(object sender, EventArgs e)
        {
            DataBaseOperationDLL db = new DataBaseOperationDLL();
            DataTable            dt = db.AllProductInformation();

            dataGridView1.DataSource = dt;
            List <string> list = new List <string>();

            foreach (DataRow dr in dt.Rows)
            {
                if (dr["product_number"].ToString().Length != 0)
                {
                    list.Add(dr["product_number"].ToString());
                }
                if (dr["product_name"].ToString().Length != 0)
                {
                    list.Add(dr["product_name"].ToString());
                }
            }
            AutoCompleteStringCollection source = new AutoCompleteStringCollection();

            source.AddRange(list.ToArray());
            tbNameOrNumber.AutoCompleteCustomSource = source;
            tbNameOrNumber.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbNameOrNumber.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            dataGridView1.ClearSelection();//清除选中状态
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("请先完善销售单!");
                return;
            }
            if (tbCustomer.TextLength == 0)
            {
                MessageBox.Show("请选择客户!");
                return;
            }
            if (cbPayment.Text.Length == 0)
            {
                MessageBox.Show("请选择支付方式!");
                return;
            }
            DataBaseOperationDLL db = new DataBaseOperationDLL();
            string dateTime         = dateTimePicker1.Text + " " + dateTimePicker1.Value.ToShortTimeString();
            int    paymentId        = db.GetPaymentId(cbPayment.Text);//获取员工编号
            int    chack            = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                chack += db.InsertSaleTable(lbSaleNumber.Text,
                                            int.Parse(row.Cells[9].Value.ToString()),
                                            float.Parse(row.Cells[4].Value.ToString()),
                                            double.Parse(row.Cells[6].Value.ToString()),
                                            InfoShareDLL.staffId,
                                            customerID,
                                            dateTime,
                                            paymentId,
                                            row.Cells["note"].Value.ToString()
                                            );
            }
            if (chack == dataGridView1.Rows.Count)
            {
                MessageBox.Show("开单成功!");
                form.Visible = true;
                this.Close();
                return;
            }
            MessageBox.Show("开单失败!");
        }