⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jl_peijian.cs

📁 此系统开发了一个公交车管理系统。系统根据权限的不同
💻 CS
📖 第 1 页 / 共 2 页
字号:
                                    this.textBuyFitName.Clear();
                                    this.textBuyFitAver.Clear();
                                    this.textBuyFitCount.Clear();
                                    this.textBuyFitMoney.Clear();
                                    this.textBuyFitAddress.Clear();
                                    this.gridviewcar();

                                }
                                else
                                {

                                    MessageBox.Show("请选择要修改的项目 ");

                                }

                            }
                            else
                            {
                                MessageBox.Show("请选择要修改的项目 ");
                            }
                        }
                        else
                        {
                            MessageBox.Show("请选择要修改的项目");
                        }

                    }
                    else
                    {
                        MessageBox.Show("请选择要修改的项目");
                    }

                }
                else
                {
                    MessageBox.Show("请选择要修改的项目");
                }
            }
            else
            {
                MessageBox.Show("请选择要修改的项目");
            }
        }
        #endregion
        #region 显示gridview选中行的信息
        private void GridViewBuyFit_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //获取选中的行的信息
            this.textBuyFitStyle.SelectedItem = GridViewBuyFit.CurrentRow.Cells[1].Value.ToString();
            this.textCarKinds.Text = GridViewBuyFit.CurrentRow.Cells[2].Value.ToString();
            this.textBuyFitName.Text = GridViewBuyFit.CurrentRow.Cells[3].Value.ToString();
            this.textBuyFitAver.Text = GridViewBuyFit.CurrentRow.Cells[4].Value.ToString();
            this.textBuyFitCount.Text = GridViewBuyFit.CurrentRow.Cells[5].Value.ToString();
            this.textBuyFitMoney.Text = GridViewBuyFit.CurrentRow.Cells[6].Value.ToString();
            this.textBuyFitAddress.Text = GridViewBuyFit.CurrentRow.Cells[7].Value.ToString();
            this.dateTimeBuy.Value = Convert.ToDateTime(GridViewBuyFit.CurrentRow.Cells[8].Value.ToString());
        }
        #endregion
        #region (使用中)添加按钮
        private void btnUseFitAdd_Click(object sender, EventArgs e)
        {
            string UseFitCount1 = this.textUseFitCount.Text.ToString().Trim();
            string UseFitCount = " - " + UseFitCount1;
            string UserCarStyle = this.textUserCarStyle.SelectedItem.ToString();
            string UserCarKinds = this.textUserCarKinds.Text.ToString().Trim();
            string UseFitName = this.textUseFitName.Text.ToString().Trim();
            string UseFitAver = this.textUseFitAver.Text.ToString().Trim();
            string UseFitMoney1 = this.textUseFitMoney.Text.ToString().Trim();
            string UseFitMoney = "-" + UseFitMoney1;
            DateTime UseTime = Convert.ToDateTime(this.dateTimeUse.Value.ToShortDateString());

            if (UserCarKinds != "")
            {
                if (UseFitName != "")
                {
                    if (UseFitAver != "")
                    {
                        if (UseFitCount1 != "")
                        {
                            if (UseFitMoney1 != "")
                            {
                                string sql = "insert into db_fit(fit_style,fit_carkinds,fit_name,fit_price,fit_count,fit_totol,fit_time)values('" + UserCarStyle + "','" + UserCarKinds + "','" + UseFitName + "','" + UseFitAver + "','" + UseFitCount + "','" + UseFitMoney + "','" + UseTime + "')";
                                Car.ADU(sql);
                                //调用gridviewcar方法
                                this.gridviewcar2();
                                MessageBox.Show("添加成功");
                                this.textUseFitName.Clear();
                                this.textUseFitAver.Clear();
                                this.textUseFitCount.Clear();
                                this.textUseFitMoney.Clear();
                            }
                        }
                        else
                        {

                            MessageBox.Show("请将信息添加完整 ");

                        }

                    }
                    else
                    {
                        MessageBox.Show("请将信息添加完整 ");
                    }
                }
                else
                {
                    MessageBox.Show("请将信息添加完整");
                }

            }
            else
            {
                MessageBox.Show("请将信息添加完整");
            }

        }
        #endregion
        #region 查询按钮
        private void btnCheck_Click(object sender, EventArgs e)
        {
            string sqlstr = "select fit_id as 序号, fit_style as 配件类型,fit_carkinds as 车型,fit_name as 配件名称,fit_price as 配件单价,fit_count as 配件数量,fit_totol as 总金额,fit_palce as 购买地址,fit_time as 购买时间 from db_fit where 1 = 1";
            string CheckFitName = this.textCheckFitName.Text.ToString().Trim();
            string CheckFitCarKinds = this.textCheckFitCarKinds.Text.ToString().Trim();
            string CheckFitAdress = this.textCheckFitAdress.Text.ToString().Trim();
            string CheckFitKinds = this.textCheckFitKinds.SelectedItem.ToString();
            DateTime TimeCheck = Convert.ToDateTime(this.dateTimeCheck.Value.ToShortDateString());
            //调用config配置文件对象dl连接对象
            string dl = ConfigurationManager.AppSettings["sqlString"];
            //创建connection对象con进行连接
            SqlConnection con = new SqlConnection(dl);
            //打开连接
            con.Open();
            if (dateTimeCheck.Checked)
            {
                sqlstr = sqlstr + "and fit_time = '" + TimeCheck + "'";

            }
            if (CheckFitAdress != "")
            {
                sqlstr = sqlstr + "and fit_palce = '" + CheckFitAdress + "'";

            }
            if (CheckFitName != "")
            {
                sqlstr = sqlstr + "and fit_name = '" + CheckFitName + "'";

            }
            if (CheckFitKinds != "--未选择--")
            {
                sqlstr = sqlstr + "and fit_style = '" + CheckFitKinds + "'";
            }
            if (CheckFitKinds == "剩余")
            {
                sqlstr = "select fit_carkinds as 车型, fit_name as 配件名称,fit_price as 配件单价, sum(fit_count) as 剩余配件,sum(fit_totol) as 剩余金额 from db_fit  group by  fit_carkinds,fit_name,fit_price";
 
            }
            if (CheckFitCarKinds != "")
            {
                sqlstr = sqlstr + "and fit_carkinds = '"+CheckFitCarKinds+"'";
            }
            SqlCommand cmd = new SqlCommand(sqlstr, con);
            //创建读取器对象sdr
            SqlDataAdapter sdr = new SqlDataAdapter();
            //sdr的查询方法为cmd
            sdr.SelectCommand = cmd;
            //创建一个dataset容器
            DataSet ds = new DataSet();
            //填充数据ds
            sdr.Fill(ds);
            //绑定datagriview数据源为ds
            this.GridViewFitCheck.DataSource = ds.Tables[0].DefaultView;
            //关闭连接
            con.Close();
            //GridViewFitCheck.Columns[0].Width = 80;
            //GridViewFitCheck.Columns[1].Width = 80;
            //GridViewFitCheck.Columns[2].Width = 80;
            //GridViewFitCheck.Columns[3].Width = 80;
            //GridViewFitCheck.Columns[4].Width = 80;
            //GridViewFitCheck.Columns[5].Width = 80;
            //GridViewFitCheck.Columns[6].Width = 80;
            //GridViewFitCheck.Columns[7].Width = 80;
            //GridViewFitCheck.Columns[8].Width = 80;
        }
        #endregion        
        #region 清空按钮
        private void btnCheckClear_Click(object sender, EventArgs e)
        {
            this.textCheckFitName.Clear();
            this.textCheckFitAdress.Clear();
        }
        #endregion
        #region 使用中的显示选中行信息
        private void GridViewUse_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //获取选中的行的信息
            this.textUserCarStyle.SelectedItem = GridViewUse.CurrentRow.Cells[1].Value.ToString();
            this.textUserCarKinds.Text = GridViewUse.CurrentRow.Cells[2].Value.ToString();
            this.textUseFitName.Text = GridViewUse.CurrentRow.Cells[3].Value.ToString();
            this.textUseFitAver.Text = GridViewUse.CurrentRow.Cells[4].Value.ToString();
            this.textUseFitCount.Text = GridViewUse.CurrentRow.Cells[5].Value.ToString();
            this.textUseFitMoney.Text = GridViewUse.CurrentRow.Cells[6].Value.ToString();
            this.dateTimeUse.Value = Convert.ToDateTime(GridViewUse.CurrentRow.Cells[7].Value.ToString());
        }
        #endregion
        #region (配件使用)删除按钮
        private void btnUseFitDelete_Click(object sender, EventArgs e)
        {
            //获取选中的行的信息
            object row = (object)this.GridViewUse.CurrentRow.Cells[0].Value.ToString().Trim();
            DialogResult drm = MessageBox.Show("确定要删除吗?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            if (drm == DialogResult.OK)
            {
                //创建sql语句将信息从库中调出
                string sql = "delete db_fit where fit_id = '" + row + "'";
                Car.ADU(sql);
                this.textUseFitName.Clear();
                this.textUseFitAver.Clear();
                this.textUseFitCount.Clear();
                this.textUseFitMoney.Clear();
                this.gridviewcar2();
                MessageBox.Show("删除成功");
            }
            else
            {
                MessageBox.Show("请选择要删除的选项");
            }
        }
        #endregion
        #region 修改按钮(使用)
        private void btnUseFitUpdate_Click(object sender, EventArgs e)
        {
            string UserCarStyle = this.textUserCarStyle.SelectedItem.ToString();
            string UserCarKinds = this.textUserCarKinds.Text.ToString().Trim();
            string UseFitName = this.textUseFitName.Text.ToString().Trim();
            string UseFitAver = this.textUseFitAver.Text.ToString().Trim();
            string UseFitCount = this.textUseFitCount.Text.ToString().Trim();
            string UseFitMoney = this.textUseFitMoney.Text.ToString().Trim();
            DateTime UseTime = Convert.ToDateTime(this.dateTimeUse.Value.ToShortDateString());
            int ID = Convert.ToInt32(GridViewUse.CurrentRow.Cells[0].Value.ToString());

              if (UserCarKinds != "")
                {
                    if (UseFitMoney != "")
                    {
                        if (UseFitName != "")
                        {
                            if (UseFitAver != "")
                            {
                                if (UseFitCount != "")
                                {
                                    string sql = "update db_fit set fit_style ='" + UserCarStyle + "', fit_carkinds ='" + UserCarKinds + "' , fit_name='" + UseFitName + "',fit_price = '" + UseFitAver + "',fit_count = '" + UseFitCount + "',fit_totol='" + UseFitMoney + "',fit_time ='" + UseTime + "'   where fit_id ='" + ID + "'";
                                    Car.ADU(sql);
                                    this.gridviewcar();
                                    MessageBox.Show("修改成功");
                                    this.textUseFitName.Clear();
                                    this.textUseFitAver.Clear();
                                    this.textUseFitCount.Clear();
                                    this.textUseFitMoney.Clear();
                                    this.gridviewcar2();

                                }
                                else
                                {

                                    MessageBox.Show("请选择要修改的项目 ");

                                }

                            }
                            else
                            {
                                MessageBox.Show("请选择要修改的项目 ");
                            }
                        }
                        else
                        {
                            MessageBox.Show("请选择要修改的项目");
                        }

                    }
                    else
                    {
                        MessageBox.Show("请选择要修改的项目");
                    }

                }
                else
                {
                    MessageBox.Show("请选择要修改的项目");
                }
        }
        #endregion

        private void btnCheckClear_Click_1(object sender, EventArgs e)
        {
            this.textUseFitName.Clear();
            this.textUseFitAver.Clear();
            this.textUseFitCount.Clear();
            this.textUseFitMoney.Clear();
        }
    }
}


       
    



                                     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -