private InterfaceReturnCode CreateInterfaceReturnCode(SQLResultCode code) { switch (code) { case SQLResultCode.Successful: return(InterfaceReturnCode.Success); //成功 case SQLResultCode.CannotConnectServer: return(InterfaceReturnCode.CannotConnectDatabase); //连接数据库失败 case SQLResultCode.NoRecord: return(InterfaceReturnCode.DatabaseNoRecord); //未找到记录 case SQLResultCode.SaveDataError: return(InterfaceReturnCode.DatabaseSaveDataError); //数据写入数据库失败 default: return(InterfaceReturnCode.DatabaseError); //失败 } }
/// <summary> /// 通过员工编号删除员工记录接口 /// </summary> /// <param name="employeeNum"></param> /// <returns></returns> public int DeleteEmployee(string employeeNum) { try { if (string.IsNullOrEmpty(employeeNum)) { return((int)InterfaceReturnCode.ParameterError); } SQLHelperProvider sqlHelper = new SQLHelperProvider(AppConifg.Current.ParkingConnection); string cmdstr = @"delete from Card where CardID=@cardID"; SqlCommand cmd = new SqlCommand(); cmd.CommandText = cmdstr; cmd.Parameters.AddWithValue("@cardID", employeeNum); SQLResultCode code = sqlHelper.SQLExecuteNonQuery(cmd).Result; InterfaceReturnCode result = CreateInterfaceReturnCode(code); return((int)result); } catch (Exception) { return((int)InterfaceReturnCode.InterfaceException);//接口执行期间发生错误 } }
/// <summary> /// 获取命令返回结果的文字描述 /// </summary> /// <param name="result"></param> /// <returns></returns> public static string GetDescription(SQLResultCode result) { switch (result) { case SQLResultCode.CannotConnectServer: return("连接服务器(数据库)失败"); case SQLResultCode.Fail: return("失败"); case SQLResultCode.NoRecord: return("没有找到记录"); case SQLResultCode.SaveDataError: return("数据写入数据库时失败"); case SQLResultCode.Successful: return("成功"); default: return("失败"); } }
public SQLQueryResult(SQLResultCode code, string msg, T obj) { this._result = code; this._msg = msg; this._queryObject = obj; }
public SQLQueryResult(SQLResultCode code, T obj) { this._result = code; this._msg = SQLResultCodeDecription.GetDescription(code); this._queryObject = obj; }
public SQLCommandResult(SQLResultCode code, string msg) { this._ret = code; this._msg = msg; }
public SQLCommandResult(SQLResultCode code) { this._ret = code; this._msg = SQLResultCodeDecription.GetDescription(code); }
public SQLQueryResultList(SQLResultCode code, string msg, List <T> list) { this._result = code; this._msg = msg; this._queryList = list; }
public SQLQueryResultList(SQLResultCode code, List <T> list) { this._result = code; this._msg = SQLResultCodeDecription.GetDescription(code); this.QueryObjects = list; }