//上下班 private void btnClock_Click(object sender, EventArgs e) { if (m_tech_id == "-1") { BathClass.printErrorMsg("请先选择技师!"); return; } var tech_index = dao.get_techIndex("select * from [TechIndex] where dutyid=" + m_tech.jobId); List<string> old_index = null; if (tech_index != null) old_index = tech_index.ids.Split('%').ToList(); string cmd_str = ""; if (m_tech.techStatus != null && m_tech.techStatus == "下班") { cmd_str = "update [Employee] set techStatus='空闲',startTime=null, seat=null,serverTime=null,room=null,OrderClock=null" + " where id='" + m_tech_id + "'"; if (tech_index != null) { old_index.Add(m_tech_id); cmd_str += " update [techIndex] set ids='" + string.Join("%", old_index.ToArray()) + "' where id=" + tech_index.id; } } else { if (m_tech.techStatus != null && m_tech.techStatus != "空闲") { if (BathClass.printAskMsg("技师正在上钟,确认下班?") != DialogResult.Yes) return; } cmd_str = "update [Employee] set techStatus='下班' where id='" + m_tech_id + "'"; if (tech_index != null) { old_index.Remove(m_tech_id); cmd_str += " update [techIndex] set ids='" + string.Join("%", old_index.ToArray()) + "' where id=" + tech_index.id; } } if (!dao.execute_command(cmd_str)) { BathClass.printErrorMsg("技师上下班失败!"); return; } else { var btn = (Button)(tPanel.Controls.Find(m_tech_id, false).FirstOrDefault()); btn.ImageIndex = -1; m_tech_id = "-1"; m_tech = null; } }
public CEmployee get_Employee(string state_str) { CEmployee user = null; SqlConnection sqlCn = null; string cmd_str = ""; try { sqlCn = new SqlConnection(_con_str); sqlCn.Open(); cmd_str = "Select * from [Employee] where (" + state_str + ")"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { user = new CEmployee(); user.id = dr["id"].ToString(); user.name = dr["name"].ToString(); user.cardId = ToString(dr["cardId"]); user.gender = dr["gender"].ToString(); user.birthday = (DateTime)dr["birthday"]; user.jobId = (int)dr["jobId"]; user.password = dr["password"].ToString(); user.phone = dr["phone"].ToString(); user.address = dr["address"].ToString(); user.email = dr["email"].ToString(); user.status = ToString(dr["status"]); user.techStatus = ToString(dr["techStatus"]); //user = dr[""].ToString(); //user = dr[""].ToString(); //user = dr[""].ToString(); //user = dr[""].ToString(); //user = dr[""].ToString(); //user = dr[""].ToString(); //user = dr[""].ToString(); //user = dr[""].ToString(); } } } catch (System.Exception e) { IOUtil.insert_file(DateTime.Now.ToString() + "=" + cmd_str); BathClass.printErrorMsg(e.Message); } finally { close_connection(sqlCn); } return user; }
//点击台位按钮 private void btn_Click(object sender, EventArgs e) { var btn = sender as Button; if (btn.Name == m_tech_id) { btn.ImageIndex = -1; m_tech_id = "-1"; } else { if (m_tech_id != "-1") { var old_btn = (Button)(tPanel.Controls.Find(m_tech_id, false).FirstOrDefault()); if (old_btn != null) old_btn.ImageIndex = -1; } btn.ImageIndex = 0; m_tech_id = btn.Name; m_tech = dao.get_Employee("id='" + m_tech_id + "'"); if (m_tech.techStatus != null && m_tech.techStatus == "下班") btnClock.Text = "上班"; else btnClock.Text = "下班"; } }