Example #1
0
        // 确认修改
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("确认修改 ? ", "提示", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                BillPO billPO = new BillPO();
                billPO.Billid = textBox1.Text;
                //billPO.GuestName = comboBox1.SelectedItem.ToString();
                billPO.Xinghao     = comboBox2.SelectedItem.ToString();
                billPO.Zhonglei    = comboBox3.SelectedItem.ToString();
                billPO.Color       = textBox10.Text;
                billPO.Num         = Convert.ToInt32(textBox3.Text);
                billPO.SinglePrice = Convert.ToDouble(textBox4.Text);
                billPO.TotalPrice  = Convert.ToDouble(textBox4.Text) * Convert.ToDouble(textBox3.Text);
                billPO.OtherText   = textBox9.Text;
                MysqlManager manager = new MysqlManager();
                int          result  = manager.UpdateBill(billPO);
                if (result == 1)
                {
                    MessageBox.Show("修改成功 !");
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
                this.Close();
            }
        }
Example #2
0
        // 页面加载时  加载查询的数据
        private void UpdateBill_Load(object sender, EventArgs e)
        {
            xinghao  = ConfigHelper.GetAppConfig("xinghao");
            zhonglei = ConfigHelper.GetAppConfig("zhonglei");
            color    = ConfigHelper.GetAppConfig("color");
            //comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox3.DropDownStyle = ComboBoxStyle.DropDownList;
            //comboBox4.DropDownStyle = ComboBoxStyle.DropDownList;
            String[] xinghaos  = xinghao.Split('.');
            String[] zhongleis = zhonglei.Split('.');
            String[] colors    = color.Split('.');
            // 从数据库读取用户
            MysqlManager manager = new MysqlManager();

            //DataTable table = manager.getGuestNames();
            //String[] guests = new string[table.Rows.Count];
            //for (int i = 0; i < table.Rows.Count; i++)
            //{
            //    comboBox1.Items.Add(table.Rows[i]["name"]);
            //}

            for (int i = 0; i < xinghaos.Length; i++)
            {
                comboBox2.Items.Add(xinghaos[i]);
            }

            for (int i = 0; i < zhongleis.Length; i++)
            {
                comboBox3.Items.Add(zhongleis[i]);
            }

            //for (int i = 0; i < colors.Length; i++)
            //{
            //    comboBox4.Items.Add(colors[i]);
            //}

            // 表单填上原来的值
            BillPO bill = manager.getBillPObyBillid(billid);

            textBox1.Text = bill.Billid;
            //comboBox1.SelectedIndex = comboBox1.FindString(bill.GuestName);
            comboBox2.SelectedIndex = comboBox2.FindString(bill.Xinghao);
            comboBox3.SelectedIndex = comboBox3.FindString(bill.Zhonglei);
            //comboBox4.SelectedIndex = comboBox4.FindString(bill.Color);

            textBox10.Text = bill.Color.ToString();
            textBox3.Text  = bill.Num.ToString();
            textBox4.Text  = bill.SinglePrice.ToString();
            textBox5.Text  = bill.TotalPrice.ToString();
            textBox9.Text  = bill.OtherText;
        }
Example #3
0
        //确定插入
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == "")
            {
                MessageBox.Show("数量不能为空");
            }
            else if (textBox4.Text == "")
            {
                MessageBox.Show("单价不能为空");
            }

            else if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("请选择用户名称");
            }
            else if (comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("请选择型号");
            }
            else if (comboBox3.SelectedIndex == -1)
            {
                MessageBox.Show("请选择种类");
            }
            else if (textBox11.Text == "")
            {
                MessageBox.Show("请输入颜色");
            }
            else
            {
                form1.preColor = textBox11.Text;

                bill        = new BillPO();
                bill.Billid = textBox1.Text = DateTime.Now.ToString("yyyyMMddHHmmss") + comboBox1.SelectedItem.ToString() + (form1.dataGridView2.Rows.Count + 1);
                // 客户名称
                bill.GuestName = comboBox1.SelectedItem.ToString();
                // 型号
                bill.Xinghao  = comboBox2.SelectedItem.ToString();
                bill.Zhonglei = comboBox3.SelectedItem.ToString();
                //bill.Color = comboBox4.SelectedItem.ToString();
                bill.Color       = textBox11.Text;
                bill.Danwei      = textBox2.Text;
                bill.Num         = int.Parse(textBox3.Text);
                bill.SinglePrice = double.Parse(textBox4.Text);

                // 单价 *  数量
                bill.TotalPrice = double.Parse(textBox3.Text) * double.Parse(textBox4.Text);
                //bill.TotalPrice = double.Parse(textBox5.Text);
                bill.Kaipiaor = textBox6.Text;
                bill.Jinshour = textBox7.Text;
                bill.PicPath  = "无";
                //bill.KaipiaoDate = DateTime.Now.ToString("yyyyMMddHHmmss");
                bill.Address   = textBox8.Text; // 无
                bill.OtherText = textBox9.Text;

                // 插入datagridview 中
                DataGridViewRow row   = new DataGridViewRow();
                int             index = form1.dataGridView2.Rows.Add(row);
                form1.dataGridView2.Rows[index].Cells[0].Value = bill.Billid;
                form1.dataGridView2.Rows[index].Cells[1].Value = bill.GuestName;
                form1.dataGridView2.Rows[index].Cells[2].Value = bill.Xinghao;
                form1.dataGridView2.Rows[index].Cells[3].Value = bill.Zhonglei;
                form1.dataGridView2.Rows[index].Cells[4].Value = bill.Color;
                form1.dataGridView2.Rows[index].Cells[5].Value = bill.Num;
                form1.dataGridView2.Rows[index].Cells[6].Value = bill.SinglePrice;
                form1.dataGridView2.Rows[index].Cells[7].Value = bill.TotalPrice;
                form1.dataGridView2.Rows[index].Cells[8].Value = bill.OtherText;
                this.Close();
            }
        }