Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime datetime = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, 1);

            strSql        = "select count(*)  from ydsb where yzz060='" + dateTimePicker1.Value.ToString("yyyy") + "' and yzz061='" + dateTimePicker1.Value.ToString("MM") + "' and flag=1 and aae140 = '" + aae140 + "'";
            sqlDataReader = db.GetDataReader(strSql);
            sqlDataReader.Read();
            if (sqlDataReader.GetValue(0).ToString() == "1")
            {
                button2.Text = "回退";
            }
            else
            {
                button2.Text = "提交";
            }
            if (button2.Text == "提交")
            {
                strSql = "select sfsb.aac002,sfsb.aac043,sfsb.aac044,sfsb.aac003,"
                         + "sfsb.aab301,gxjzdj.ykc700,fyjs.ykc618,gxjzdj.ykc701,cydj.ykc702,"
                         + "cydj.akb063,fyjs.akc194,gxjzdj.akc050,cydj.akc185,fyjs.akc264,"
                         + "fyjs.akb068,fyjs.ykc630,gxjzdj.aka130,aae140,gxjzdj.akc190,fyjs.yzz139,'无' as aae013"
                         + " from  gxjzdj,sfsb,fyjs,cydj "
                         + " where  gxjzdj.id = sfsb.id and sfsb.id = fyjs.id and sfsb.id = cydj.id "
                         + " and fyjs.akc194 between '" + datetime.ToString("yyyyMMdd") + "' and '" + datetime.AddMonths(1).AddDays(-1).ToString("yyyyMMdd") + "'"
                         + " and aae140 = '" + aae140 + "'";
                sqlDataAdapter = db.GetDataAdapter(strSql);
                dataSet        = new DataSet();
                sqlDataAdapter.Fill(dataSet, "caigou");
                dataGridView1.DataSource = dataSet.Tables["caigou"].DefaultView;
                strSql        = "select SUM(cast(akc264 as numeric(18,2))),COUNT(*) from fyjs where aae140 = '" + aae140 + "' and left(CONVERT(varchar(100), akc194, 112),6)='" + dateTimePicker1.Value.ToString("yyyyMM") + "'";
                sqlDataReader = db.GetDataReader(strSql);
                sqlDataReader.Read();
                label3.Text = sqlDataReader.GetValue(1).ToString();
                label6.Text = sqlDataReader.GetValue(0).ToString();
            }
            else
            {
                strSql         = "select transid,yzz060,yzz061,yzz062,aae140 from ydsb where flag=1 and aae140 = '" + aae140 + "' and yzz060='" + dateTimePicker1.Value.ToString("yyyy") + "' and yzz061='" + dateTimePicker1.Value.ToString("MM") + "'";
                sqlDataAdapter = db.GetDataAdapter(strSql);
                dataSet        = new DataSet();
                sqlDataAdapter.Fill(dataSet, "caigou");
                DataTable dt = dataSet.Tables[0];
                dt = qj.ppdt(dt);
                dataGridView1.DataSource = dt;
                strSql = "select ROW_NUMBER() OVER (ORDER BY fyjs.akc194 ASC) AS 序号,aac003 as "
                         + " 姓名,sfsb.aab301 as 参保地,sfsb.aac002 as 身份证号码,akc190 as 住院号 "
                         + " ,ykc701 as 入院日期,ykc702 as 出院日期,CONVERT(varchar(100), fyjs.akc194, 112) as 结算日期,akc050 "
                         + " as 入院诊断,cydj.akc185 as 出院诊断,fyjs.akc264 as 医疗费总额,ykc624 "
                         + " as 个人自负,akb068 as 统筹支付,ykc630 as 大病统筹,gxjzdj.aka130 as "
                         + " 医疗类别,'' as 备注 from sfsb, gxjzdj, cydj, fyjs where "
                         + " sfsb.id = gxjzdj.id and sfsb.id = cydj.id and sfsb.id = fyjs.id "
                         + " and aae140 = '" + aae140 + "' and fyjs.akc194 between '" + datetime.ToString("yyyyMMdd") + "' and '" + datetime.AddMonths(1).AddDays(-1).ToString("yyyyMMdd") + "'";
                sqlDataAdapter = db.GetDataAdapter(strSql);
                dataSet        = new DataSet();
                sqlDataAdapter.Fill(dataSet, "caigou");
                DataTable dt1 = dataSet.Tables[0];
                dt1 = qj.ppdt(dt1);
                dataGridView2.DataSource = dt1;
                strSql = "select ROW_NUMBER() OVER (ORDER BY fyjs.akc194 ASC) AS 序号,"
                         + " cydj.aab301 as 参保地,COUNT(*) as 就医人数,COUNT(*) as 就医人次,"
                         + " SUM(cast(akc264 as numeric(18, 2))) as 医疗费总额,"
                         + " SUM(cast(ykc624 as numeric(18, 2))) as 个人自负金额,"
                         + " SUM(cast(akb068 as numeric(18, 2))) as 记账金额,"
                         + " SUM(cast(ykc630 as numeric(18, 2))) as 大病金额,'' as 备注"
                         + " from fyjs, cydj where cydj.id = fyjs.id"
                         + " and aae140 = '" + aae140 + "' and fyjs.akc194 between '" + datetime.ToString("yyyyMMdd") + "' and '" + datetime.AddMonths(1).AddDays(-1).ToString("yyyyMMdd") + "'"
                         + " group by fyjs.akc194,cydj.aab301";
                sqlDataAdapter = db.GetDataAdapter(strSql);
                dataSet        = new DataSet();
                sqlDataAdapter.Fill(dataSet, "caigou");
                DataTable dt2 = dataSet.Tables[0];
                dt2 = qj.ppdt(dt2);
                dataGridView3.DataSource = dt2;
            }
        }