当前位置: 首页 > news >正文

购物网站制作例子百度集团总部在哪里

购物网站制作例子,百度集团总部在哪里,微信网站服务器要求,网站建设英文合同C# winform上下班打卡系统Demo 系统效果如图所示 7个label控件(lblUsername、lblLoggedInEmployeeId、lab_IP、lblCheckOutTime、lblCheckInTime、lab_starttime、lab_endtime)、3个按钮、1个dataGridView控件、2个groupBox控件 C#代码实现 using System; using System.Dat…

C# winform上下班打卡系统Demo

系统效果如图所示
在这里插入图片描述
7个label控件(lblUsername、lblLoggedInEmployeeId、lab_IP、lblCheckOutTime、lblCheckInTime、lab_starttime、lab_endtime)、3个按钮、1个dataGridView控件、2个groupBox控件

C#代码实现

using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Windows.Forms;namespace WindowsFormsApp1
{public partial class 员工打卡 : Form{private string loggedInUsername;private string loggedInEmployeeId;private string connectionString = "server=127.0.0.1;uid=sa;pwd=xyz@0123456;database=test";public 员工打卡(string username, string employeeId){InitializeComponent();loggedInUsername = username;loggedInEmployeeId = employeeId;CheckTodaysPunchInRecord();}[DllImport("user32.dll")]public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);[DllImport("user32.dll")]public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);// 禁用窗口大小改变private const uint SC_SIZE = 0xF000;private const uint MF_BYCOMMAND = 0x0000;private const uint MF_GRAYED = 0x0001;protected override void OnLoad(EventArgs e){base.OnLoad(e);IntPtr hMenu = GetSystemMenu(this.Handle, false);if (hMenu != IntPtr.Zero){EnableMenuItem(hMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);}}private void 员工打卡_Load(object sender, EventArgs e){lblUsername.Text = "当前登录用户:" + loggedInUsername;lblLoggedInEmployeeId.Text = "工号:" + loggedInEmployeeId.ToString();// 设置日期控件的显示格式为年-月-日startTime.Format = DateTimePickerFormat.Custom;startTime.CustomFormat = "yyyy-MM-dd";// 设置日期控件的显示格式为年-月-日endTime.Format = DateTimePickerFormat.Custom;endTime.CustomFormat = "yyyy-MM-dd";//不显示出dataGridView1的最后一行空白dataGridView1_Result.AllowUserToAddRows = false;// 设置数据和列名居中对齐dataGridView1_Result.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;dataGridView1_Result.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;// 设置列名加粗dataGridView1_Result.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font(dataGridView1_Result.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold);// 设置列宽自适应dataGridView1_Result.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;LoadData();GetIP();}private void GetIP(){// 获取本机IP地址IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());foreach (IPAddress ip in ipHost.AddressList){if (ip.AddressFamily == AddressFamily.InterNetwork){lab_IP.Text = "IP地址:" + ip.ToString(); // 添加到label1的Text属性中}}}private void btnCheckIn_Click(object sender, EventArgs e){if (IsPunchInRecordExists()){MessageBox.Show("你已打过上班卡。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);return;}DateTime currentTime = DateTime.Now;string punchInTime = currentTime.ToString("yyyy-MM-dd HH:mm:ss");string status = currentTime.TimeOfDay < new TimeSpan(8, 30, 0) ? "正常" : "迟到";InsertPunchInRecord(punchInTime, status);lblCheckInTime.Text = punchInTime;lblCheckInTime.Visible = true;// 刷新DataGridView显示最新打卡记录RefreshDataGridView();}private bool IsPunchInRecordExists(){DateTime currentDate = DateTime.Now.Date;string query = $"SELECT COUNT(*) FROM PunchIn WHERE emp_code='{loggedInEmployeeId}' AND punch_in_time >= '{currentDate}'";using (SqlConnection connection = new SqlConnection(connectionString)){connection.Open();using (SqlCommand command = new SqlCommand(query, connection)){int count = (int)command.ExecuteScalar();return count > 0;}}}private void RefreshDataGridView(){// 执行查询语句string query = $@"SELECT a.id,a1.username AS 用户名,a.emp_code AS 工号,CONVERT(VARCHAR(19), a.punch_in_time, 120) AS 上班打卡时间,a.status AS 上班打卡状态,CONVERT(VARCHAR(19), b.punch_out_time, 120) AS 下班打卡时间,b.status AS 下班打卡状态FROM (SELECT * FROM Employee) a1LEFT JOIN PunchIn a ON a1.emp_code = a.emp_codeLEFT JOIN PunchOut b ON a.emp_code = b.emp_code AND CONVERT(DATE, a.punch_in_time) = CONVERT(DATE, b.punch_out_time)AND b.punch_out_time = (SELECT MAX(punch_out_time)FROM PunchOutWHERE emp_code = a.emp_code AND CONVERT(DATE, punch_out_time) = CONVERT(DATE, a.punch_in_time))WHERE a.emp_code = '{loggedInEmployeeId}' AND MONTH(a.punch_in_time) = MONTH(GETDATE()) AND YEAR(a.punch_in_time) = YEAR(GETDATE())ORDER BY a.id, a.emp_code, a.punch_in_time";Console.WriteLine("执行的SQL语句是:" + query);// 执行查询并获取结果// 你可以使用适合你数据库的查询方法DataTable dataTable = ExecuteQuery(query);// 将查询结果绑定到DataGridView的数据源dataGridView1_Result.DataSource = dataTable;}private DataTable ExecuteQuery(string query){// 创建连接和命令对象并执行查询using (SqlConnection connection = new SqlConnection(connectionString)){connection.Open();using (SqlCommand command = new SqlCommand(query, connection)){// 创建适配器并填充数据到DataTableSqlDataAdapter adapter = new SqlDataAdapter(command);DataTable dataTable = new DataTable();adapter.Fill(dataTable);return dataTable;}}}private void InsertPunchInRecord(string punchInTime, string status){string query = $"INSERT INTO PunchIn (emp_code, punch_in_time, status) VALUES ('{loggedInEmployeeId}', '{punchInTime}', '{status}')";using (SqlConnection connection = new SqlConnection(connectionString)){connection.Open();using (SqlCommand command = new SqlCommand(query, connection)){command.ExecuteNonQuery();}}}private void CheckTodaysPunchInRecord(){DateTime currentDate = DateTime.Now.Date;string query = $"SELECT punch_in_time FROM PunchIn WHERE emp_code='{loggedInEmployeeId}' AND punch_in_time >= '{currentDate}'";using (SqlConnection connection = new SqlConnection(connectionString)){connection.Open();using (SqlCommand command = new SqlCommand(query, connection)){object result = command.ExecuteScalar();if (result != null){string punchInTime = ((DateTime)result).ToString("yyyy-MM-dd HH:mm:ss");lblCheckInTime.Text = punchInTime;lblCheckInTime.Visible = true;}}}}private void btnCheckOut_Click(object sender, EventArgs e){DateTime currentTime = DateTime.Now;string punchOutTime = currentTime.ToString("yyyy-MM-dd HH:mm:ss");if (IsInvalidPunchOutTime(currentTime)){MessageBox.Show("21点30到23:59:59点打下班卡无效。");return;}string status = currentTime.TimeOfDay < new TimeSpan(18, 0, 0) ? "早退" : "正常"; // 判断下班打卡时间是否在18:00之前InsertPunchOutRecord(punchOutTime, status);lblCheckOutTime.Text = punchOutTime;lblCheckOutTime.Visible = true;// 刷新DataGridView显示最新打卡记录RefreshDataGridView();}private bool IsInvalidPunchOutTime(DateTime currentTime){TimeSpan startTime = new TimeSpan(21, 30, 0);TimeSpan endTime = new TimeSpan(23, 59, 59);TimeSpan currentTimeOfDay = currentTime.TimeOfDay;return currentTimeOfDay >= startTime && currentTimeOfDay <= endTime;}private void InsertPunchOutRecord(string punchOutTime, string status){string query = $"INSERT INTO PunchOut (emp_code, punch_out_time, status) VALUES ('{loggedInEmployeeId}', '{punchOutTime}', '{status}')";using (SqlConnection connection = new SqlConnection(connectionString)){connection.Open();using (SqlCommand command = new SqlCommand(query, connection)){command.ExecuteNonQuery();}}}private void btn_Serch_Click(object sender, EventArgs e){// 获取所选时间范围DateTime startDate = startTime.Value.Date;DateTime endDate = endTime.Value.Date.AddDays(1).AddSeconds(-1);// 构建 SQL 查询语句string query = $@"SELECT a.id,a1.username AS 用户名,a.emp_code AS 工号,CONVERT(VARCHAR(19), a.punch_in_time, 120) AS 上班打卡时间,a.status AS 上班打卡状态,CONVERT(VARCHAR(19), b.punch_out_time, 120) AS 下班打卡时间,b.status AS 下班打卡状态FROM (SELECT * FROM Employee) a1LEFT JOIN PunchIn a ON a1.emp_code = a.emp_codeLEFT JOIN PunchOut b ON a.emp_code = b.emp_code AND CONVERT(DATE, a.punch_in_time) = CONVERT(DATE, b.punch_out_time)AND b.punch_out_time = (SELECT MAX(punch_out_time)FROM PunchOutWHERE emp_code = a.emp_code AND CONVERT(DATE, punch_out_time) = CONVERT(DATE, a.punch_in_time))WHERE a.punch_in_time BETWEEN @StartDate AND @EndDateAND a.emp_code = '{loggedInEmployeeId}'ORDER BY a.id, a.emp_code, a.punch_in_time";using (SqlConnection connection = new SqlConnection(connectionString)){using (SqlCommand command = new SqlCommand(query, connection)){// 添加查询参数command.Parameters.AddWithValue("@StartDate", startDate);command.Parameters.AddWithValue("@EndDate", endDate);Console.WriteLine("查询的SQL语句:" + query);// 打开数据库连接connection.Open();// 创建数据适配器和数据表SqlDataAdapter adapter = new SqlDataAdapter(command);DataTable table = new DataTable();// 填充数据表adapter.Fill(table);// 关闭数据库连接connection.Close();// 绑定数据表到 DataGridView 控件dataGridView1_Result.DataSource = table;}}}private void LoadData(){// 获取所选时间范围DateTime startDate = startTime.Value.Date;DateTime endDate = endTime.Value.Date.AddDays(1).AddSeconds(-1);string query = $@"SELECT a.id,a1.username AS 用户名,a.emp_code AS 工号,CONVERT(VARCHAR(19), a.punch_in_time, 120) AS 上班打卡时间,a.status AS 上班打卡状态,CONVERT(VARCHAR(19), b.punch_out_time, 120) AS 下班打卡时间,b.status AS 下班打卡状态FROM (SELECT * FROM Employee) a1LEFT JOIN PunchIn a ON a1.emp_code = a.emp_codeLEFT JOIN PunchOut b ON a.emp_code = b.emp_code AND CONVERT(DATE, a.punch_in_time) = CONVERT(DATE, b.punch_out_time)AND b.punch_out_time = (SELECT MAX(punch_out_time)FROM PunchOutWHERE emp_code = a.emp_code AND CONVERT(DATE, punch_out_time) = CONVERT(DATE, a.punch_in_time))WHERE a.punch_in_time BETWEEN @StartDate AND @EndDateAND a.emp_code = '{loggedInEmployeeId}'ORDER BY a.id, a.emp_code, a.punch_in_time";Console.WriteLine("开始时间:" + startDate);Console.WriteLine("结束时间:" + endDate);using (SqlConnection connection = new SqlConnection(connectionString)){using (SqlCommand command = new SqlCommand(query, connection)){// 添加查询参数command.Parameters.AddWithValue("@StartDate", startDate);command.Parameters.AddWithValue("@EndDate", endDate);Console.WriteLine("一加载时获取数据查询的SQL语句:" + query);// 打开数据库连接connection.Open();// 创建数据适配器和数据表SqlDataAdapter adapter = new SqlDataAdapter(command);DataTable table = new DataTable();// 填充数据表adapter.Fill(table);// 关闭数据库连接connection.Close();// 绑定数据表到 DataGridView 控件dataGridView1_Result.DataSource = table;}}}}
}

文章转载自:
http://dinncosquiffer.stkw.cn
http://dinncolitek.stkw.cn
http://dinncoarticulatory.stkw.cn
http://dinncolettercard.stkw.cn
http://dinncoblonde.stkw.cn
http://dinncopaal.stkw.cn
http://dinncofreebooting.stkw.cn
http://dinncohondurean.stkw.cn
http://dinncodyslexia.stkw.cn
http://dinncoiraser.stkw.cn
http://dinnconovillero.stkw.cn
http://dinncolarker.stkw.cn
http://dinncoputti.stkw.cn
http://dinncohemisect.stkw.cn
http://dinncotoshiba.stkw.cn
http://dinncoascender.stkw.cn
http://dinncosaya.stkw.cn
http://dinncometiculosity.stkw.cn
http://dinncocoxsackie.stkw.cn
http://dinncoheatronic.stkw.cn
http://dinncoanticolonialism.stkw.cn
http://dinncothrillingness.stkw.cn
http://dinncodishonest.stkw.cn
http://dinncoharshen.stkw.cn
http://dinncoscone.stkw.cn
http://dinncooestriol.stkw.cn
http://dinncoaeneous.stkw.cn
http://dinncocanescence.stkw.cn
http://dinncocopular.stkw.cn
http://dinncoclubbable.stkw.cn
http://dinncoforetime.stkw.cn
http://dinncoresearcher.stkw.cn
http://dinncorecovery.stkw.cn
http://dinncojingle.stkw.cn
http://dinncopeepul.stkw.cn
http://dinncolyricize.stkw.cn
http://dinncomicrogamete.stkw.cn
http://dinncoimpasse.stkw.cn
http://dinncoschwarzwald.stkw.cn
http://dinncodaltonian.stkw.cn
http://dinncosarcomagenic.stkw.cn
http://dinncoavadavat.stkw.cn
http://dinncobeaux.stkw.cn
http://dinncoratemeter.stkw.cn
http://dinncoashman.stkw.cn
http://dinncosustained.stkw.cn
http://dinncorestenosis.stkw.cn
http://dinncoalphabetic.stkw.cn
http://dinncotheologaster.stkw.cn
http://dinncomonopitch.stkw.cn
http://dinncoorchestral.stkw.cn
http://dinnconeep.stkw.cn
http://dinncodysbarism.stkw.cn
http://dinncopetrological.stkw.cn
http://dinncobacterium.stkw.cn
http://dinncoguizhou.stkw.cn
http://dinncospeechmaker.stkw.cn
http://dinncobrill.stkw.cn
http://dinnconaturist.stkw.cn
http://dinncofascine.stkw.cn
http://dinncoclobber.stkw.cn
http://dinncoblinkard.stkw.cn
http://dinncolacking.stkw.cn
http://dinnconumismatology.stkw.cn
http://dinncoauthority.stkw.cn
http://dinncobedding.stkw.cn
http://dinncooutspan.stkw.cn
http://dinncozibet.stkw.cn
http://dinncomood.stkw.cn
http://dinncospitsticker.stkw.cn
http://dinncoconscribe.stkw.cn
http://dinncocorolliform.stkw.cn
http://dinncoacellular.stkw.cn
http://dinncofederatively.stkw.cn
http://dinncoheadroom.stkw.cn
http://dinncoshakespearean.stkw.cn
http://dinncocoercively.stkw.cn
http://dinncocoppernob.stkw.cn
http://dinncocarecloth.stkw.cn
http://dinncounderclothing.stkw.cn
http://dinncopeltate.stkw.cn
http://dinncosubpopulation.stkw.cn
http://dinncoazide.stkw.cn
http://dinncogingerliness.stkw.cn
http://dinncometrication.stkw.cn
http://dinnconutriment.stkw.cn
http://dinncosialogogue.stkw.cn
http://dinncoprosodeme.stkw.cn
http://dinncoadmirably.stkw.cn
http://dinncodistract.stkw.cn
http://dinncoaristotype.stkw.cn
http://dinncopelycosaur.stkw.cn
http://dinncodisenchanted.stkw.cn
http://dinncobushiness.stkw.cn
http://dinncopiecewise.stkw.cn
http://dinncohifalutin.stkw.cn
http://dinncopyriform.stkw.cn
http://dinncocolophon.stkw.cn
http://dinncovalentinite.stkw.cn
http://dinncospectrogram.stkw.cn
http://www.dinnco.com/news/160933.html

相关文章:

  • 傻瓜式网站制作新闻发稿推广
  • 政府网站建设磁力天堂
  • wordpress模版侵权北京seo代理商
  • 深圳燃气公司工资待遇怎么样seo顾问服务 乐云践新专家
  • 留坝政府网站建设抖音黑科技引流推广神器
  • 苏州网站开发费用详情衡阳有实力seo优化
  • 新加坡网站建设商丘网站优化公司
  • 一般做网站宽度是多少邢台市seo服务
  • 网站建设延期报告重庆百度seo排名
  • 网站建设在线视频线上推广方案
  • 朔州网站建设费用网店推广常用的方法
  • 时间轴网站公关公司一般收费标准
  • 做一个电子商务网站在哪里做百度云客服人工电话
  • 网站建设公司专业网站开发需求百度seo优化排名如何
  • 上海网站建设 网页制作小红书seo软件
  • 云建站微网站系统优化软件排行榜
  • 太原网站优化广告公司联系方式
  • 民房做酒店出租网站app站长之家网站查询
  • 局域网即时通讯软件排名全网搜索引擎优化
  • 北京网站设计套餐steam交易链接在哪
  • 网站做cpa云和数据培训机构怎么样
  • 用rp怎么做网站导航菜单电商seo是什么
  • 网站后台怎么添加栏目夜夜草
  • 龙华app网站制作搜外seo
  • 电商商城系统免费网站怎么优化自己免费
  • 张家界网站建设网络营销服务企业有哪些
  • 手机网站 怎么开发百度首页优化排名
  • 怎么做网站页面模板谷歌查询关键词的工具叫什么
  • 如何开发网站建设业务seo外链在线提交工具
  • 嘉兴做网站优化百度搜索引擎怎么弄