Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //获取textbox中的内容



            //2获取汽车品牌中的值
            string txtCarBrand = this.txtCarBrand.Text.ToString().Trim();

            //3获取进货价中的值
            string txtCarInPrice = this.txtCarInPrice.Text.ToString().Trim();

            //4获取买出价格中的值
            string txtCarOutPrice = this.txtCarOutPrice.Text.ToString().Trim();

            //5获取库存数量中的值
            string txtCarStock = this.txtCarStock.Text.ToString().Trim();

            //6获取汽车排量中的值
            string txtCarDisplacement = this.txtCarDisplacement.Text.ToString().Trim();
            //7汽车种类
            string txtCarSort = this.txtCarSort.Text.ToString().Trim();
            //8生产商
            string txtProductionID = this.txtProductionID.Text.ToString().Trim();

            //判断以上8个内容中的值是否为空
            if (txtCarBrand != "" && txtCarInPrice != "" && txtCarOutPrice != "" && txtCarStock != "" && txtCarDisplacement != "" && txtCarSort != "" && txtProductionID != "")
            {
                //编写sql插入语句
                string sql = string.Format("insert into CarInfo values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','1')", txtCarBrand, txtCarInPrice, txtCarOutPrice, txtCarStock, txtCarDisplacement, txtCarSort, txtProductionID);

                //执行SQL语句
                bool x = DBhelper.BuCha(sql);

                //判断是否执行成功
                if (x)
                {
                    MessageBox.Show("数据添加成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("数据添加失败!");
                }
            }
            else
            {
                MessageBox.Show("您输入的内容不能为空!");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string answer1 = this.textBox3.Text.ToString();
            string answer2 = this.textBox5.Text.ToString();
            string answer3 = this.textBox7.Text.ToString();

            if (answer1 != "" || answer2 != "" || answer3 != "")
            {
                SqlConnection conn   = new SqlConnection("Data Source=.;Initial Catalog=CarManagementSystem;Integrated Security=True");
                string        sql    = string.Format("select answer1,answer2,answer3 from UserInfo where UserNo='{0}'", ((LoginForm)(this.Owner)).userName);
                SqlDataReader reader = DBhelper.GetReader(sql);
                string        a1     = ""; //答案1
                string        a2     = ""; //答案2
                string        a3     = ""; //答案3
                while (reader.Read())
                {
                    a1 = reader["answer1"].ToString();
                    a2 = reader["answer2"].ToString();
                    a3 = reader["answer3"].ToString();
                }
                reader.Close();
                conn.Close();
                if (answer1 == a1 && answer2 == a2 && answer3 == a3)
                {
                    string s = string.Format("update UserInfo set UserPwd='123456' where UserNo='{0}'", ((LoginForm)(this.Owner)).userName);
                    bool   r = DBhelper.BuCha(s);
                    if (r)
                    {
                        MessageBox.Show("您的登陆密码已重置为:123456");
                        LoginForm lf = new LoginForm();
                        lf.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("重置密码失败!");
                    }
                }
                else
                {
                    MessageBox.Show("密保答案不正确!");
                }
            }
            else
            {
                MessageBox.Show("答案不能为空!");
            }
        }
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string id = this.dataGridView1.SelectedRows[0].Cells["UserNo"].Value.ToString();

            string sql = "delete from UserInfo where UserNo=" + id;
            bool   r   = DBhelper.BuCha(sql);

            if (r)
            {
                MessageBox.Show("删除成功!");
            }
            else
            {
                MessageBox.Show("删除失败!");
            }
        }
Beispiel #4
0
        private void year_Load(object sender, EventArgs e)
        {
            //纵向柱状统计图
            //编写sql语句
            string sql = "select * from year";

            // 将数据库的year表绑定到“chart1-横向柱状统计表” 中
            chart1.DataSource = DBhelper.Cha(sql).Tables[0];

            //横向柱状统计图
            // 将数据库的year表绑定到“chart1-横向柱状统计表” 中
            chart2.DataSource = DBhelper.Cha(sql).Tables[0];

            //圆盘统计图
            // 将数据库的year表绑定到“chart1-横向柱状统计表” 中
            chart3.DataSource = DBhelper.Cha(sql).Tables[0];

            //雷达图模式
            // 将数据库的year表绑定到“chart1-横向柱状统计表” 中
            chart4.DataSource = DBhelper.Cha(sql).Tables[0];
        }
Beispiel #5
0
        private void btnyes_Click(object sender, EventArgs e)
        {
            //获取厂商编号
            string txtProductionID = this.txtProductionID.Text.ToString().Trim();
            //获取采购价格
            string txtInPrice = this.txtInPrice.Text.ToString().Trim();
            //获取 采购数量
            string txtInNum = this.txtInNum.Text.ToString().Trim();
            //获取采购员编号
            string txtUserNo = this.txtUserNo.Text.ToString().Trim();
            //获取汽车编号
            string txtCarNo = this.txtCarNo.Text.ToString().Trim();

            //判断以上8个内容中的值是否为空
            if (txtProductionID != "" && txtInPrice != "" && txtInNum != "" && txtUserNo != "" && txtCarNo != "")
            {
                //编写sql插入语句
                string sql = string.Format("insert into PurchaseInfo values ('{0}','{1}','{2}','{3}','{4}','1')", txtProductionID, txtInPrice, txtInNum, txtUserNo, txtCarNo);
                //执行SQL语句
                bool x = DBhelper.BuCha(sql);

                //判断是否执行成功
                if (x)
                {
                    MessageBox.Show("数据添加成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("数据添加失败!");
                }
            }
            else
            {
                MessageBox.Show("您输入的内容不能为空!");
            }
        }
        private void btnyes_Click(object sender, EventArgs e)
        {
            //获取text中的值
            string gai = txtgai.Text.ToString().Trim();

            //判断rbSID
            if (rbProductionBrand.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 将text中的值进行数据类型转换


                    // 编写sql语句
                    string sql = string.Format("update ProductionInfo set  ProductionBrand='{0}' where ProductionID=  '{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }

            //判断rbTrademark
            else if (rbproductionPhone.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 编写sql语句
                    string sql = string.Format("update ProductionInfo set productionPhone='{0}' where ProductionID='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            //判断rbREM
            else if (rbproductionAddress.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 编写sql语句);
                    string sql = string.Format("update ProductionInfo set  productionAddress='{0}' where ProductionID='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
        }
        private void EmployeeManageForm_Load(object sender, EventArgs e)
        {
            string sql = "select u.UserNo JobNumder,o.CarNo VehicleNumber,u.UserName UserName,o.OrderDate SaleDate from UserInfo u left join OrderInfo o on u.UserNo=o.UserNo";

            this.dataGridView1.DataSource = DBhelper.Cha(sql).Tables[0];
        }
Beispiel #8
0
        private void Car_Load(object sender, EventArgs e)
        {
            string slq = string.Format("select * from CarInfo where Cancel= 1");

            dvcar.DataSource = DBhelper.Cha(slq).Tables[0];
        }
Beispiel #9
0
        private void btnyes_Click(object sender, EventArgs e)
        {
            //获取text中的值
            string gai = txtgai.Text.ToString().Trim();

            //判断rbSID
            if (rbCarBrand.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 将text中的值进行数据类型转换

                    // 编写sql语句
                    string sql = string.Format("update CarInfo set  CarBrand='{0}' where CarNo='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }

            //判断rbTrademark
            else if (rbCarInPrice.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 编写sql语句
                    string sql = string.Format("update CarInfo set CarInPrice='{0}' where CarNo='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            //判断rbREM
            else if (rbCarOutPrice.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    ;

                    // 编写sql语句);
                    string sql = string.Format("update CarInfo set  CarOutPrice='{0}' where CarNo='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            //判断rbMoney
            else if (rbCarStock.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 编写sql语句
                    string sql = string.Format("update CarInfo set CarStock='{0}' where CarNo='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            //判断rbDisplacement
            else if (rbCarDisplacement.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 编写sql语句
                    string sql = string.Format("update CarInfo set CarDisplacement='{0}' where CarNo='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            //判断rbDisplacement
            else if (rbCarSort.Checked)
            {
                // 判断两个tetxt中的值是否为空
                if (gai != "")
                {
                    // 编写sql语句
                    string sql = string.Format("update CarInfo set CarSort='{0}' where CarNo='{1}'", gai, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            //判断是否选择  rbGenre
            else if (rbProductionID.Checked)
            {
                // 判断两个txt中的值是否为空
                if (gai != "")
                {
                    // 将text中的值进行数据类型转换
                    int gui = int.Parse(txtgai.Text.ToString().Trim());

                    // 编写sql语句
                    string sql = string.Format("update CarInfo set   ProductionID='{0}' where CarNo='{1}'", gui, p);

                    // 执行sql命令
                    bool x = DBhelper.BuCha(sql);

                    //判断是否执行成功
                    if (x)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!!!");
                    }
                }
                else
                {
                    MessageBox.Show("您输入的内容不能为空");
                }
            }
            else
            {
                MessageBox.Show("请先选择您要修改的内容!");
            }
        }