private void ActiveAppointment(ActiveRes res) { LoadingOverlay.Instance.Hide(); GlobalData.AppointmentData.UpdateUserAppointment(res.UserAppointments); View.SetData(_appointmentRuleVo, GlobalData.AppointmentData); Show(); }
public ActiveRes Active(string activeCode, string machineCode) { // bool flag = false; ActiveRes res = new ActiveRes(); res.Success = false; string querySql = "select * from clientinfo where activecode=?ACODE"; string clientID = ""; List <MySqlParameter> paras = new List <MySqlParameter>(); MySqlParameter para = new MySqlParameter(); para.ParameterName = "?ACODE"; para.Value = activeCode; para.Direction = ParameterDirection.Input; para.DbType = DbType.String; paras.Add(para); DataTable dt1 = DbHelper.ExecuteDataTable(querySql, paras.ToArray()); if (dt1 != null && dt1.Rows.Count > 0) { clientID = dt1.Rows[0]["clientID"].ToString(); string id = ""; //检查是否已激活过 querySql = "select * from activeinfo where machineCode='" + machineCode + "' and ClientID='" + clientID + "'"; DataTable dt2 = DbHelper.ExecuteDataTable(querySql); if (dt2 != null && dt2.Rows.Count > 0) { id = dt2.Rows[0]["TerminalID"].ToString(); res.Success = true; res.ClientName = dt1.Rows[0]["ClientName"].ToString(); res.TerminalID = id; res.ClientID = clientID; res.PID = dt1.Rows[0]["PID"].ToString(); res.PKEY = dt1.Rows[0]["PKEY"].ToString(); res.AlipayAccount = dt1.Rows[0]["AlipayAccount"].ToString(); } else { //获取已激活数量 int count = 0; querySql = "select count(*) from activeinfo where clientID='" + clientID + "'"; object obj = DbHelper.ExecuteScalar(querySql); if (obj != null) { count = int.Parse(obj.ToString()) + 1; } id = clientID + count.ToString().PadLeft(2, '0'); //插入机器信息 string insertSql = "insert into activeinfo(clientID,machineCode,TerminalID,status) values('"; insertSql += clientID + "','" + machineCode + "','" + id; insertSql += "',0)"; if (DbHelper.ExecuteNonQuery(insertSql) > 0) { res.Success = true; res.ClientName = dt1.Rows[0]["ClientName"].ToString(); res.TerminalID = id; res.ClientID = clientID; res.PID = dt1.Rows[0]["PID"].ToString(); res.PKEY = dt1.Rows[0]["PKEY"].ToString(); res.AlipayAccount = dt1.Rows[0]["AlipayAccount"].ToString(); } } } else { res.Success = false; } return(res); // MySqlTransaction trans = (MySqlTransaction)DbHelper.DBConnection.BeginTransaction(); //创建事务 // cmd.Transaction = trans; //绑定事务 //foreach(.........) //{ // string sql = "....."; // cmd = new MySQLCommand(sqlInsert, mysqlConn); // cmd.ExecuteNonQuery(); //} //trans.Commit(); //return flag; }