paibangbiao.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:4k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Data.SqlClient;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. public partial class web_paibangbiao : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.     }
  17.     protected void Button1_Click(object sender, EventArgs e)
  18.     {
  19.         int id = 1;
  20.         int num = 0;
  21.         ArrayList num1 = new ArrayList();
  22.         ArrayList num2 = new ArrayList();
  23.         SqlConnection conn5 = dbConnection.getConnection();
  24.         conn5.Open();
  25.         SqlCommand sqlcomm5 = new SqlCommand("select count(id) as id from dbo.OA_KAOQIN_MD_JL", conn5);
  26.         num = Convert.ToInt16(sqlcomm5.ExecuteScalar());
  27.         if (num != 0)
  28.         {
  29.             SqlCommand sqlcomm4 = new SqlCommand("select max(id) as id from dbo.OA_KAOQIN_MD_JL", conn5);
  30.             id = Convert.ToInt16(sqlcomm4.ExecuteScalar())+1;
  31.         }
  32.         conn5.Close();
  33.         SqlConnection conn1 = dbConnection.getConnection();
  34.         SqlCommand sqlcomm1 = new SqlCommand("select distinct data from dbo.OA_KAOQIN_MD ", conn1);
  35.         conn1.Open();
  36.         SqlDataReader comm1 = sqlcomm1.ExecuteReader();
  37.         while (comm1.Read())
  38.         {
  39.             num1.Add(comm1["data"]);
  40.         }
  41.         comm1.Close();
  42.         conn1.Close();
  43.         SqlConnection conn2 = dbConnection.getConnection();
  44.         SqlCommand sqlcomm2 = new SqlCommand("select distinct card_id from dbo.OA_KAOQIN_MD", conn2);
  45.         conn2.Open();
  46.         SqlDataReader comm2 = sqlcomm2.ExecuteReader();
  47.         while (comm2.Read())
  48.         {
  49.             num2.Add(comm2["card_id"]);
  50.         }
  51.         comm2.Close();
  52.         conn2.Close();
  53.         foreach (decimal i in num1)
  54.         {
  55.             foreach (string j in num2)
  56.             {
  57.                 decimal first_time = 0;
  58.                 decimal end_time = 0;
  59.                 SqlConnection conn3 = dbConnection.getConnection();
  60.                 conn3.Open();
  61.                 SqlCommand sqlcomm3 = new SqlCommand("select min(card_time) as card_time from dbo.OA_KAOQIN_MD where data=" + i + "and card_id=" + j, conn3);
  62.                 SqlDataReader comm3 = sqlcomm3.ExecuteReader();
  63.                 while (comm3.Read())
  64.                 {
  65.                     first_time = Convert.ToInt32(comm3["card_time"]);
  66.                 }
  67.                 comm3.Close();
  68.                 conn3.Close();
  69.                 SqlConnection conn6 = dbConnection.getConnection();
  70.                 conn6.Open();
  71.                 SqlCommand sqlcomm4 = new SqlCommand("select max(card_time) as card_time from dbo.OA_KAOQIN_MD where data=" + i + "and card_id=" + j,conn6);
  72.                 SqlDataReader comm4 = sqlcomm4.ExecuteReader();
  73.                 while (comm4.Read())
  74.                 {
  75.                     end_time = Convert.ToInt32(comm4["card_time"]);
  76.                 }
  77.                 comm4.Close();
  78.                 conn6.Close();
  79.                 SqlConnection conn4 = dbConnection.getConnection();
  80.                 conn4.Open();
  81.                 if (first_time != end_time)
  82.                 {
  83.                     SqlCommand cmd = new SqlCommand("insert into OA_KAOQIN_JL(id ,data,card_id,zao,wan,wuxia,wushang )values('" + id + "','" + i + "','" + j + "','" + first_time + "','" + end_time + "','0','0')", conn4);
  84.                     cmd.ExecuteNonQuery();
  85.                     id = id + 1;
  86.                 }
  87.                 else
  88.                 {
  89.                     SqlCommand cmd = new SqlCommand("insert into OA_KAOQIN_JL(id ,data,card_id,zao,wan,wuxia,wushang )values('" + id + "','" + i + "','" + j + "','" + first_time + "','0','0','0')", conn4);
  90.                     cmd.ExecuteNonQuery();
  91.                     id = id + 1;
  92.                 }
  93.                 conn4.Close();
  94.             }
  95.         }
  96.     }
  97. }