IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> 基于C#WPF和SQL server的小管理系统 -> 正文阅读

[大数据]基于C#WPF和SQL server的小管理系统

大二上c#课程的大作业,有需要的可以借鉴一下。点个赞就行

?

下载地址:阿里云盘分享https://www.aliyundrive.com/s/ztMFnB7Z7Pt

有条件的hxd也可以支持一波:基于C#WPF和SQLserver的小管理系统-C#文档类资源-CSDN下载

本小系统基于wpf和SQL server构建。

大致框架如下图所示,数据库文件在SQL server中

?实现了增删改查,以及注册等功能。

增:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace bigwork
{
    /// <summary>
    /// zeng.xaml 的交互逻辑
    /// </summary>
    public partial class Add : Window
    {
        public Add()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string strCon = @"Data Source=.;Initial Catalog=Phone_manager;Integrated Security=True";
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            var phonename = textbox1.Text;
            var name = textbox2.Text;
            var pwd = textbox3.Text;
            var cost = textbox4.Text;
            var balance = textbox5.Text;
            while (true)
            {
                if (textbox1.Text == "")
                {
                    MessageBox.Show("电话号码不能为空");
                    break;
                }
                if (textbox2.Text == "")
                {
                    MessageBox.Show("名字不能为空");
                    break;
                }
                if (textbox3.Text == "")
                {
                    MessageBox.Show("密码不能为空");
                    break;
                }
                if (textbox4.Text == "")
                {
                    MessageBox.Show("消费不能为空");
                    break;
                }
                if (textbox5.Text == "")
                {
                    MessageBox.Show("余额不能为空");
                    break;
                }
                string sql = "INSERT INTO god(number,name,password,cost,balance) VALUES (@phonename,@name,@pwd,@cost,@balance)";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.Connection = con;
            cmd.Parameters.AddWithValue("@phonename", phonename);
            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@pwd", pwd);
            cmd.Parameters.AddWithValue("@cost", cost);
            cmd.Parameters.AddWithValue("@balance", balance);
            int i = cmd.ExecuteNonQuery();
            // while (true)
            // {
            if (i > 0)
            {
                MessageBox.Show("添加成功");
                    break;
            }
            else
            {
                MessageBox.Show("添加失败");
                    // Add add = new Add();
                    // add.ShowDialog();
                    continue;

            }
            }
            con.Close();

        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            this.Hide();
            Administration administration= new  Administration();
            administration.ShowDialog();
        }
    }
}

删:

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace bigwork
{
    /// <summary>
    /// shan.xaml 的交互逻辑
    /// </summary>
    public partial class Deletess : Window
    {
        public Deletess()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            string strCon = @"Data Source=.;Initial Catalog=Phone_manager;Integrated Security=True";
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            String sql = "delete from god  where number=" + "\'" + textbox1.Text + "\'";
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Connection = con;
            while (true)
            {
                if (textbox1.Text == "")
                {
                    MessageBox.Show("电话号码不能为空");
                    break;
                }
                //var phonenumber = textbox1.Text;



                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("删除成功");
                    textbox1.Text = "";
                    break;
                }
                else
                {
                    MessageBox.Show("删除失败");
                    break;
                }
            }
            con.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            this.Hide();
           Administration administration = new Administration();
            administration.ShowDialog();
        }
    }
}

改:

using System;
using System.Data.SqlClient;
using System.Windows;
namespace bigwork
{
    /// <summary>
    /// gai.xaml 的交互逻辑
    /// </summary>
    public partial class Changess : Window
    {
        public Changess()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var balance = textbox1.Text;
            var name = textbox2.Text;
            var pwd = textbox3.Text;
            var phonenumber = textbox4.Text;
            var cost = textbox5.Text;
            string strCon = @"Data Source=.;Initial Catalog=Phone_manager;Integrated Security=True";
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            while (true)
            {
                if (textbox1.Text == "")
                {
                    MessageBox.Show("余额不能为空");
                    break;
                }
                if (textbox2.Text == "")
                {
                    MessageBox.Show("名字不能为空");
                    break;
                }
                if (textbox3.Text == "")
                {
                    MessageBox.Show("密码不能为空");
                    break;
                }
                if (textbox4.Text == "")
                {
                    MessageBox.Show("电话号码不能为空");
                    break;
                }
                if (textbox5.Text == "")
                {
                    MessageBox.Show("消费不能为空");
                    break;
                }
              
                //update god set cost = '100', balance = '100', password = '321'  where number = '110'and name = 'pdd';
                String sql = "update god set  cost = " + "\'" + cost + "\'" + ",balance= " + "\'" + balance + "\'" + ",password=" + "\'" + pwd + "\'" + "where number=" + "\'" + phonenumber + "\'" + " and name=" + "\'" + name + "\'";
                SqlCommand cmd = new SqlCommand(sql, con);

                int hang = cmd.ExecuteNonQuery();
                if (hang > 0)
                {
                    MessageBox.Show("修改成功");
                    break;
                }
                else
                {
                    MessageBox.Show("修改失败");
                    continue;
                }
            }
            con.Close();
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            this.Hide();
            Administration administration = new Administration();
            administration.ShowDialog();
        }
    }
}

查:

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace bigwork
{
    /// <summary>
    /// yhjm.xaml 的交互逻辑
    /// </summary>
    public partial class Userss : Window
    {
        public Userss()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string strCon = @"Data Source=.;Initial Catalog=Phone_manager;Integrated Security=True";
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            var phonenumber = textbox1.Text;
            while (true)
            {
                if (textbox1.Text == "")
                {
                    MessageBox.Show("查询不能为空");
                    break;
                }
                //String sql = "select balance from god where number=" + "\'" + (phonenumber) + "\'";
                SqlCommand cmd = new SqlCommand("select balance, cost from god where number = @phonenumber", con);
                cmd.Parameters.AddWithValue("@phonenumber", phonenumber);
                SqlDataReader myReader = cmd.ExecuteReader();
                myReader.Read();
                if (myReader.HasRows)
                {
                    label2.Content = Convert.ToString(myReader["balance"]);

                    label3.Content = Convert.ToString(myReader["cost"]);
                    break;
                }
                else
                {
                    label2.Content = "";
                    label3.Content = "";
                    MessageBox.Show("不存在");
                    break;
                }
            }
                //将两次的查询结果显示出来
                con.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {

            Environment.Exit(0);

        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            this.Hide();
            Sign_in_2 sign = new Sign_in_2();
            sign.ShowDialog();


        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("请拨打10086");
        }
    }
}

登录:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace bigwork
{
    /// <summary>
    /// login2.xaml 的交互逻辑
    /// </summary>
    public partial class Sign_in_2 : Window
    {
        public Sign_in_2()
        {
            InitializeComponent();
        }


        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string strCon = @"Data Source=.;Initial Catalog=Phone_manager;Integrated Security=True";
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            var phonename = textbox1.Text;
            var pwd = textbox2.Password;
            while (true)
            {
                if (textbox1.Text == "")
                {
                    MessageBox.Show("id不能为空");
                    break;
                }
                if (textbox2.Password == "")
                {
                    MessageBox.Show("密码不能为空");
                    break;
                }

                SqlCommand cmd = new SqlCommand("select number,password from god where number=@phonename and password=@pwd", con);
                cmd.Connection = con;
                cmd.Parameters.AddWithValue("@phonename", phonename);
                cmd.Parameters.AddWithValue("@pwd", pwd);
                SqlDataReader read = cmd.ExecuteReader();
                while (true)
                {
                    if (read.Read())
                    {
                        MessageBox.Show("登录成功");
                        Userss userss = new Userss();
                        userss.ShowDialog();

                    }

                    else
                    {
                        textbox1.Text = "";
                        textbox2.Password = "";
                        MessageBox.Show("用户名或密码错误");
                        Sign_in_2 signs = new Sign_in_2();
                        signs.ShowDialog();
                    }
                }



                

            }
            con.Close();


        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            User_register user_Register = new User_register();
            user_Register.ShowDialog();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }



        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            this.Hide();
            MainWindow mw = new MainWindow();
            mw.ShowDialog();
        }
    }
}

数据库部分:

管理员字段:

用户字段:

?

?

  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2022-02-09 20:46:17  更:2022-02-09 20:47:51 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 14:01:22-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码