• 一个小型公司人工费用核算winform查询开发(1)


    开发思路:数据库一张表里存储所有员工薪酬数据,除了员工和时间信息,还有2个数字字段:薪酬、公司承担五险一金。一次性提取出来,然后利用c#对list的操作,包括linq技术。通过选择部门、员工、时间对员工薪酬进行随意查询。

    本小节用到的技术:连接数据库提取数据到list中。其中private jmjm objjmjm = new jmjm();是对连接字符串的加密解密环节,可以忽视。

    1.这是人工核算的类

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace Models
    {
        [Serializable]
        public class rg
        {
            public bool fx { get; set; }  //复选
            public string year { get; set; }// 年
            public string month { get; set; }//月份
            public string bmbm { get; set; }//部门编码
            public string bmtxt { get; set; }//部门文本
            public string name { get; set; }//员工
            public string ygfl { get; set; } //员工分类
            public decimal xc { get; set; } //薪酬
            public decimal wxyj { get; set; } //企业承担五险一金
            public decimal total { get; set; } //总计
        }
    }

    基本和数据库表字段对应的,这是数据库表截图。分别对应如上。这个小查询一次性把历年所有数据都提取出来。

    2.数据库取数代码

     下面是连接数据库的代码 放入List

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Data;
    using System.Data.SqlClient;
    using Models;
    using Oracle.ManagedDataAccess.Client;
    using System.Collections;
    using System.Configuration;
    using System.Windows.Forms;

    namespace DAL
    {
       public class rgdataprocess
        {

            private jmjm objjmjm = new jmjm();

            private static string connString_ORACLE = ConfigurationManager.ConnectionStrings["connString_oracle"].ToString();


            public List Getbm()//获取部门
            {
                string xx = objjmjm.Decrypt(connString_ORACLE);

                List rgdata = new List();

                OracleConnection conn = new OracleConnection(objjmjm.Decrypt(connString_ORACLE));


                try
                {
                    conn.Open();
                    var cmd = conn.CreateCommand();
                    cmd.CommandText = " select  *  from rg order by bmbm ";
                    cmd.CommandType = CommandType.Text;
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        rgdata.Add(new rg()
                        {
                            year = reader["year"].ToString(),
                            month = reader["month"].ToString(),
                            bmbm = reader["bmbm"].ToString(),
                            bmtxt = reader["bmtxt"].ToString(),
                            name = reader["name"].ToString(),
                            xc = Convert.ToDecimal(reader["xc"]),
                            wxyj = Convert.ToDecimal(reader["wxyj"]) ,
                            total = Convert.ToDecimal(reader["xc"]) + Convert.ToDecimal(reader["wxyj"])

                        });

                        

                    }

                }
                catch (Exception ex)
                {
                    string errorInfo = "connect GS oracle false " + ex.Message;
                    throw ex;
                }
                finally
                {
                    conn.Close();
                }

                return rgdata;

            }


        }

    }

  • 相关阅读:
    XSS工具
    只需 6 步,你就可以搭建一个云原生操作系统原型
    CentOS7用yum安装MySQL8.0 2209170054
    12个MySQL慢查询的原因分析
    vscode markdown 使用技巧 -- 如何快速打出一个Tab 或多个空格
    前端总结——计算机网络
    1、线性表相关算法
    ansible学习
    百度地图 新公司分部如何添加到地图导航上
    Git的一些常用概念与操作方法分享
  • 原文地址:https://blog.csdn.net/liheao/article/details/126734381